Enum ValueToXmlHelper

java.lang.Object
java.lang.Enum<ValueToXmlHelper>
org.faktorips.runtime.internal.ValueToXmlHelper
All Implemented Interfaces:
Serializable, Comparable<ValueToXmlHelper>, java.lang.constant.Constable

public enum ValueToXmlHelper extends Enum<ValueToXmlHelper>
Helper class to write values to XML and retrieve them from XML.
Author:
Jan Ortmann
  • Field Details

  • Method Details

    • values

      public static ValueToXmlHelper[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static ValueToXmlHelper valueOf(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:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • addValueToElement

      public static void addValueToElement(String value, Element el, 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, Element el, 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(String value, Element el, 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 Element createValueElement(String value, String tagName, Document ownerDocument, boolean useCDataSection)
    • setValue

      public static void setValue(String value, Element valueEl)
    • addValueAndReturnElement

      public static Element addValueAndReturnElement(String value, Element el, 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(Element el, String structureUsage, 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 String getValueFromElement(Element el, 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(Element el, 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 String getValueFromElement(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(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(Element el, String tagName)
    • getEnumValueSetFromElement

      public static EnumValues getEnumValueSetFromElement(Element el, String tagName)
    • getStringLengthValueSetFromElement

      public static org.faktorips.valueset.StringLengthValueSet getStringLengthValueSetFromElement(Element el, String tagName)
    • getUnrestrictedValueSet

      public static <T> org.faktorips.valueset.UnrestrictedValueSet<T> getUnrestrictedValueSet(Element el, String tagName)
    • isAttributeTrue

      public static boolean isAttributeTrue(Element element, String attribute)
      Returns whether the given element has an attribute by the given name that has the value "true".