public class InfoStreamXml extends Resource
InformationService
to return a remote stream value parsed into xml.
The URL link to the online source is stored and the contents are returned upon request.
This should close the stream after each request. The getValue
method logs any
error but then returns null
instead of throwing an exception. An alternative
to this would be the InfoHtml
resource for more basic HTML pages.
This class tries to read the event stream as an input stream. If that fails, it tries to retrieve the whole stream first as a string, check formatting and then create the event stream. If that fails, it resets SSL to accept any certificate and repeats the process. The TrustManager is then re-loaded at the end if it has been reset.
The default is to parse the stream to format it as an rss feed. As well as the Const
.VALUE
element, it is possible to add a <Keywords><Keyword>kw1</Keyword><Keyword>kw2</Keyword>...</Keywords>
section
to the initialisation script to define a different set of element names to keep.
In that case, both the data value element and the keywords element probably need to be
both wrapped in an outer element.
dataType, INFOANYTYPE, INFOBINARYTYPE, INFOHTMLTYPE, INFOSTREAMXMLTYPE, INFOSTRINGTYPE, INFOTEXTTYPE, INFOURLTYPE, INFOXMLTYPE, LISTCONTAINERTYPE, QUERYCONTAINERTYPE, RANDOMCONTAINERTYPE, uuid
Constructor and Description |
---|
InfoStreamXml(java.lang.String theDataType,
org.licas_xml.abs.Element dataXml)
Create a new instance of InfoStreamXml.
|
Modifier and Type | Method and Description |
---|---|
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 |
getURL()
Get the url address.
|
java.lang.Object |
getValue(org.licas_xml.abs.Element infoDescr)
Get the value itself and not a wrapped description.
|
boolean |
parseInfo(org.licas_xml.abs.Element dataXml)
Parse the data description in the document to create the data object.
|
createResource, dataFromResourceType, getDataType, getUUID, parseValueElem, resourceTypeForDataType, setUUID, setUUID
public InfoStreamXml(java.lang.String theDataType, org.licas_xml.abs.Element dataXml) throws java.lang.Exception
theDataType
- the resource data type. One of the stream types. This
returns the stream as a String by default.dataXml
- a description of the initialisation parameters. Can be null.java.lang.Exception
- any error.public boolean parseInfo(org.licas_xml.abs.Element dataXml) throws java.lang.Exception
parseInfo
in class Resource
dataXml
- this must include a Const
.VALUE
element that stores
a String-based URL path description. It can also include a Keywords
element
that stores a specific list of element tag names to keep. If not present, then a
default rss set of element names are kept.java.lang.Exception
- any error.public org.licas_xml.abs.Element getInfo(org.licas_xml.abs.Element infoDescr) throws java.lang.Exception
getInfo
in class Resource
infoDescr
- a description of the info resource value that should be retrieved.Data
element through an admin document.java.lang.Exception
- any error.public java.lang.Object getValue(org.licas_xml.abs.Element infoDescr) throws java.lang.Exception
public java.lang.String getURL()
url.toExternalForm()
.