org.licas.service.resource.container

## Class QueryContainer

- java.lang.Object
- - org.licas.service.resource.Resource
  - - org.licas.service.resource.container.ResourceContainer
    - - org.licas.service.resource.container.QueryContainer

-     public class QueryContainer
      extends ResourceContainer

  This can be used to store an array or set of `Resource` derived objects and return the details of any of them that match a query specification. To do this, the container uses a QueryDef derived query engine to evaluate the query expression, of type `QueryMediator`.

  It uses the definition's `executeQueryModel` method on the contents of each resource. The query itself is sent as an XML-script that is a parsed version of the `licas_text` package `QueryModel`. You can use the related `QueryParser` to parse to or from XML.

  Alternatively, you can write your own query engine, that implements `QueryDef`, pass the class name as part of the constructor script `Value` element and it will be created instead. If you then add your own parser for a new query model, or still use the existing one, you can perform your own evaluations.

  Author:
    Kieran Greer

- - ### Field Summary

    - ### Fields inherited from class org.licas.service.resource.container.ResourceContainer

      `resourceList`

    - ### Fields inherited from class org.licas.service.resource.Resource

      `dataType, INFOANYTYPE, INFOBINARYTYPE, INFOHTMLTYPE, INFOSTREAMXMLTYPE, INFOSTRINGTYPE, INFOTEXTTYPE, INFOURLTYPE, INFOXMLTYPE, LISTCONTAINERTYPE, QUERYCONTAINERTYPE, RANDOMCONTAINERTYPE, uuid`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `QueryContainer(java.lang.String theDataType)` Create a new instance of QueryContainer.
    `QueryContainer(java.lang.String theDataType, org.licas_xml.abs.Element dataXml)` Create a new instance of QueryContainer.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `org.licas_xml.abs.Element` | `getInfo(org.licas_xml.abs.Element infoDescr)` Get the source information wrapped in an XML element.
    `java.lang.Object` | `getValue(org.licas_xml.abs.Element infoDescr)` Get the currently selected value itself and not a wrapped description.
    `protected boolean` | `parseInfo(org.licas_xml.abs.Element dataXml)` Parse the data description in the admin document to create the data object.

    - ### Methods inherited from class org.licas.service.resource.container.ResourceContainer

      `addResource, createContainer, getResource, getResourceIDs, removeResource`

    - ### Methods inherited from class org.licas.service.resource.Resource

      `createResource, dataFromResourceType, getDataType, getUUID, parseValueElem, resourceTypeForDataType, setUUID, setUUID`

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

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

- - ### Constructor Detail

    - #### QueryContainer

          public QueryContainer(java.lang.String theDataType)
                         throws java.lang.Exception

      Create a new instance of QueryContainer.
      Parameters:
        `theDataType` - the container type.
      Throws:
        `java.lang.Exception` - any error.

    - #### QueryContainer

          public QueryContainer(java.lang.String theDataType,
                                org.licas_xml.abs.Element dataXml)
                         throws java.lang.Exception

      Create a new instance of QueryContainer.
      Parameters:
        `theDataType` - the container type.
        `dataXml` - a description of the initialisation parameters.
      Throws:
        `java.lang.Exception` - any error.

  - ### Method Detail

    - #### parseInfo

          protected boolean parseInfo(org.licas_xml.abs.Element dataXml)
                               throws java.lang.Exception

      Parse the data description in the admin document to create the data object.
      Overrides:
        `parseInfo` in class `ResourceContainer`
      Parameters:
        `dataXml` - the `Data` element of the admin document. This should include the container `DataType` element and a `Value` element that stores a list of child `Data` elements that store information for each resource to create. The `Value` element can also optionally store a different query engine type. This would be the class name and is assumed to be from a local jar file. It would be stored in another `Value` element that could be created using `MetaFactory.addXML(adminData, (MetaFactory.createMetaValueXML(Const.VALUE, query-engine-class), Const.VALUE)`, for example.
      Returns:
        true if any specified resources are successfully added, false otherwise.
      Throws:
        `java.lang.Exception` - any error.

    - #### getInfo

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

      Get the source information wrapped in an XML element.
      Specified by:
        `getInfo` in class `Resource`
      Parameters:
        `infoDescr` - a description of the query to execute on each resource. The `QueryModel` is used as default.
      Returns:
        the query reply value.
      Throws:
        `java.lang.Exception` - any error.

    - #### getValue

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

      Get the currently selected value itself and not a wrapped description. For a query container, this is in fact the same operation as `getInfo` and returns the same query reply `Element`.
      Specified by:
        `getValue` in class `Resource`
      Parameters:
        `infoDescr` - a description of the query to execute on the resources. The `QueryModel` is used as default.
      Returns:
        the query reply value.
      Throws:
        `java.lang.Exception` - any error.