org.licas.module

## Class DataModule

- java.lang.Object
- - java.lang.Thread
  - - org.licas.module.LicasModule
    - - org.licas.module.FrameworkModule
      - - org.licas.module.DataModule

- All Implemented Interfaces:
    java.lang.Runnable, ServiceDef

      public class DataModule
      extends FrameworkModule

  This class can manage the data for a service

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.lang.Thread

      `java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.lang.String` | `dataType` The data type
    `protected Resource` | `resource` The resource to reference the data source

    - ### Fields inherited from class org.licas.module.FrameworkModule

      `passwordHandler, service, serviceType`

    - ### Fields inherited from class org.licas.module.LicasModule

      `jarFile, syncOn, uuid`

    - ### Fields inherited from class java.lang.Thread

      `MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DataModule(Service service, PasswordHandler pHandler)` Creates a new instance of DataModule.
    `DataModule(Service service, PasswordHandler pHandler, org.licas_xml.abs.Element adminDataXml)` Creates a new instance of DataModule.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Object` | `getData()` Get the whole public data object.
    `java.lang.Object` | `getData(org.licas_xml.abs.Element infoDescr)` Get the data object part defined by the description.
    `java.lang.String` | `getDataType()` Get the data type.
    `Resource` | `getResource()` Get the data resource object.
    `void` | `initialiseData(org.licas_xml.abs.Element adminDataXml)` Create the data resource.
    `boolean` | `isEmpty()` Return true if the data module has no data references.
    `protected org.licas_xml.abs.Element` | `resetXml(org.licas_xml.abs.Element dataXml)` Reset the XML to remove the coding to a string.
    `void` | `setData(org.licas_xml.abs.Element dataXml)` This creates an appropriate `Resource` object by parsing the XMl description.
    `void` | `setData(java.lang.String dataType, java.lang.Object dataObj)` This creates a `Resource` to store the data directly.

    - ### Methods inherited from class org.licas.module.FrameworkModule

      `canAccess, canAccessTemp, getPasswordHandler, getPasswordHandler, getServerPassword, getServicePassword, getServiceType, isAdminKey, setServiceDetails, setServiceType`

    - ### Methods inherited from class org.licas.module.LicasModule

      `getJarFile, getUUID, loadObject, setJarFile, setUUID, threadAliveState`

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

      `activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield`

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

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

    - ### Methods inherited from interface org.licas.def.ServiceDef

      `getUUID, setJarFile, setUUID`

- - ### Field Detail

    - #### dataType

          protected java.lang.String dataType

      The data type

    - #### resource

          protected Resource resource

      The resource to reference the data source

  - ### Constructor Detail

    - #### DataModule

          public DataModule(Service service,
                            PasswordHandler pHandler)
                     throws java.lang.Exception

      Creates a new instance of DataModule.
      Parameters:
        `service` - the parent service.
        `pHandler` - the parent password handler.
      Throws:
        `java.lang.Exception` - any error.

    - #### DataModule

          public DataModule(Service service,
                            PasswordHandler pHandler,
                            org.licas_xml.abs.Element adminDataXml)
                     throws java.lang.Exception

      Creates a new instance of DataModule.
      Parameters:
        `service` - the parent service.
        `pHandler` - the parent password handler.
        `adminDataXml` - xml description to create the data resource from.
      Throws:
        `java.lang.Exception` - any error.

  - ### Method Detail

    - #### initialiseData

          public void initialiseData(org.licas_xml.abs.Element adminDataXml)
                              throws java.lang.Exception

      Create the data resource.
      Parameters:
        `adminDataXml` - description of the resource with data value.
      Throws:
        `java.lang.Exception` - any error.

    - #### resetXml

          protected org.licas_xml.abs.Element resetXml(org.licas_xml.abs.Element dataXml)

      Reset the XML to remove the coding to a string.
      Parameters:
        `dataXml` - the data that may be represented as a string.
      Returns:
        the data converted back into an XML element.

    - #### setData

          public void setData(java.lang.String dataType,
                              java.lang.Object dataObj)
                       throws java.lang.Exception

      This creates a `Resource` to store the data directly. This can be dangerous because it overwrites the existing resource.
      Parameters:
        `dataType` - the data type.
        `dataObj` - the data object.
      Throws:
        `java.lang.Exception` - any error.

    - #### setData

          public void setData(org.licas_xml.abs.Element dataXml)
                       throws java.lang.Exception

      This creates an appropriate `Resource` object by parsing the XMl description. This can be dangerous because it overwrites the existing resource.
      Parameters:
        `dataXml` - XML description of the data object to store.
      Throws:
        `java.lang.Exception` - any error.

    - #### isEmpty

          public boolean isEmpty()

      Return true if the data module has no data references.
      Returns:
        true if empty module.

    - #### getResource

          public Resource getResource()

      Get the data resource object.
      Returns:
        the value of resource.

    - #### getDataType

          public java.lang.String getDataType()

      Get the data type.
      Returns:
        the value of dataType.

    - #### getData

          public java.lang.Object getData()
                                   throws java.lang.Exception

      Get the whole public data object.
      Returns:
        the resource data.
      Throws:
        `java.lang.Exception` - any error.

    - #### getData

          public java.lang.Object getData(org.licas_xml.abs.Element infoDescr)
                                   throws java.lang.Exception

      Get the data object part defined by the description.
      Parameters:
        `infoDescr` - optional description. Needs to be implemented in the resource.
      Returns:
        the resource data.
      Throws:
        `java.lang.Exception` - any error.