public abstract class Resource
extends java.lang.Object
InformationService
, to store a single
resource instance. The resource could store static content or access an online link, for example.Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
dataType
The data type
|
static java.lang.String |
INFOANYTYPE
Resource types
|
static java.lang.String |
INFOBINARYTYPE |
static java.lang.String |
INFOHTMLTYPE |
static java.lang.String |
INFOSTREAMXMLTYPE |
static java.lang.String |
INFOSTRINGTYPE |
static java.lang.String |
INFOTEXTTYPE |
static java.lang.String |
INFOURLTYPE |
static java.lang.String |
INFOXMLTYPE |
static java.lang.String |
LISTCONTAINERTYPE |
static java.lang.String |
QUERYCONTAINERTYPE |
static java.lang.String |
RANDOMCONTAINERTYPE |
protected java.lang.String |
uuid
A unique id for the resource
|
Constructor and Description |
---|
Resource(java.lang.String theDataType)
Create a new instance of Resource.
|
Modifier and Type | Method and Description |
---|---|
static Resource |
createResource(java.lang.String dataType,
org.licas_xml.abs.Element dataXml)
Create an info resource object and return.
|
static java.lang.String |
dataFromResourceType(java.lang.String theResourceType)
Get the data type from the resource type.
|
protected java.lang.String |
getDataType()
Get the data type.
|
abstract org.licas_xml.abs.Element |
getInfo(org.licas_xml.abs.Element infoDescr)
Get the currently loaded source information wrapped in an XML element.
|
java.lang.String |
getUUID()
Get the ID value.
|
abstract java.lang.Object |
getValue(org.licas_xml.abs.Element infoDescr)
Get the value itself and not a wrapped description.
|
protected abstract boolean |
parseInfo(org.licas_xml.abs.Element dataXml)
Parse the data description in the admin document to create the data object.
|
protected org.licas_xml.abs.Element |
parseValueElem(org.licas_xml.abs.Element dataXml)
Try to find the value element, but only for a specific structure at the start of
the document, so find the first instance and the rest can include any element name.
|
static java.lang.String |
resourceTypeForDataType(java.lang.String dataType)
Get the most appropriate info resource type for the specified data type.
|
protected void |
setUUID(org.licas_xml.abs.Element adminXml)
Check if there is a
UUID attribute specified in the admin script root element
and set the resource ID if there is. |
void |
setUUID(java.lang.String theUuid)
Set the resource uuid.
|
public static final java.lang.String INFOANYTYPE
public static final java.lang.String INFOBINARYTYPE
public static final java.lang.String INFOTEXTTYPE
public static final java.lang.String INFOXMLTYPE
public static final java.lang.String INFOHTMLTYPE
public static final java.lang.String INFOSTREAMXMLTYPE
public static final java.lang.String INFOURLTYPE
public static final java.lang.String INFOSTRINGTYPE
public static final java.lang.String LISTCONTAINERTYPE
public static final java.lang.String RANDOMCONTAINERTYPE
public static final java.lang.String QUERYCONTAINERTYPE
protected java.lang.String uuid
protected java.lang.String dataType
public Resource(java.lang.String theDataType) throws java.lang.Exception
theDataType
- the resource data type.java.lang.Exception
- any error.protected abstract boolean parseInfo(org.licas_xml.abs.Element dataXml) throws java.lang.Exception
dataXml
- the outermost element is not checked for, but might be a DATA
or DATASET
element. This should include a VALUE
element that stores
a String or XML-based value description and possibly an Action
element.
If there is no specified action, then the data is loaded into the resource as default.
An action of AiConst
.LOADREMOTE
, for example, will retrieve the
data dynamically upon request, from the file link.java.lang.Exception
- any error.public abstract org.licas_xml.abs.Element getInfo(org.licas_xml.abs.Element infoDescr) throws java.lang.Exception
infoDescr
- a description of the info resource value that should be retrieved.java.lang.Exception
- any error.public abstract java.lang.Object getValue(org.licas_xml.abs.Element infoDescr) throws java.lang.Exception
infoDescr
- a description of the info resource value that should be retrieved,
but can be null.java.lang.Exception
- any error.protected void setUUID(org.licas_xml.abs.Element adminXml) throws java.lang.Exception
UUID
attribute specified in the admin script root element
and set the resource ID if there is. If there is not then assign a unique random one. The resourceadminXml
- the initialisation admin script.java.lang.Exception
- any error.public void setUUID(java.lang.String theUuid)
theUuid
- the uuid value.public java.lang.String getUUID()
protected java.lang.String getDataType()
protected org.licas_xml.abs.Element parseValueElem(org.licas_xml.abs.Element dataXml) throws java.lang.Exception
dataXml
- the resource admin document. Should have a Data
element
as the first element, and a Value
element at the immediate next level.null
if the structure does not exist.java.lang.Exception
- any error.public static java.lang.String dataFromResourceType(java.lang.String theResourceType)
theResourceType
- the resource type to convert.public static java.lang.String resourceTypeForDataType(java.lang.String dataType)
dataType
- the data type, for example, Integer.class.getName(),
String.class.getName(), URL.class.getName(). Basic types are covered.
An HTML source should be represented by URL.class.getName().public static Resource createResource(java.lang.String dataType, org.licas_xml.abs.Element dataXml) throws java.lang.Exception
dataType
- the data type of the value to be stored, for example, Class.getName()
.dataXml
- a description of the initialisation parameters, ideally with a
Data-Value
structure. Can be null, when no value is set.java.lang.Exception
- any error.