Enum 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 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
      • 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_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 name
        java.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 value
        el - 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 the DefaultInternationalString to the given xml element. Takes care of proper null handling.
        Parameters:
        value - the DefaultInternationalString to 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 value
        el - 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 does addValueToElement(String, Element, String). The created element then is returned.
        Parameters:
        value - the string representation of the value
        el - 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 attribute
        tableContentName - 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. Returns null if 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 the DefaultInternationalString stored 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. Returns null if the value is null, the attribute isNull is true or 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 the DefaultInternationalString stored 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".