Package org.vast.sensorML
Class SMLUtils
java.lang.Object
org.vast.xml.XMLBindingsUtils
org.vast.sensorML.SMLUtils
Helper class providing a version agnostic access to SensorML object readers and writers as well as other utility methods. This class delegates to version specific code whenever required.
- Since:
- Apr 10, 2007
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class org.vast.xml.XMLBindingsUtils
encoding, staxBindings -
Constructor Summary
ConstructorsConstructorDescriptionCreates this helper for the specified SensorML versionSMLUtils(SMLStaxBindings staxBindings) -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyConfig(AbstractProcess process, boolean removeConfig) Apply config to the specified process and optionally remove config when we're doneprotected voidapplyConfig(AbstractProcess process, Settings settings) Applies a configuration on a base process.
Note that the process must contain all properties that the configuration refers to.protected DataComponentfindTargetComponent(AbstractProcess process, String refPath) getConfiguredInstance(AbstractProcess process) Generates a configured instance by copying I/Os definition from base description referenced by the typeOf property, and applying configuration settings.getExecutableInstance(AbstractProcessImpl process, boolean useThreads) Generate a new process description configured for runtime executiongetVersion(DOMHelper dom, Element smlElt) Logic to guess SensorML version from namespacestatic voidvoidmakeProcessExecutable(AbstractProcessImpl smlProcess, boolean useThreads) Makes a process executable by instantiating and wrapping an implementation of IProcessExec.
The actual implementation is found using the method or typeOf URI.protected voidmergeMetadataList(OgcPropertyList baseList, OgcPropertyList instanceList) protected ObjectreadFromXmlStream(XMLStreamReader reader, Enum<?> eltType) Reads a SensorML process from an InputStream The root element must be of one of the types derived from AbstractProcessreadProcess(URL url) Reads a SensorML process from a URL The root element must be of one of the types derived from AbstractProcessreadProcess(DOMHelper dom, Element processElt) Reads a SensorML process from a DOM elementvoidresolveLinkedProcesses(AggregateProcess processChain) Resolves all child processes included in a process chain by referenceprotected voidresolveLinkedProcesses(AggregateProcess processChain, boolean recursive) voidsetProcessFactory(IProcessFactory processFactory) static voidvalidateConnections(AggregateProcess processChain) Validate connections between child processes of the given process chainstatic AbstractProcessImplwrapWithProcessDescription(IProcessExec processExec) Create SML process description from process executable implementationvoidwriteProcess(OutputStream os, AbstractProcess process, boolean indent) Serializes a SensorML process to an OutputStreamwriteProcess(DOMHelper dom, AbstractProcess process) Serializes a SensorML process to a DOM elementprotected voidwriteToXmlStream(XMLStreamWriter writer, Object sweObj, Enum<?> eltType) Methods inherited from class org.vast.xml.XMLBindingsUtils
addOnlyUsedNamespaceMappingsToDOM, readFromDom, readFromStream, readFromStream, setEncoding, writeToDom, writeToStream
-
Field Details
-
IC
-
SENSORML
-
V1_0
- See Also:
-
V2_0
- See Also:
-
V2_1
- See Also:
-
-
Constructor Details
-
SMLUtils
Creates this helper for the specified SensorML version- Parameters:
version-
-
SMLUtils
-
-
Method Details
-
loadRegistry
public static void loadRegistry() -
readProcess
Reads a SensorML process from a DOM element- Parameters:
dom- DOM helper wrapping the XML document to read fromprocessElt- DOM element to read from. Must be of one of the types derived from AbstractProcess- Returns:
- the process instance
- Throws:
XMLReaderException- if an error occurs while reading the XML
-
readProcess
Reads a SensorML process from an InputStream The root element must be of one of the types derived from AbstractProcess- Parameters:
is- Input stream to read from- Returns:
- the process instance
- Throws:
XMLReaderException- if an error occurs while reading the XML
-
readProcess
Reads a SensorML process from a URL The root element must be of one of the types derived from AbstractProcess- Parameters:
url- URL to fetch data from- Returns:
- the process instance
- Throws:
XMLReaderException- if an error occurs while fetching data or reading the XML
-
writeProcess
Serializes a SensorML process to a DOM element- Parameters:
dom- DOM helper wrapping the XMl document to write toprocess- Process object to serialize- Returns:
- DOM element containing the process description (not attached to any parent)
- Throws:
XMLWriterException- if an error occurs while generating the DOM tree
-
writeProcess
public void writeProcess(OutputStream os, AbstractProcess process, boolean indent) throws XMLWriterException Serializes a SensorML process to an OutputStream- Parameters:
os- Output stream to write toprocess- Process object to serializeindent- Set to true to indent the output- Throws:
XMLWriterException- if an error occurs while generating the XML contentIOException- if an error occurs while writing to output the stream
-
getVersion
Logic to guess SensorML version from namespace- Parameters:
dom-smlElt- DOM element containing the SensorML content- Returns:
- version string
-
readFromXmlStream
protected Object readFromXmlStream(XMLStreamReader reader, Enum<?> eltType) throws XMLStreamException - Specified by:
readFromXmlStreamin classXMLBindingsUtils- Throws:
XMLStreamException
-
writeToXmlStream
protected void writeToXmlStream(XMLStreamWriter writer, Object sweObj, Enum<?> eltType) throws XMLStreamException - Specified by:
writeToXmlStreamin classXMLBindingsUtils- Throws:
XMLStreamException
-
setProcessFactory
-
wrapWithProcessDescription
Create SML process description from process executable implementation- Parameters:
processExec-- Returns:
- The process description object
-
validateConnections
Validate connections between child processes of the given process chain- Parameters:
processChain-- Throws:
SMLException
-
getExecutableInstance
public AbstractProcessImpl getExecutableInstance(AbstractProcessImpl process, boolean useThreads) throws SMLException Generate a new process description configured for runtime execution- Parameters:
process- static, unconfigured process description (i.e. not executable)useThreads- true to use separate threads for child processes (only applicable to aggregate processes)- Returns:
- the new executable process instance
- Throws:
SMLException- if executable instance cannot be created (e.g. exec implementation not found)
-
makeProcessExecutable
public void makeProcessExecutable(AbstractProcessImpl smlProcess, boolean useThreads) throws SMLException Makes a process executable by instantiating and wrapping an implementation of IProcessExec.
The actual implementation is found using the method or typeOf URI.- Parameters:
smlProcess- process description to prepare for runtime executionuseThreads- if true, run children processes in separate threads- Throws:
SMLException- if process cannot be made executable
-
getConfiguredInstance
Generates a configured instance by copying I/Os definition from base description referenced by the typeOf property, and applying configuration settings.- Parameters:
process- process with typeOf and configuration settings- Returns:
- new process instance with configuration values set
- Throws:
SMLException- if configuration is invalid or cannot be applied
-
mergeMetadataList
-
applyConfig
Apply config to the specified process and optionally remove config when we're done- Parameters:
process-removeConfig- if true, the configuration settings will be removed from the process description- Throws:
SMLException
-
applyConfig
Applies a configuration on a base process.
Note that the process must contain all properties that the configuration refers to.- Parameters:
process-settings-- Throws:
SMLException
-
findTargetComponent
protected DataComponent findTargetComponent(AbstractProcess process, String refPath) throws SMLException - Throws:
SMLException
-
resolveLinkedProcesses
Resolves all child processes included in a process chain by reference- Parameters:
processChain-- Throws:
SMLException- if one of the process cannot be resolved
-
resolveLinkedProcesses
protected void resolveLinkedProcesses(AggregateProcess processChain, boolean recursive) throws SMLException - Throws:
SMLException
-