org.faktorips.runtime.internal
Class ValueToXmlHelper

java.lang.Object
  extended by org.faktorips.runtime.internal.ValueToXmlHelper

public class ValueToXmlHelper
extends Object

Helper class to write values to XML and retrieve them from XML.

Author:
Jan Ortmann

Field Summary
static String XML_ATTRIBUTE_ATTRIBUTE
           
static String XML_ATTRIBUTE_CONTAINS_NULL
           
static String XML_ATTRIBUTE_IS_NULL
           
static String XML_ATTRIBUTE_STRUCTURE_USAGE
           
static String XML_TAG_ALL_VALUES
           
static String XML_TAG_ATTRIBUTE_VALUE
           
static String XML_TAG_CONFIG_ELEMENT
           
static String XML_TAG_DATA
           
static String XML_TAG_ENUM
           
static String XML_TAG_LOWER_BOUND
           
static String XML_TAG_RANGE
           
static String XML_TAG_STEP
           
static String XML_TAG_TABLE_CONTENT_NAME
           
static String XML_TAG_TABLE_CONTENT_USAGE
           
static String XML_TAG_UPPER_BOUND
           
static String XML_TAG_VALUE
          Used for both the value of a config element and the values of an enum value set.
static String XML_TAG_VALUE_SET
           
 
Method Summary
static void addCDataValueToElement(String value, Element el, String tagName)
          Adds the value to the given xml element.
static void addInternationalStringToElement(org.faktorips.values.DefaultInternationalString value, Element el, String tagName)
          Adds the DefaultInternationalString to the given xml element.
static void addTableUsageToElement(Element el, String structureUsage, String tableContentName)
          Adds a table usage to the XML element.
static Element addValueAndReturnElement(String value, Element el, String tagName)
          Adds the value to the given xml element as does addValueToElement(String, Element, String).
static void addValueToElement(String value, Element el, String tagName)
          Adds the value to the given xml element.
static Element createValueElement(String value, String tagName, Document ownerDocument, boolean useCDataSection)
           
static EnumValues getEnumValueSetFromElement(Element el, String tagName)
           
static org.faktorips.values.DefaultInternationalString getInternationalStringFromElement(Element el)
          Returns the DefaultInternationalString stored in the given element.
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.
static Range getRangeFromElement(Element el, String tagName)
           
static
<T> org.faktorips.valueset.UnrestrictedValueSet<T>
getUnrestrictedValueSet(Element el, String tagName)
           
static String getValueFromElement(Element valueEl)
          Returns the string representation of the value stored in given value element.
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XML_TAG_VALUE

public static final 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 String XML_TAG_VALUE_SET
See Also:
Constant Field Values

XML_TAG_DATA

public static final String XML_TAG_DATA
See Also:
Constant Field Values

XML_TAG_CONFIG_ELEMENT

public static final String XML_TAG_CONFIG_ELEMENT
See Also:
Constant Field Values

XML_TAG_ATTRIBUTE_VALUE

public static final String XML_TAG_ATTRIBUTE_VALUE
See Also:
Constant Field Values

XML_ATTRIBUTE_ATTRIBUTE

public static final String XML_ATTRIBUTE_ATTRIBUTE
See Also:
Constant Field Values

XML_TAG_ALL_VALUES

public static final String XML_TAG_ALL_VALUES
See Also:
Constant Field Values

XML_TAG_ENUM

public static final String XML_TAG_ENUM
See Also:
Constant Field Values

XML_TAG_RANGE

public static final String XML_TAG_RANGE
See Also:
Constant Field Values

XML_TAG_STEP

public static final String XML_TAG_STEP
See Also:
Constant Field Values

XML_TAG_UPPER_BOUND

public static final String XML_TAG_UPPER_BOUND
See Also:
Constant Field Values

XML_TAG_LOWER_BOUND

public static final String XML_TAG_LOWER_BOUND
See Also:
Constant Field Values

XML_TAG_TABLE_CONTENT_NAME

public static final String XML_TAG_TABLE_CONTENT_NAME
See Also:
Constant Field Values

XML_TAG_TABLE_CONTENT_USAGE

public static final String XML_TAG_TABLE_CONTENT_USAGE
See Also:
Constant Field Values

XML_ATTRIBUTE_STRUCTURE_USAGE

public static final String XML_ATTRIBUTE_STRUCTURE_USAGE
See Also:
Constant Field Values

XML_ATTRIBUTE_IS_NULL

public static final String XML_ATTRIBUTE_IS_NULL
See Also:
Constant Field Values

XML_ATTRIBUTE_CONTAINS_NULL

public static final String XML_ATTRIBUTE_CONTAINS_NULL
See Also:
Constant Field Values
Method Detail

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)

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)

getUnrestrictedValueSet

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


Copyright © 2015. All rights reserved.