Class InternationalStringXmlReaderWriter
- java.lang.Object
-
- org.faktorips.runtime.internal.InternationalStringXmlReaderWriter
-
public class InternationalStringXmlReaderWriter extends java.lang.ObjectHelper class to read international strings from XML and write them back to XML.The helper should not be initialized, just use the static utility methods.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringXML_ATTR_DEFAULT_LOCALEstatic java.lang.StringXML_ATTR_LOCALEstatic java.lang.StringXML_ATTR_TEXTstatic java.lang.StringXML_ELEMENT_LOCALIZED_STRINGstatic java.lang.StringXML_TAG
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.LocaledefaultLocaleFromXml(org.w3c.dom.Element e)Returns the default locale from thedefault locale attributeof the given element.static java.util.LocaledefaultLocaleFromXml(org.w3c.dom.Element element, java.lang.String tagName)Reads the default locale from the international string stored in the childElementwith the specified name.static java.util.Collection<org.faktorips.values.LocalizedString>fromXml(org.w3c.dom.Element element)Reads thelocalized stringsstored in the given XMLElement.static java.util.Collection<org.faktorips.values.LocalizedString>fromXml(org.w3c.dom.Element element, java.lang.String tagName)Reads thelocalized stringsstored in the childElementwith the specified name.static voidsetDefaultLocaleInXml(org.w3c.dom.Node node, java.util.Locale defaultLocale)static org.w3c.dom.ElementtoXml(org.w3c.dom.Document doc, java.util.Collection<org.faktorips.values.LocalizedString> localizedStrings)Creates a newElementrepresenting the givenlocalized strings.static org.w3c.dom.ElementtoXml(org.w3c.dom.Document doc, org.faktorips.values.DefaultInternationalString internationalString)Creates a newElementrepresenting the givenDefaultInternationalString.
-
-
-
Field Detail
-
XML_TAG
public static final java.lang.String XML_TAG
- See Also:
- Constant Field Values
-
XML_ELEMENT_LOCALIZED_STRING
public static final java.lang.String XML_ELEMENT_LOCALIZED_STRING
- See Also:
- Constant Field Values
-
XML_ATTR_DEFAULT_LOCALE
public static final java.lang.String XML_ATTR_DEFAULT_LOCALE
- See Also:
- Constant Field Values
-
XML_ATTR_LOCALE
public static final java.lang.String XML_ATTR_LOCALE
- See Also:
- Constant Field Values
-
XML_ATTR_TEXT
public static final java.lang.String XML_ATTR_TEXT
- See Also:
- Constant Field Values
-
-
Method Detail
-
toXml
public static org.w3c.dom.Element toXml(org.w3c.dom.Document doc, org.faktorips.values.DefaultInternationalString internationalString)Creates a newElementrepresenting the givenDefaultInternationalString.- Parameters:
doc- the XMLDocumentthat will contain the new elementinternationalString- theDefaultInternationalStringto create an element for- Returns:
- the new element representing the given international string
-
toXml
public static org.w3c.dom.Element toXml(org.w3c.dom.Document doc, java.util.Collection<org.faktorips.values.LocalizedString> localizedStrings)Creates a newElementrepresenting the givenlocalized strings.The element that is created can be used to initialize the localized string of a
DefaultInternationalStringbut is missing the attribute for the default locale required byDefaultInternationalString. That attribute is added byorg.faktorips.devtools.stdbuilder.productcmpt.ProductCmptXMLBuilderwhen writing a product component's XML.- Parameters:
doc- the XMLDocumentthat contains the new elementlocalizedStrings- thelocalized stringsto be saved- Returns:
- the new element representing the localized strings
-
fromXml
public static java.util.Collection<org.faktorips.values.LocalizedString> fromXml(org.w3c.dom.Element element)
Reads thelocalized stringsstored in the given XMLElement. If the given element is not representing an international string, an empty collection is returned.- Parameters:
element- the XMLElementrepresenting an international string- Returns:
- a collection of all
localized stringsdefined in the international string represented by the givenElement.
-
fromXml
public static java.util.Collection<org.faktorips.values.LocalizedString> fromXml(org.w3c.dom.Element element, java.lang.String tagName)Reads thelocalized stringsstored in the childElementwith the specified name. If the given element does not contain a child of the given name or if that child does not represent an international string, an empty collection is returned.- Parameters:
element- the XMLElementrepresenting the parent of an international string.tagName- the name of the child node representing an international string.- Returns:
- a collection of all
localized stringsdefined in the international string.
-
defaultLocaleFromXml
public static java.util.Locale defaultLocaleFromXml(org.w3c.dom.Element element, java.lang.String tagName)Reads the default locale from the international string stored in the childElementwith the specified name. Returnsnullif the given element does not contain a child of the given name, if that child does not represent an international string or if that international string does not have a default locale.Note that the attribute for the default locale is only written by the
toXml(Document, DefaultInternationalString)method. ThetoXml(Document, Collection)method does not write the attribute for the default locale.org.faktorips.devtools.stdbuilder.productcmpt.ProductCmptXMLBuilderadds the default locale when writing a product component's XML.- Parameters:
element- the XMLElementrepresenting the parent of an international stringtagName- the name of the child node representing an international string- Returns:
- the default locale defined in the international string if present or
null
-
defaultLocaleFromXml
public static java.util.Locale defaultLocaleFromXml(org.w3c.dom.Element e)
Returns the default locale from thedefault locale attributeof the given element. Returnsnullif the element is not anlocalized stringelement or does not have a default locale attribute.Note that the attribute for the default locale is only written by the
toXml(Document, DefaultInternationalString)method. ThetoXml(Document, Collection)method does not write the attribute for the default locale.org.faktorips.devtools.stdbuilder.productcmpt.ProductCmptXMLBuilderadds the default locale when writing a product component's XML.- Parameters:
e- the XML element representing an international string- Returns:
- the default locale from the given element or
nullif the element does not represent an international string or does not have a default locale attribute
-
setDefaultLocaleInXml
public static void setDefaultLocaleInXml(org.w3c.dom.Node node, java.util.Locale defaultLocale)
-
-