Package org.faktorips.runtime.internal
Enum ValueToXmlHelper
- java.lang.Object
-
- java.lang.Enum<ValueToXmlHelper>
-
- org.faktorips.runtime.internal.ValueToXmlHelper
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<ValueToXmlHelper>
public enum ValueToXmlHelper extends java.lang.Enum<ValueToXmlHelper>
Helper class to write values to XML and retrieve them from XML.- Author:
- Jan Ortmann
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCONFIGURED_DEFAULT_PREFIXstatic java.lang.StringCONFIGURED_VALUE_SET_PREFIXstatic java.lang.StringLEGACY_XML_TAG_CONFIG_ELEMENTSince 3.19 the ConfigElement was separated in ConfiguredDefault and ConfiguredValueSet.static java.lang.StringXML_ATTRIBUTE_ATTRIBUTEstatic java.lang.StringXML_ATTRIBUTE_CONTAINS_NULLstatic java.lang.StringXML_ATTRIBUTE_EMPTYstatic java.lang.StringXML_ATTRIBUTE_IS_NULLstatic java.lang.StringXML_ATTRIBUTE_STRUCTURE_USAGEstatic java.lang.StringXML_TAG_ALL_VALUESstatic java.lang.StringXML_TAG_ATTRIBUTE_VALUEstatic java.lang.StringXML_TAG_CONFIGURED_DEFAULTstatic java.lang.StringXML_TAG_CONFIGURED_VALUE_SETstatic java.lang.StringXML_TAG_DATAstatic java.lang.StringXML_TAG_DERIVEDstatic java.lang.StringXML_TAG_ENUMstatic java.lang.StringXML_TAG_LOWER_BOUNDstatic java.lang.StringXML_TAG_MAXIMUM_LENGTHstatic java.lang.StringXML_TAG_RANGEstatic java.lang.StringXML_TAG_STEPstatic java.lang.StringXML_TAG_STRINGLENGTHstatic java.lang.StringXML_TAG_TABLE_CONTENT_NAMEstatic java.lang.StringXML_TAG_TABLE_CONTENT_USAGEstatic java.lang.StringXML_TAG_UPPER_BOUNDstatic java.lang.StringXML_TAG_VALUEUsed for both the value of a config element and the values of an enum value set.static java.lang.StringXML_TAG_VALUE_SET
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddCDataValueToElement(java.lang.String value, org.w3c.dom.Element el, java.lang.String tagName)Adds the value to the given xml element.static voidaddInternationalStringToElement(org.faktorips.values.DefaultInternationalString value, org.w3c.dom.Element el, java.lang.String tagName)Adds theDefaultInternationalStringto the given xml element.static voidaddTableUsageToElement(org.w3c.dom.Element el, java.lang.String structureUsage, java.lang.String tableContentName)Adds a table usage to the XML element.static org.w3c.dom.ElementaddValueAndReturnElement(java.lang.String value, org.w3c.dom.Element el, java.lang.String tagName)Adds the value to the given xml element as doesaddValueToElement(String, Element, String).static voidaddValueToElement(java.lang.String value, org.w3c.dom.Element el, java.lang.String tagName)Adds the value to the given xml element.static org.w3c.dom.ElementcreateValueElement(java.lang.String value, java.lang.String tagName, org.w3c.dom.Document ownerDocument, boolean useCDataSection)static EnumValuesgetEnumValueSetFromElement(org.w3c.dom.Element el, java.lang.String tagName)static org.faktorips.values.DefaultInternationalStringgetInternationalStringFromElement(org.w3c.dom.Element el)Returns theDefaultInternationalStringstored in the given element.static org.faktorips.values.DefaultInternationalStringgetInternationalStringFromElement(org.w3c.dom.Element el, java.lang.String tagName)Returns theDefaultInternationalStringstored in the child element of the given element with the indicated name.static RangegetRangeFromElement(org.w3c.dom.Element el, java.lang.String tagName)static org.faktorips.valueset.StringLengthValueSetgetStringLengthValueSetFromElement(org.w3c.dom.Element el, java.lang.String tagName)static <T> org.faktorips.valueset.UnrestrictedValueSet<T>getUnrestrictedValueSet(org.w3c.dom.Element el, java.lang.String tagName)static java.lang.StringgetValueFromElement(org.w3c.dom.Element valueEl)Returns the string representation of the value stored in given value element.static java.lang.StringgetValueFromElement(org.w3c.dom.Element el, java.lang.String tagName)Returns the string representation of the value stored in the child element of the given element with the indicated name.static booleanisAttributeTrue(org.w3c.dom.Element element, java.lang.String attribute)Returns whether the given element has an attribute by the given name that has the value"true".static voidsetValue(java.lang.String value, org.w3c.dom.Element valueEl)static ValueToXmlHelpervalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static ValueToXmlHelper[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Field Detail
-
XML_TAG_VALUE
public static final java.lang.String XML_TAG_VALUE
Used for both the value of a config element and the values of an enum value set.- See Also:
- Constant Field Values
-
XML_TAG_VALUE_SET
public static final java.lang.String XML_TAG_VALUE_SET
- See Also:
- Constant Field Values
-
XML_TAG_DATA
public static final java.lang.String XML_TAG_DATA
- See Also:
- Constant Field Values
-
LEGACY_XML_TAG_CONFIG_ELEMENT
public static final java.lang.String LEGACY_XML_TAG_CONFIG_ELEMENT
Since 3.19 the ConfigElement was separated in ConfiguredDefault and ConfiguredValueSet. We need this for reading legacy XML.- See Also:
- Constant Field Values
-
CONFIGURED_DEFAULT_PREFIX
public static final java.lang.String CONFIGURED_DEFAULT_PREFIX
- See Also:
- Constant Field Values
-
CONFIGURED_VALUE_SET_PREFIX
public static final java.lang.String CONFIGURED_VALUE_SET_PREFIX
- See Also:
- Constant Field Values
-
XML_TAG_CONFIGURED_DEFAULT
public static final java.lang.String XML_TAG_CONFIGURED_DEFAULT
- See Also:
- Constant Field Values
-
XML_TAG_CONFIGURED_VALUE_SET
public static final java.lang.String XML_TAG_CONFIGURED_VALUE_SET
- See Also:
- Constant Field Values
-
XML_TAG_ATTRIBUTE_VALUE
public static final java.lang.String XML_TAG_ATTRIBUTE_VALUE
- See Also:
- Constant Field Values
-
XML_ATTRIBUTE_ATTRIBUTE
public static final java.lang.String XML_ATTRIBUTE_ATTRIBUTE
- See Also:
- Constant Field Values
-
XML_TAG_ALL_VALUES
public static final java.lang.String XML_TAG_ALL_VALUES
- See Also:
- Constant Field Values
-
XML_TAG_STRINGLENGTH
public static final java.lang.String XML_TAG_STRINGLENGTH
- See Also:
- Constant Field Values
-
XML_TAG_DERIVED
public static final java.lang.String XML_TAG_DERIVED
- See Also:
- Constant Field Values
-
XML_TAG_ENUM
public static final java.lang.String XML_TAG_ENUM
- See Also:
- Constant Field Values
-
XML_TAG_RANGE
public static final java.lang.String XML_TAG_RANGE
- See Also:
- Constant Field Values
-
XML_TAG_STEP
public static final java.lang.String XML_TAG_STEP
- See Also:
- Constant Field Values
-
XML_TAG_UPPER_BOUND
public static final java.lang.String XML_TAG_UPPER_BOUND
- See Also:
- Constant Field Values
-
XML_TAG_LOWER_BOUND
public static final java.lang.String XML_TAG_LOWER_BOUND
- See Also:
- Constant Field Values
-
XML_TAG_TABLE_CONTENT_NAME
public static final java.lang.String XML_TAG_TABLE_CONTENT_NAME
- See Also:
- Constant Field Values
-
XML_TAG_TABLE_CONTENT_USAGE
public static final java.lang.String XML_TAG_TABLE_CONTENT_USAGE
- See Also:
- Constant Field Values
-
XML_TAG_MAXIMUM_LENGTH
public static final java.lang.String XML_TAG_MAXIMUM_LENGTH
- See Also:
- Constant Field Values
-
XML_ATTRIBUTE_STRUCTURE_USAGE
public static final java.lang.String XML_ATTRIBUTE_STRUCTURE_USAGE
- See Also:
- Constant Field Values
-
XML_ATTRIBUTE_IS_NULL
public static final java.lang.String XML_ATTRIBUTE_IS_NULL
- See Also:
- Constant Field Values
-
XML_ATTRIBUTE_CONTAINS_NULL
public static final java.lang.String XML_ATTRIBUTE_CONTAINS_NULL
- See Also:
- Constant Field Values
-
XML_ATTRIBUTE_EMPTY
public static final java.lang.String XML_ATTRIBUTE_EMPTY
- See Also:
- Constant Field Values
-
-
Method Detail
-
values
public static ValueToXmlHelper[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (ValueToXmlHelper c : ValueToXmlHelper.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static ValueToXmlHelper valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- if the argument is null
-
addValueToElement
public static void addValueToElement(java.lang.String value, org.w3c.dom.Element el, java.lang.String tagName)Adds the value to the given xml element. Takes care of proper null handling. By value we mean a value of a datatype, e.g. 42EUR is a value of the datatype money.- Parameters:
value- the string representation of the valueel- the xml element.tagName- the tag name for the element that stored the value
-
addInternationalStringToElement
public static void addInternationalStringToElement(org.faktorips.values.DefaultInternationalString value, org.w3c.dom.Element el, java.lang.String tagName)Adds theDefaultInternationalStringto the given xml element. Takes care of proper null handling.- Parameters:
value- theDefaultInternationalStringto be added.el- the xml element.tagName- the tag name for the element that stored the value.
-
addCDataValueToElement
public static void addCDataValueToElement(java.lang.String value, org.w3c.dom.Element el, java.lang.String tagName)Adds the value to the given xml element. The value is inserted inside a CDATA section.- Parameters:
value- the string representation of the valueel- the xml element.tagName- the tag name for the element that stored the value
-
createValueElement
public static org.w3c.dom.Element createValueElement(java.lang.String value, java.lang.String tagName, org.w3c.dom.Document ownerDocument, boolean useCDataSection)
-
setValue
public static void setValue(java.lang.String value, org.w3c.dom.Element valueEl)
-
addValueAndReturnElement
public static org.w3c.dom.Element addValueAndReturnElement(java.lang.String value, org.w3c.dom.Element el, java.lang.String tagName)Adds the value to the given xml element as doesaddValueToElement(String, Element, String). The created element then is returned.- Parameters:
value- the string representation of the valueel- the XML element to add the value to.tagName- the tag name for the element that stored the value- Returns:
- the created element with the given tag name, that contains the given value.
-
addTableUsageToElement
public static void addTableUsageToElement(org.w3c.dom.Element el, java.lang.String structureUsage, java.lang.String tableContentName)Adds a table usage to the XML element.- Parameters:
el- the XML element to add the value to.structureUsage- the value for the structureUsage XML attributetableContentName- the name of the used table content
-
getValueFromElement
public static java.lang.String getValueFromElement(org.w3c.dom.Element el, java.lang.String tagName)Returns the string representation of the value stored in the child element of the given element with the indicated name. Returnsnullif the value is null or no such child element exists.<Parent> <Property isNull="false">42</Property> </Parent>- Parameters:
el- The xml element that is the parent of the element storing the value.tagName- The name of the child
-
getInternationalStringFromElement
public static org.faktorips.values.DefaultInternationalString getInternationalStringFromElement(org.w3c.dom.Element el, java.lang.String tagName)Returns theDefaultInternationalStringstored in the child element of the given element with the indicated name. Returns an empty DefaultInternationalString if the value is null or no such child element exists.- Parameters:
el- The xml element that is the parent of the element storing the international string.tagName- The name of the child
-
getValueFromElement
public static java.lang.String getValueFromElement(org.w3c.dom.Element valueEl)
Returns the string representation of the value stored in given value element. Returnsnullif the value is null, the attribute isNull istrueor no such child element exists.<Property isNull="false">42</Property>- Parameters:
valueEl- The xml value element containing the value.
-
getInternationalStringFromElement
public static org.faktorips.values.DefaultInternationalString getInternationalStringFromElement(org.w3c.dom.Element el)
Returns theDefaultInternationalStringstored in the given element. Returns an empty DefaultInternationalString if the value is null.- Parameters:
el- The xml element storing the international string.
-
getRangeFromElement
public static Range getRangeFromElement(org.w3c.dom.Element el, java.lang.String tagName)
-
getEnumValueSetFromElement
public static EnumValues getEnumValueSetFromElement(org.w3c.dom.Element el, java.lang.String tagName)
-
getStringLengthValueSetFromElement
public static org.faktorips.valueset.StringLengthValueSet getStringLengthValueSetFromElement(org.w3c.dom.Element el, java.lang.String tagName)
-
getUnrestrictedValueSet
public static <T> org.faktorips.valueset.UnrestrictedValueSet<T> getUnrestrictedValueSet(org.w3c.dom.Element el, java.lang.String tagName)
-
isAttributeTrue
public static boolean isAttributeTrue(org.w3c.dom.Element element, java.lang.String attribute)Returns whether the given element has an attribute by the given name that has the value"true".
-
-