Class SMLUtils


public class SMLUtils extends XMLBindingsUtils

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 Details

  • Constructor Details

    • SMLUtils

      public SMLUtils(String version)
      Creates this helper for the specified SensorML version
      Parameters:
      version -
    • SMLUtils

      public SMLUtils(SMLStaxBindings staxBindings)
  • Method Details

    • loadRegistry

      public static void loadRegistry()
    • readProcess

      public AbstractProcess readProcess(DOMHelper dom, Element processElt) throws XMLReaderException
      Reads a SensorML process from a DOM element
      Parameters:
      dom - DOM helper wrapping the XML document to read from
      processElt - 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

      public AbstractProcess readProcess(InputStream is) throws XMLReaderException
      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

      public AbstractProcess readProcess(URL url) throws XMLReaderException
      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

      public Element writeProcess(DOMHelper dom, AbstractProcess process) throws XMLWriterException
      Serializes a SensorML process to a DOM element
      Parameters:
      dom - DOM helper wrapping the XMl document to write to
      process - 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 to
      process - Process object to serialize
      indent - Set to true to indent the output
      Throws:
      XMLWriterException - if an error occurs while generating the XML content
      IOException - if an error occurs while writing to output the stream
    • getVersion

      public String getVersion(DOMHelper dom, Element smlElt)
      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:
      readFromXmlStream in class XMLBindingsUtils
      Throws:
      XMLStreamException
    • writeToXmlStream

      protected void writeToXmlStream(XMLStreamWriter writer, Object sweObj, Enum<?> eltType) throws XMLStreamException
      Specified by:
      writeToXmlStream in class XMLBindingsUtils
      Throws:
      XMLStreamException
    • setProcessFactory

      public void setProcessFactory(IProcessFactory processFactory)
    • wrapWithProcessDescription

      public static AbstractProcessImpl wrapWithProcessDescription(IProcessExec processExec)
      Create SML process description from process executable implementation
      Parameters:
      processExec -
      Returns:
      The process description object
    • validateConnections

      public static void validateConnections(AggregateProcess processChain) throws SMLException
      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 execution
      useThreads - if true, run children processes in separate threads
      Throws:
      SMLException - if process cannot be made executable
    • getConfiguredInstance

      public AbstractProcess getConfiguredInstance(AbstractProcess process) throws SMLException
      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

      protected void mergeMetadataList(OgcPropertyList baseList, OgcPropertyList instanceList)
    • applyConfig

      public void applyConfig(AbstractProcess process, boolean removeConfig) throws SMLException
      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

      protected void applyConfig(AbstractProcess process, Settings settings) throws SMLException
      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

      public void resolveLinkedProcesses(AggregateProcess processChain) throws SMLException
      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