org.licas.meta

## Class MetaFactoryData

- java.lang.Object
- - org.licas.meta.MetaFactoryData

-     public class MetaFactoryData
      extends java.lang.Object

  This class can create metadata parts that can be used to define data descriptions.
  Author:
    Kieran Greer

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MetaFactoryData()` Create a new instance of MetaFactoryData

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `addToContainer(org.licas_xml.abs.Element scriptXml, org.licas_xml.abs.Element toAdd)` Add the new XML element to the admin document/script under the appropriate element type.
    `boolean` | `addToContainer(org.licas_xml.abs.Element scriptXml, org.licas_xml.abs.Element toAdd, java.lang.String resourceID)` Add the new XML element to the admin document/script under the appropriate element type.
    `org.licas_xml.abs.Element` | `createDataTypeValue(java.lang.String dataType, java.util.ArrayList<?> infoData)` Create an XML element that can be used as part of a script to define a data resource.
    `org.licas_xml.abs.Element` | `createDataTypeValue(java.lang.String dataType, org.licas_xml.abs.Element infoData)` Create an XML element that can be used as part of a script to define a data resource.
    `org.licas_xml.abs.Element` | `createDataTypeValue(java.lang.String dataType, java.lang.String infoData)` Create an XML element that can be used as part of a script to define a data resource.
    `protected org.licas_xml.abs.Element` | `createDataValue(java.lang.String dataType, java.lang.Object infoData)` Create an XML element that can be used as part of a script to define a data resource.
    `org.licas_xml.abs.Element` | `createResourceContainer(java.lang.String containerType)` Create a root Resource Container XML element that can be used as the base of a script to describe resources to load.
    `java.lang.String` | `getDataType(org.licas_xml.abs.Element dataXml)` Parse the data element type from the service info data description.
    `java.lang.String` | `innerText(org.licas_xml.abs.Element rootElem)` Parse the root element and store all text content for it and any nested elements.
    `boolean` | `setDataType(java.lang.String dataType, org.licas_xml.abs.Element dataXml)` Set the data element type from the service info data description.

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

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

- - ### Constructor Detail

    - #### MetaFactoryData

          public MetaFactoryData()

      Create a new instance of MetaFactoryData

  - ### Method Detail

    - #### createResourceContainer

          public org.licas_xml.abs.Element createResourceContainer(java.lang.String containerType)

      Create a root Resource Container XML element that can be used as the base of a script to describe resources to load. It can then be populated with other elements. This method creates an admin script with just a root element, as in `<Data><DataType>containerType</DataType><Value></Value></Data>`. You can then add resources to it, for example, by calling `addToContainer(containerXml, createDataTypeValueXml(type, urlPath)`. Construct this way, because the single resource descriptions should be placed inside of the container's `Value` element.
      Parameters:
        `containerType` - the type of container to create.
      Returns:
        an XML element that defines the service to load.

    - #### addToContainer

          public boolean addToContainer(org.licas_xml.abs.Element scriptXml,
                                        org.licas_xml.abs.Element toAdd)

      Add the new XML element to the admin document/script under the appropriate element type.
      Parameters:
        `scriptXml` - the current admin document/script. Can use `createAdminXML` to create an empty admin document, for example.
        `toAdd` - the XML element to add to the script.
      Returns:
        true if added, false otherwise.

    - #### addToContainer

          public boolean addToContainer(org.licas_xml.abs.Element scriptXml,
                                        org.licas_xml.abs.Element toAdd,
                                        java.lang.String resourceID)

      Add the new XML element to the admin document/script under the appropriate element type.
      Parameters:
        `scriptXml` - the current admin document/script. Can use `createAdminXML` to create an empty admin document, for example.
        `toAdd` - the XML element to add to the script.
        `resourceID` - if not null, then a UUID field is added to the `toAdd` description and used as the unique resource id.
      Returns:
        true if added, false otherwise.

    - #### createDataTypeValue

          public org.licas_xml.abs.Element createDataTypeValue(java.lang.String dataType,
                                                               java.lang.String infoData)
                                                        throws java.lang.Exception

      Create an XML element that can be used as part of a script to define a data resource. This would be the admin script `Data` section and it stores a description of a data type and value. The returned value is `<Data><DataType>dataType</DataType><Value>infoData</Value></Data>`
      Parameters:
        `dataType` - the data type of the value. Its class name.
        `infoData` - the data itself. If null, only the type is added.
      Returns:
        an XML element that defines the service to load.
      Throws:
        `java.lang.Exception` - any error.

    - #### createDataTypeValue

          public org.licas_xml.abs.Element createDataTypeValue(java.lang.String dataType,
                                                               org.licas_xml.abs.Element infoData)
                                                        throws java.lang.Exception

      Create an XML element that can be used as part of a script to define a data resource. This would be the admin script `Data` section and it stores a description of a data type and value. The returned value is `<Data><DataType>dataType</DataType><Value><XML infoData></Value></Data>`
      Parameters:
        `dataType` - the data type of the value. Its class name.
        `infoData` - the data itself. If null, only the type is added.
      Returns:
        an XML element that defines the service to load.
      Throws:
        `java.lang.Exception` - any error.

    - #### createDataTypeValue

          public org.licas_xml.abs.Element createDataTypeValue(java.lang.String dataType,
                                                               java.util.ArrayList<?> infoData)
                                                        throws java.lang.Exception

      Create an XML element that can be used as part of a script to define a data resource. This would be the admin script `Data` section and it stores a description of a data type and value. The returned value is `<Data><DataType>dataType</DataType><Value>infoData1</Value><Value>infoData2</Value></Data>`
      Parameters:
        `dataType` - the data type of the value. Its class name.
        `infoData` - the data itself. This list should be either XML elements or simple types that can be converted directly to Strings. If null, only the type is added.
      Returns:
        an XML element that defines the service to load.
      Throws:
        `java.lang.Exception` - any error.

    - #### createDataValue

          protected org.licas_xml.abs.Element createDataValue(java.lang.String dataType,
                                                              java.lang.Object infoData)
                                                       throws java.lang.Exception

      Create an XML element that can be used as part of a script to define a data resource. This would be the admin script `Data` section and it stores a description of a data value only. The returned value is `<Data><Value>String or XML infoData</Value></Data>`
      Parameters:
        `dataType` - the data type of the value - its class name. This might be required for serializing the data object into a string, but is not added to the script. Use `createDataValueTypeXML` for that.
        `infoData` - the data itself. This can be a String, XML element, or simple type that can be converted directly to a String.
      Returns:
        an XML element that defines the service to load.
      Throws:
        `java.lang.Exception` - any error.

    - #### getDataType

          public java.lang.String getDataType(org.licas_xml.abs.Element dataXml)
                                       throws java.lang.Exception

      Parse the data element type from the service info data description.
      Parameters:
        `dataXml` - this is the base data or dataset element with nested elements that include directly, `Const`.`DATATYPE` or `DATASETTYPE`, plus a `VALUE` elements for parsing. If they are missing, a `convertParameter` call is tried on the whole XML object.
      Returns:
        the data type value if the XML element is in the correct format, or null otherwise.
      Throws:
        `java.lang.Exception` - any error.

    - #### setDataType

          public boolean setDataType(java.lang.String dataType,
                                     org.licas_xml.abs.Element dataXml)

      Set the data element type from the service info data description.
      Parameters:
        `dataType` - the new data type to set the value to.
        `dataXml` - this is the base data or dataset element with nested elements that include directly, `Const`.`DATATYPE` or `DATASETTYPE` elements for parsing.
      Returns:
        true if the element exists and the value was set, false otherwise.

    - #### innerText

          public java.lang.String innerText(org.licas_xml.abs.Element rootElem)

      Parse the root element and store all text content for it and any nested elements.
      Parameters:
        `rootElem` - the root element to parse from.
      Returns:
        a full concatenated description of the text content.