org.licas.meta

## Class MetaFactoryService

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

-     public class MetaFactoryService
      extends java.lang.Object

  This class can create metadata parts that can be used to define the service metadata as it is stored and defined on the server.
  Author:
    Kieran Greer

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MetaFactoryService()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `addUUIDAttribute(org.licas_xml.abs.Element xmlElem, java.lang.String uuidValue)` Add an `Const.UUID` attribute to the base XML element.
    `java.lang.String` | `asFaultComm(java.lang.String commID)` Convert the comm ID into a fault comm ID.
    `java.lang.String` | `asServiceComm(java.lang.String commID)` Convert the comm ID into a service comm ID.
    `org.licas_xml.abs.Element` | `createAddInstanceValue(org.licas_xml.abs.Element valuesXml, java.lang.String varName, java.lang.Class varType)` Add a new instance value to the instance values section.
    `org.licas_xml.abs.Element` | `createAddInstanceValue(org.licas_xml.abs.Element valuesXml, java.lang.String varName, java.lang.Object varInstance)` Add a new instance value to the instance values section.
    `static org.licas_xml.abs.Element` | `createAdmin(AdminInfo adminInfo)` Create an Admin script that can be used to initialise a service with.
    `org.licas_xml.abs.Element` | `createLoadService(java.lang.String serviceUuid, java.lang.String serviceType, java.lang.String serviceClass, java.util.ArrayList<java.lang.String> jarFiles, java.util.ArrayList<java.lang.Object> params)` Create an XML element that can be used as part of a script to define a service to dynamically create and load into another one.
    `org.licas_xml.abs.Element` | `createSerialize(java.util.ArrayList<java.lang.String> varNames, boolean includeAdmin, java.util.ArrayList<java.lang.String> toRemove)` Create a list of variable names to be serialized as the service object.
    `org.licas_xml.abs.Element` | `createSerialize(java.util.ArrayList varNames, boolean includeAdmin)` Create a list of variable names to be serialized as the service object.
    `boolean` | `isFaultComm(java.lang.String commID)` Return true if the comm ID is coded as a fault comm ID.
    `boolean` | `isServiceComm(java.lang.String commID)` Return true if the comm ID is coded as a service comm ID.
    `org.licas_xml.abs.Element` | `serverMeta(org.licas_xml.abs.Element serverXml, java.lang.String metaType)` Get the element representing the meta type for an XML description of a server.

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

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

- - ### Constructor Detail

    - #### MetaFactoryService

          public MetaFactoryService()

  - ### Method Detail

    - #### createAdmin

          public static org.licas_xml.abs.Element createAdmin(AdminInfo adminInfo)
                                                       throws java.lang.Exception

      Create an Admin script that can be used to initialise a service with. This method creates an admin script, as in `<Admin></Admin>` and populates it with the field values of the `AdminInfo` object.
      Parameters:
        `adminInfo` - an admin document with values to initialise a service with.
      Returns:
        an XML element that defines the service to load.
      Throws:
        `java.lang.Exception` - any error.

    - #### addUUIDAttribute

          public static void addUUIDAttribute(org.licas_xml.abs.Element xmlElem,
                                              java.lang.String uuidValue)

      Add an `Const.UUID` attribute to the base XML element. This will overwrite any existing attribute.
      Parameters:
        `xmlElem` - the element to add the attribute to.
        `uuidValue` - the value of the uuid.

    - #### createLoadService

          public org.licas_xml.abs.Element createLoadService(java.lang.String serviceUuid,
                                                             java.lang.String serviceType,
                                                             java.lang.String serviceClass,
                                                             java.util.ArrayList<java.lang.String> jarFiles,
                                                             java.util.ArrayList<java.lang.Object> params)

      Create an XML element that can be used as part of a script to define a service to dynamically create and load into another one. This is for a single service instance only and should be added to another script XML section - `Const`.`SERVICESTOLOAD`, for example - see the admin user guide.
      Parameters:
        `serviceUuid` - the service uuid.
        `serviceType` - the service type.
        `serviceClass` - the service classname.
        `jarFiles` - a list of required jar files.
        `params` - list of constructor parameters for the service. Can be of a simple type, like String, Integer or an XML Element and the service must know what they represent. `<serviceType Name="serviceUUID"><Class_Name>serviceClass</Class_Name> <Jar_Files><Jar_File>Jar file path</Jar_File></Jar_Files> <Ps><Param>String or XML param</Param></Ps></serviceType>`
      Returns:
        an XML element that defines the service to load.

    - #### createAddInstanceValue

          public org.licas_xml.abs.Element createAddInstanceValue(org.licas_xml.abs.Element valuesXml,
                                                                  java.lang.String varName,
                                                                  java.lang.Object varInstance)
                                                           throws java.lang.Exception

      Add a new instance value to the instance values section. Create the section first if it is missing.
      Parameters:
        `valuesXml` - the instance values section. If null it is created first.
        `varName` - the name of the variable, as written in the class.
        `varInstance` - the actual instance to serializeToString. This will also check if the parser is present for a complex object. `<Instance_Values><Instance_Value Name="variableName"><Object_Type Ct="class_type"> <Object_Variable>Serialized code</Object_Variable></Object_Type></Instance_Value> </Instance_Values>`
      Returns:
        an XML element that defines the service to load.
      Throws:
        `java.lang.Exception` - any error.

    - #### createAddInstanceValue

          public org.licas_xml.abs.Element createAddInstanceValue(org.licas_xml.abs.Element valuesXml,
                                                                  java.lang.String varName,
                                                                  java.lang.Class varType)

      Add a new instance value to the instance values section. Create the section first if it is missing.
      Parameters:
        `valuesXml` - the instance values section. If null it is created first.
        `varName` - the name of the variable, as written in the class.
        `varType` - only add the variable type and leave the value missing. This is then used for later serializations, when the value gets added. `<Instance_Values><Instance_Value Name="variableName"><Object_Type Ct="class_type"> </Object_Type></Instance_Value></Instance_Values>`
      Returns:
        an XML element that defines the service to load.

    - #### createSerialize

          public org.licas_xml.abs.Element createSerialize(java.util.ArrayList varNames,
                                                           boolean includeAdmin)

      Create a list of variable names to be serialized as the service object.
      Parameters:
        `varNames` - the list of variables to serialize.
        `includeAdmin` - if true add a `MetaConst`.`ADMIN` value to indicate to include the admin document information. If true, some admin fields are automatically removed, for safety reasons.
      Returns:
        an XML element that defines the serialized variable list.

    - #### createSerialize

          public org.licas_xml.abs.Element createSerialize(java.util.ArrayList<java.lang.String> varNames,
                                                           boolean includeAdmin,
                                                           java.util.ArrayList<java.lang.String> toRemove)

      Create a list of variable names to be serialized as the service object.
      Parameters:
        `varNames` - the list of variables to serialize.
        `includeAdmin` - if true add a `MetaConst`.`ADMIN` value to indicate to include the admin document information.
        `toRemove` - if any admin section is indicated here through the XML tag name, it is removed first. If included, `includeAdmin` must also be true.
      Returns:
        an XML element that defines the serialized variable list.

    - #### serverMeta

          public org.licas_xml.abs.Element serverMeta(org.licas_xml.abs.Element serverXml,
                                                      java.lang.String metaType)

      Get the element representing the meta type for an XML description of a server.
      Parameters:
        `serverXml` - a description of the server, probably a `Const`.`SERVER` element.
        `metaType` - the type of meta to find. Can the the server path `Const`.`HANDLE` or the server password `Const`.`META`.
      Returns:
        the element if it is present, or null otherwise.

    - #### isServiceComm

          public boolean isServiceComm(java.lang.String commID)

      Return true if the comm ID is coded as a service comm ID.
      Parameters:
        `commID` - the communication id.
      Returns:
        true if ends with the service code.

    - #### isFaultComm

          public boolean isFaultComm(java.lang.String commID)

      Return true if the comm ID is coded as a fault comm ID.
      Parameters:
        `commID` - the communication id.
      Returns:
        true if ends with the fault code.

    - #### asServiceComm

          public java.lang.String asServiceComm(java.lang.String commID)

      Convert the comm ID into a service comm ID.
      Parameters:
        `commID` - the communication id to convert.
      Returns:
        the comm ID with the service code at the end.

    - #### asFaultComm

          public java.lang.String asFaultComm(java.lang.String commID)

      Convert the comm ID into a fault comm ID.
      Parameters:
        `commID` - the communication id to convert.
      Returns:
        the comm ID with the fault code at the end.