com.tibbo.aggregate.common.datatable.encoding

## Class XMLEncodingHelper

- java.lang.Object
- - com.tibbo.aggregate.common.datatable.encoding.XMLEncodingHelper

-     public class XMLEncodingHelper
      extends java.lang.Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `ATTRIBUTE_ADVANCED`
    `static java.lang.String` | `ATTRIBUTE_DESCRIPTION`
    `static java.lang.String` | `ATTRIBUTE_EDITOR`
    `static java.lang.String` | `ATTRIBUTE_EDITOR_OPTIONS`
    `static java.lang.String` | `ATTRIBUTE_EXTENDABLE_SELECTION_VALUES`
    `static java.lang.String` | `ATTRIBUTE_HIDDEN`
    `static java.lang.String` | `ATTRIBUTE_ICON`
    `static java.lang.String` | `ATTRIBUTE_ID`
    `static java.lang.String` | `ATTRIBUTE_INLINE`
    `static java.lang.String` | `ATTRIBUTE_KEY_FIELD`
    `static java.lang.String` | `ATTRIBUTE_MAXIMUM_RECORDS`
    `static java.lang.String` | `ATTRIBUTE_MINIMUM_RECORDS`
    `static java.lang.String` | `ATTRIBUTE_NAME`
    `static java.lang.String` | `ATTRIBUTE_NOT_REPLICATED`
    `static java.lang.String` | `ATTRIBUTE_NULLABLE`
    `static java.lang.String` | `ATTRIBUTE_OPTIONAL`
    `static java.lang.String` | `ATTRIBUTE_READONLY`
    `static java.lang.String` | `ATTRIBUTE_REORDERABLE`
    `static java.lang.String` | `ATTRIBUTE_TYPE`
    `static java.lang.String` | `ATTRIBUTE_UNRESIZABLE`
    `static java.lang.String` | `CONTENT_TYPE`
    `static java.lang.String` | `CONTENT_TYPE_BASE64`
    `static java.lang.String` | `ELEMENT_BINDING`
    `static java.lang.String` | `ELEMENT_BINDINGS`
    `static java.lang.String` | `ELEMENT_DATA`
    `static java.lang.String` | `ELEMENT_DATA_TABLE`
    `static java.lang.String` | `ELEMENT_DEFAULT_VALUE`
    `static java.lang.String` | `ELEMENT_EDITOR_OPTIONS`
    `static java.lang.String` | `ELEMENT_EXPRESSION`
    `static java.lang.String` | `ELEMENT_FIELD`
    `static java.lang.String` | `ELEMENT_FIELD_VALUE`
    `static java.lang.String` | `ELEMENT_FIELDS`
    `static java.lang.String` | `ELEMENT_FORMAT`
    `static java.lang.String` | `ELEMENT_GROUP`
    `static java.lang.String` | `ELEMENT_HELP`
    `static java.lang.String` | `ELEMENT_NULL_VALUE`
    `static java.lang.String` | `ELEMENT_OPTION`
    `static java.lang.String` | `ELEMENT_PREVIEW`
    `static java.lang.String` | `ELEMENT_RECORD`
    `static java.lang.String` | `ELEMENT_RECORDS`
    `static java.lang.String` | `ELEMENT_REFERENCE`
    `static java.lang.String` | `ELEMENT_SELECTION_VALUES`
    `static java.lang.String` | `ELEMENT_VALIDATORS`
    `static java.util.regex.Pattern` | `RESOURCE_PATTERN`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XMLEncodingHelper()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static org.w3c.dom.Node` | `createDataTableNode(DataTable dt, org.w3c.dom.Document doc, CallerController cc, ContextManager cm, XMLEncodingSettings settings)` Creates a DOM node for provided Data Table
    `static org.w3c.dom.Document` | `createNewDocument()` Returns new `Document` object.
    `static DataTable` | `decodeFromDocument(org.w3c.dom.Document doc, TableFormat givenFormat)`
    `static DataTable` | `decodeFromXML(java.io.InputStream from, TableFormat givenFormat)`
    `static DataTable` | `decodeFromXML(java.lang.String from, java.lang.String encoding, TableFormat givenFormat)`
    `static org.w3c.dom.Document` | `encodeToDocument(DataTable dt, CallerController cc, ContextManager cm, XMLEncodingSettings settings)`
    `static void` | `encodeToXML(DataTable dt, CallerController cc, ContextManager cm, XMLEncodingSettings settings, java.io.Writer writer)`
    `static java.lang.Object` | `evaluateXPathExpression(org.w3c.dom.Document doc, java.lang.String expression, javax.xml.namespace.QName resultType)` Compiles XPath query and evaluates it on provided Document object.
    `static java.lang.String` | `getElementContentWithUnsafetyText(org.w3c.dom.Node el, java.util.ResourceBundle bundle, boolean transferEncode)` Common way to read text content of XML Element.
    `static java.lang.String` | `parseBundles(java.lang.String value, java.util.ResourceBundle bundle, boolean transferEncode)`
    `static DataTable` | `readDataTableFromNode(org.w3c.dom.Node dtNode, XMLEncodingSettings settings)` Reading DataTable from DOM node object.
    `static void` | `setElementContentWithUnsafetyText(org.w3c.dom.Element el, java.lang.String content)` Common way to save any XML Element Text Content.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### CONTENT_TYPE

          public static final java.lang.String CONTENT_TYPE

      See Also:
        Constant Field Values

    - #### CONTENT_TYPE_BASE64

          public static final java.lang.String CONTENT_TYPE_BASE64

      See Also:
        Constant Field Values

    - #### ELEMENT_DATA_TABLE

          public static final java.lang.String ELEMENT_DATA_TABLE

      See Also:
        Constant Field Values

    - #### ELEMENT_FORMAT

          public static final java.lang.String ELEMENT_FORMAT

      See Also:
        Constant Field Values

    - #### ELEMENT_FIELDS

          public static final java.lang.String ELEMENT_FIELDS

      See Also:
        Constant Field Values

    - #### ELEMENT_BINDING

          public static final java.lang.String ELEMENT_BINDING

      See Also:
        Constant Field Values

    - #### ELEMENT_BINDINGS

          public static final java.lang.String ELEMENT_BINDINGS

      See Also:
        Constant Field Values

    - #### ELEMENT_REFERENCE

          public static final java.lang.String ELEMENT_REFERENCE

      See Also:
        Constant Field Values

    - #### ELEMENT_EXPRESSION

          public static final java.lang.String ELEMENT_EXPRESSION

      See Also:
        Constant Field Values

    - #### ELEMENT_FIELD

          public static final java.lang.String ELEMENT_FIELD

      See Also:
        Constant Field Values

    - #### ELEMENT_SELECTION_VALUES

          public static final java.lang.String ELEMENT_SELECTION_VALUES

      See Also:
        Constant Field Values

    - #### ELEMENT_HELP

          public static final java.lang.String ELEMENT_HELP

      See Also:
        Constant Field Values

    - #### ELEMENT_GROUP

          public static final java.lang.String ELEMENT_GROUP

      See Also:
        Constant Field Values

    - #### ELEMENT_OPTION

          public static final java.lang.String ELEMENT_OPTION

      See Also:
        Constant Field Values

    - #### ELEMENT_RECORDS

          public static final java.lang.String ELEMENT_RECORDS

      See Also:
        Constant Field Values

    - #### ELEMENT_RECORD

          public static final java.lang.String ELEMENT_RECORD

      See Also:
        Constant Field Values

    - #### ELEMENT_DEFAULT_VALUE

          public static final java.lang.String ELEMENT_DEFAULT_VALUE

      See Also:
        Constant Field Values

    - #### ELEMENT_DATA

          public static final java.lang.String ELEMENT_DATA

      See Also:
        Constant Field Values

    - #### ELEMENT_NULL_VALUE

          public static final java.lang.String ELEMENT_NULL_VALUE

      See Also:
        Constant Field Values

    - #### ELEMENT_PREVIEW

          public static final java.lang.String ELEMENT_PREVIEW

      See Also:
        Constant Field Values

    - #### ELEMENT_FIELD_VALUE

          public static final java.lang.String ELEMENT_FIELD_VALUE

      See Also:
        Constant Field Values

    - #### ATTRIBUTE_ID

          public static final java.lang.String ATTRIBUTE_ID

      See Also:
        Constant Field Values

    - #### ATTRIBUTE_MINIMUM_RECORDS

          public static final java.lang.String ATTRIBUTE_MINIMUM_RECORDS

      See Also:
        Constant Field Values

    - #### ATTRIBUTE_MAXIMUM_RECORDS

          public static final java.lang.String ATTRIBUTE_MAXIMUM_RECORDS

      See Also:
        Constant Field Values

    - #### ATTRIBUTE_REORDERABLE

          public static final java.lang.String ATTRIBUTE_REORDERABLE

      See Also:
        Constant Field Values

    - #### ATTRIBUTE_UNRESIZABLE

          public static final java.lang.String ATTRIBUTE_UNRESIZABLE

      See Also:
        Constant Field Values

    - #### ATTRIBUTE_NAME

          public static final java.lang.String ATTRIBUTE_NAME

      See Also:
        Constant Field Values

    - #### ATTRIBUTE_TYPE

          public static final java.lang.String ATTRIBUTE_TYPE

      See Also:
        Constant Field Values

    - #### ATTRIBUTE_DESCRIPTION

          public static final java.lang.String ATTRIBUTE_DESCRIPTION

      See Also:
        Constant Field Values

    - #### ATTRIBUTE_NULLABLE

          public static final java.lang.String ATTRIBUTE_NULLABLE

      See Also:
        Constant Field Values

    - #### ATTRIBUTE_OPTIONAL

          public static final java.lang.String ATTRIBUTE_OPTIONAL

      See Also:
        Constant Field Values

    - #### ATTRIBUTE_ICON

          public static final java.lang.String ATTRIBUTE_ICON

      See Also:
        Constant Field Values

    - #### ATTRIBUTE_EXTENDABLE_SELECTION_VALUES

          public static final java.lang.String ATTRIBUTE_EXTENDABLE_SELECTION_VALUES

      See Also:
        Constant Field Values

    - #### ATTRIBUTE_READONLY

          public static final java.lang.String ATTRIBUTE_READONLY

      See Also:
        Constant Field Values

    - #### ATTRIBUTE_NOT_REPLICATED

          public static final java.lang.String ATTRIBUTE_NOT_REPLICATED

      See Also:
        Constant Field Values

    - #### ATTRIBUTE_HIDDEN

          public static final java.lang.String ATTRIBUTE_HIDDEN

      See Also:
        Constant Field Values

    - #### ATTRIBUTE_INLINE

          public static final java.lang.String ATTRIBUTE_INLINE

      See Also:
        Constant Field Values

    - #### ATTRIBUTE_ADVANCED

          public static final java.lang.String ATTRIBUTE_ADVANCED

      See Also:
        Constant Field Values

    - #### ATTRIBUTE_KEY_FIELD

          public static final java.lang.String ATTRIBUTE_KEY_FIELD

      See Also:
        Constant Field Values

    - #### ATTRIBUTE_EDITOR

          public static final java.lang.String ATTRIBUTE_EDITOR

      See Also:
        Constant Field Values

    - #### ELEMENT_EDITOR_OPTIONS

          public static final java.lang.String ELEMENT_EDITOR_OPTIONS

      See Also:
        Constant Field Values

    - #### ELEMENT_VALIDATORS

          public static final java.lang.String ELEMENT_VALIDATORS

      See Also:
        Constant Field Values

    - #### RESOURCE_PATTERN

          public static final java.util.regex.Pattern RESOURCE_PATTERN

    - #### ATTRIBUTE_EDITOR_OPTIONS

          public static final java.lang.String ATTRIBUTE_EDITOR_OPTIONS

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### XMLEncodingHelper

          public XMLEncodingHelper()

  - ### Method Detail

    - #### encodeToXML

          public static void encodeToXML(DataTable dt,
                                         CallerController cc,
                                         ContextManager cm,
                                         XMLEncodingSettings settings,
                                         java.io.Writer writer)
                                  throws javax.xml.parsers.ParserConfigurationException,
                                         java.io.IOException,
                                         ContextException,
                                         org.w3c.dom.DOMException

      Throws:
        `javax.xml.parsers.ParserConfigurationException`
        `java.io.IOException`
        `ContextException`
        `org.w3c.dom.DOMException`

    - #### encodeToDocument

          public static org.w3c.dom.Document encodeToDocument(DataTable dt,
                                                              CallerController cc,
                                                              ContextManager cm,
                                                              XMLEncodingSettings settings)
                                                       throws javax.xml.parsers.ParserConfigurationException,
                                                              java.io.IOException,
                                                              ContextException

      Throws:
        `javax.xml.parsers.ParserConfigurationException`
        `java.io.IOException`
        `ContextException`

    - #### decodeFromXML

          public static DataTable decodeFromXML(java.lang.String from,
                                                java.lang.String encoding,
                                                TableFormat givenFormat)
                                         throws java.lang.IllegalArgumentException,
                                                java.io.IOException,
                                                org.xml.sax.SAXException,
                                                javax.xml.parsers.ParserConfigurationException

      Throws:
        `java.lang.IllegalArgumentException`
        `java.io.IOException`
        `org.xml.sax.SAXException`
        `javax.xml.parsers.ParserConfigurationException`

    - #### decodeFromXML

          public static DataTable decodeFromXML(java.io.InputStream from,
                                                TableFormat givenFormat)
                                         throws java.lang.IllegalArgumentException,
                                                java.io.IOException,
                                                org.xml.sax.SAXException,
                                                javax.xml.parsers.ParserConfigurationException

      Throws:
        `java.lang.IllegalArgumentException`
        `java.io.IOException`
        `org.xml.sax.SAXException`
        `javax.xml.parsers.ParserConfigurationException`

    - #### decodeFromDocument

          public static DataTable decodeFromDocument(org.w3c.dom.Document doc,
                                                     TableFormat givenFormat)
                                              throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### setElementContentWithUnsafetyText

          public static void setElementContentWithUnsafetyText(org.w3c.dom.Element el,
                                                               java.lang.String content)

      Common way to save any XML Element Text Content. Desired Element text content can contain non Valid XML chars. In this case text content is encoded with base64 and element receive corresponding attribute value.
      Parameters:
        `el` - Element
        `content` - String

    - #### getElementContentWithUnsafetyText

          public static java.lang.String getElementContentWithUnsafetyText(org.w3c.dom.Node el,
                                                                           java.util.ResourceBundle bundle,
                                                                           boolean transferEncode)

      Common way to read text content of XML Element. If it has attribute 'contentType' with value 'base64' then text content is being decoded from base64 encoding.
      Parameters:
        `el` - Node
      Returns:
        String
      See Also:
        `setElementContentWithUnsafetyText(org.w3c.dom.Element, byte[])`

    - #### parseBundles

          public static java.lang.String parseBundles(java.lang.String value,
                                                      java.util.ResourceBundle bundle,
                                                      boolean transferEncode)

    - #### createDataTableNode

          public static org.w3c.dom.Node createDataTableNode(DataTable dt,
                                                             org.w3c.dom.Document doc,
                                                             CallerController cc,
                                                             ContextManager cm,
                                                             XMLEncodingSettings settings)
                                                      throws javax.xml.parsers.ParserConfigurationException,
                                                             java.io.IOException,
                                                             ContextException

      Creates a DOM node for provided Data Table
      Throws:
        `javax.xml.parsers.ParserConfigurationException`
        `java.io.IOException`
        `ContextException`

    - #### readDataTableFromNode

          public static DataTable readDataTableFromNode(org.w3c.dom.Node dtNode,
                                                        XMLEncodingSettings settings)
                                                 throws java.io.IOException

      Reading DataTable from DOM node object. If DOM node contains no 'format' section then resulting TableFormat should be set to `givenFormat` if it is not null. Otherwise exception will be thrown.
      Parameters:
        `dtNode` - Node
        `settings` - XMLEncodingSettings
      Returns:
        DataTable
      Throws:
        `java.io.IOException`

    - #### createNewDocument

          public static org.w3c.dom.Document createNewDocument()
                                                        throws javax.xml.parsers.ParserConfigurationException

      Returns new `Document` object. Created to simplify new DOM `Document` object creation process.
      Returns:
        Document
      Throws:
        `javax.xml.parsers.ParserConfigurationException`

    - #### evaluateXPathExpression

          public static java.lang.Object evaluateXPathExpression(org.w3c.dom.Document doc,
                                                                 java.lang.String expression,
                                                                 javax.xml.namespace.QName resultType)
                                                          throws javax.xml.xpath.XPathExpressionException

      Compiles XPath query and evaluates it on provided Document object. Returns result of this query.
      Parameters:
        `doc` -
        `expression` -
        `resultType` -
      Throws:
        `javax.xml.xpath.XPathExpressionException`