Class InternationalStringXmlReaderWriter
The helper should not be initialized, just use the static utility methods.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic LocaleReturns the default locale from thedefault locale attributeof the given element.static LocaledefaultLocaleFromXml(Element element, String tagName) Reads the default locale from the international string stored in the childElementwith the specified name.static Collection<org.faktorips.values.LocalizedString>Reads thelocalized stringsstored in the given XMLElement.static Collection<org.faktorips.values.LocalizedString>Reads thelocalized stringsstored in the childElementwith the specified name.static voidsetDefaultLocaleInXml(Node node, Locale defaultLocale) static ElementtoXml(Document doc, Collection<org.faktorips.values.LocalizedString> localizedStrings) Creates a newElementrepresenting the givenlocalized strings.static ElementCreates a newElementrepresenting the givenDefaultInternationalString.
-
Field Details
-
XML_TAG
- See Also:
-
XML_ELEMENT_LOCALIZED_STRING
- See Also:
-
XML_ATTR_DEFAULT_LOCALE
- See Also:
-
XML_ATTR_LOCALE
- See Also:
-
XML_ATTR_TEXT
- See Also:
-
-
Method Details
-
toXml
public static Element toXml(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 Element toXml(Document doc, 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
Reads thelocalized stringsstored in the given XMLElement. If the given element is not representing an international string, an empty collection is returned. -
fromXml
public static Collection<org.faktorips.values.LocalizedString> fromXml(Element element, 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
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
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
-