public class InternationalStringXmlReaderWriter extends Object
The helper should not be initialized, just use the static utility methods.
Modifier and Type | Field and Description |
---|---|
static String |
XML_ATTR_DEFAULT_LOCALE |
static String |
XML_ATTR_LOCALE |
static String |
XML_ATTR_TEXT |
static String |
XML_ELEMENT_LOCALIZED_STRING |
static String |
XML_TAG |
Modifier and Type | Method and Description |
---|---|
static Locale |
defaultLocaleFromXml(Element e)
Returns the default locale from the
default locale attribute
of the given element. |
static Locale |
defaultLocaleFromXml(Element element,
String tagName)
Reads the default locale from the international string stored in the child
Element
with the specified name. |
static Collection<org.faktorips.values.LocalizedString> |
fromXml(Element element)
Reads the
localized strings stored in the given XML Element . |
static Collection<org.faktorips.values.LocalizedString> |
fromXml(Element element,
String tagName)
Reads the
localized strings stored in the child Element with
the specified name. |
static void |
setDefaultLocaleInXml(Node node,
Locale defaultLocale) |
static Element |
toXml(Document doc,
Collection<org.faktorips.values.LocalizedString> localizedStrings)
Creates a new
Element representing the given localized
strings . |
static Element |
toXml(Document doc,
org.faktorips.values.DefaultInternationalString internationalString)
Creates a new
Element representing the given DefaultInternationalString . |
public static final String XML_TAG
public static final String XML_ELEMENT_LOCALIZED_STRING
public static final String XML_ATTR_DEFAULT_LOCALE
public static final String XML_ATTR_LOCALE
public static final String XML_ATTR_TEXT
public static Element toXml(Document doc, org.faktorips.values.DefaultInternationalString internationalString)
Element
representing the given DefaultInternationalString
.doc
- the XML Document
that will contain the new elementinternationalString
- the DefaultInternationalString
to create an element forpublic static Element toXml(Document doc, Collection<org.faktorips.values.LocalizedString> localizedStrings)
Element
representing the given localized
strings
.
The element that is created can be used to initialize the localized string of a
DefaultInternationalString
but is missing the attribute for the default locale
required by DefaultInternationalString
. That attribute is added by
org.faktorips.devtools.stdbuilder.productcmpt.ProductCmptXMLBuilder
when writing a
product component's XML.
doc
- the XML Document
that contains the new elementlocalizedStrings
- the localized strings
to be savedpublic static Collection<org.faktorips.values.LocalizedString> fromXml(Element element)
localized strings
stored in the given XML Element
.
If the given element is not representing an international string, an empty collection is
returned.public static Collection<org.faktorips.values.LocalizedString> fromXml(Element element, String tagName)
localized strings
stored in the child Element
with
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.element
- the XML Element
representing the parent of an international string.tagName
- the name of the child node representing an international string.localized strings
defined in the
international string.public static Locale defaultLocaleFromXml(Element element, String tagName)
Element
with the specified name. Returns null
if 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. The
toXml(Document, Collection)
method does not write the attribute for the default
locale. org.faktorips.devtools.stdbuilder.productcmpt.ProductCmptXMLBuilder
adds the
default locale when writing a product component's XML.
element
- the XML Element
representing the parent of an international stringtagName
- the name of the child node representing an international stringnull
public static Locale defaultLocaleFromXml(Element e)
default locale attribute
of the given element. Returns null
if the element is not an
localized string
element 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. The
toXml(Document, Collection)
method does not write the attribute for the default
locale. org.faktorips.devtools.stdbuilder.productcmpt.ProductCmptXMLBuilder
adds the
default locale when writing a product component's XML.
e
- the XML element representing an international stringnull
if the element does not
represent an international string or does not have a default locale attributeCopyright © 2021. All rights reserved.