Interface XmlService

All Known Implementing Classes:
XmlServiceImpl

@Contract public interface XmlService
This is the main service for parsing your XML files using some pluggable parsing technology.
Author:
jwells
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The default namespace of the document
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    createBean(Class<T> beanInterface)
    This creates an instance of the given bean type of with no fields of the bean filled in.
    createEmptyHandle(Class<T> jaxbAnnotationInterface)
    This creates an empty handle (root will initially be null) corresponding to the given interface class
    createEmptyHandle(Class<T> jaxbAnnotationInterface, boolean advertiseInRegistry, boolean advertiseInHub)
    This creates an empty handle (root will initially be null) corresponding to the given interface class
    <T> void
    marshal(OutputStream outputStream, XmlRootHandle<T> rootHandle)
    Will marshal the given tree into the given stream.
    <T> void
    marshal(OutputStream outputStream, XmlRootHandle<T> rootHandle, Map<String,Object> options)
    Will marshal the given tree into the given stream.
    unmarshal(InputStream inputStream, Class<T> jaxbAnnotatedInterface)
    Unmarshals an XML stream using the jaxb annotated interface.
    unmarshal(InputStream inputStream, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub)
    Unmarshals an XML stream using the jaxb annotated interface.
    unmarshal(InputStream inputStream, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub, Map<String,Object> options)
    Unmarshals an XML stream using the jaxb annotated interface.
    unmarshal(URI uri, Class<T> jaxbAnnotatedInterface)
    Unmarshalls the given URI using the jaxb annotated interface.
    unmarshal(URI uri, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub)
    Unmarshalls the given URI using the jaxb annotated interface.
    unmarshal(URI uri, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub, Map<String,Object> options)
    Unmarshalls the given URI using the jaxb annotated interface.
    unmarshal(XMLStreamReader reader, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub)
    Unmarshals an XML stream using the jaxb annotated interface.
    unmarshal(XMLStreamReader reader, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub, Map<String,Object> options)
    Unmarshals an XML stream using the jaxb annotated interface.
  • Field Details

  • Method Details

    • unmarshal

      <T> XmlRootHandle<T> unmarshal(URI uri, Class<T> jaxbAnnotatedInterface)
      Unmarshalls the given URI using the jaxb annotated interface. The resulting JavaBean tree will be advertised in the ServiceLocator and in the Hub. Will use the registered implementation of XmlServiceParser to parse the file.
      Parameters:
      uri - The non-null URI whereby to find the xml corresponding to the class
      jaxbAnnotatedClassOrInterface - The non-null class corresonding to the Xml to be parsed
      Returns:
      A non-null handle that can be used to get the unmarshalled data or perform other tasks
    • unmarshal

      <T> XmlRootHandle<T> unmarshal(URI uri, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub)
      Unmarshalls the given URI using the jaxb annotated interface. Will use the registered implementation of XmlServiceParser to parse the file.
      Parameters:
      uri - The non-null URI whereby to find the xml corresponding to the class
      jaxbAnnotatedClassOrInterface - The non-null interface corresponding to the Xml to be parsed
      advertiseInRegistry - if true the entire tree of parsed xml will be added to the ServiceLocator
      advertiseInHub - if true the entire tree of parsed xml will be added to the HK2 configuration Hub (as bean-like maps)
      Returns:
      A non-null handle that can be used to get the unmarshalled data or perform other tasks
    • unmarshal

      <T> XmlRootHandle<T> unmarshal(URI uri, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub, Map<String,Object> options)
      Unmarshalls the given URI using the jaxb annotated interface. Will use the registered implementation of XmlServiceParser to parse the file.
      Parameters:
      uri - The non-null URI whereby to find the xml corresponding to the class
      jaxbAnnotatedClassOrInterface - The non-null interface corresponding to the Xml to be parsed
      advertiseInRegistry - if true the entire tree of parsed xml will be added to the ServiceLocator
      advertiseInHub - if true the entire tree of parsed xml will be added to the HK2 configuration Hub (as bean-like maps)
      options - optional (possibly null) options from the caller
      Returns:
      A non-null handle that can be used to get the unmarshalled data or perform other tasks
    • unmarshal

      <T> XmlRootHandle<T> unmarshal(XMLStreamReader reader, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub)
      Unmarshals an XML stream using the jaxb annotated interface. Will use a built-in algorithm to read the stream
      Parameters:
      reader - The non-null XMLStreamReader representing the XML to be read
      jaxbAnnotatedClassOrInterface - The non-null interface corresponding to the Xml to be parsed
      advertiseInRegistry - if true the entire tree of parsed xml will be added to the ServiceLocator
      advertiseInHub - if true the entire tree of parsed xml will be added to the HK2 configuration Hub (as bean-like maps)
      Returns:
      A non-null handle that can be used to get the unmarshalled data or perform other tasks
    • unmarshal

      <T> XmlRootHandle<T> unmarshal(XMLStreamReader reader, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub, Map<String,Object> options)
      Unmarshals an XML stream using the jaxb annotated interface. Will use a built-in algorithm to read the stream
      Parameters:
      reader - The non-null XMLStreamReader representing the XML to be read
      jaxbAnnotatedClassOrInterface - The non-null interface corresponding to the Xml to be parsed
      advertiseInRegistry - if true the entire tree of parsed xml will be added to the ServiceLocator
      advertiseInHub - if true the entire tree of parsed xml will be added to the HK2 configuration Hub (as bean-like maps)
      options - optional (possibly null) options from the caller
      Returns:
      A non-null handle that can be used to get the unmarshalled data or perform other tasks
    • unmarshal

      <T> XmlRootHandle<T> unmarshal(InputStream inputStream, Class<T> jaxbAnnotatedInterface)
      Unmarshals an XML stream using the jaxb annotated interface. Will use the registered implementation of XmlServiceParser to parse the file. The beans will be included in the service registry and the configuration hub as appropriate
      Parameters:
      inputStream - The non-null input stream to read. Will not close this stream
      jaxbAnnotatedClassOrInterface - The non-null interface corresponding to the Xml to be parsed
      Returns:
      A non-null handle that can be used to get the unmarshalled data or perform other tasks
    • unmarshal

      <T> XmlRootHandle<T> unmarshal(InputStream inputStream, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub)
      Unmarshals an XML stream using the jaxb annotated interface. Will use the registered implementation of XmlServiceParser to parse the file.
      Parameters:
      inputStream - The non-null input stream to read. Will not close this stream
      jaxbAnnotatedClassOrInterface - The non-null interface corresponding to the Xml to be parsed
      advertiseInRegistry - if true the entire tree of parsed xml will be added to the ServiceLocator
      advertiseInHub - if true the entire tree of parsed xml will be added to the HK2 configuration Hub (as bean-like maps)
      Returns:
      A non-null handle that can be used to get the unmarshalled data or perform other tasks
    • unmarshal

      <T> XmlRootHandle<T> unmarshal(InputStream inputStream, Class<T> jaxbAnnotatedInterface, boolean advertiseInRegistry, boolean advertiseInHub, Map<String,Object> options)
      Unmarshals an XML stream using the jaxb annotated interface. Will use the registered implementation of XmlServiceParser to parse the file.
      Parameters:
      inputStream - The non-null input stream to read. Will not close this stream
      jaxbAnnotatedClassOrInterface - The non-null interface corresponding to the Xml to be parsed
      advertiseInRegistry - if true the entire tree of parsed xml will be added to the ServiceLocator
      advertiseInHub - if true the entire tree of parsed xml will be added to the HK2 configuration Hub (as bean-like maps)
      options - optional (possibly null) options from the caller
      Returns:
      A non-null handle that can be used to get the unmarshalled data or perform other tasks
    • createEmptyHandle

      <T> XmlRootHandle<T> createEmptyHandle(Class<T> jaxbAnnotationInterface, boolean advertiseInRegistry, boolean advertiseInHub)
      This creates an empty handle (root will initially be null) corresponding to the given interface class
      Parameters:
      jaxbAnnotationInterface - The non-null interface class corresponding to the XML to be parsed
      advertiseInRegistry - if true the entire tree of parsed xml will be added to the ServiceLocator
      advertiseInHub - if true the entire tree of parsed xml will be added to the HK2 configuration Hub (as bean-like maps)
      Returns:
      A non-null handle that can be used to create a new root bean, but which is not initially tied to any backing file or other input stream
    • createEmptyHandle

      <T> XmlRootHandle<T> createEmptyHandle(Class<T> jaxbAnnotationInterface)
      This creates an empty handle (root will initially be null) corresponding to the given interface class
      Parameters:
      jaxbAnnotationInterface - The non-null interface class corresponding to the XML to be parsed
      Returns:
      A non-null handle that can be used to create a new root bean, but which is not initially tied to any backing file or other input stream
    • createBean

      <T> T createBean(Class<T> beanInterface)
      This creates an instance of the given bean type of with no fields of the bean filled in. Objects created with this API can be used in the adder methods of the beans, and will not be validated (but all setters and getters and lookups will work properly)
      Returns:
      An instance of the bean with no properties set
    • marshal

      <T> void marshal(OutputStream outputStream, XmlRootHandle<T> rootHandle) throws IOException
      Will marshal the given tree into the given stream. This can be called with a rootHandle that was NOT created with this XmlService implementation. In that way different parsing formats can potentially be converted into each other. For example an XML document can be converted to equivalent JSON. Not all transformations may be possible. This method will hold the read lock of the rootHandle so it cannot be modified while being written to the output stream
      Parameters:
      outputStream - A non-closed output stream. This method will not close the output stream
      rootHandle - A non-null root handle that may or may not have been created with this XmlService implementation
      Throws:
      IOException - On any exception that might happen
    • marshal

      <T> void marshal(OutputStream outputStream, XmlRootHandle<T> rootHandle, Map<String,Object> options) throws IOException
      Will marshal the given tree into the given stream. This can be called with a rootHandle that was NOT created with this XmlService implementation. In that way different parsing formats can potentially be converted into each other. For example an XML document can be converted to equivalent JSON. Not all transformations may be possible. This method will hold the read lock of the rootHandle so it cannot be modified while being written to the output stream
      Parameters:
      outputStream - A non-closed output stream. This method will not close the output stream
      rootHandle - A non-null root handle that may or may not have been created with this XmlService implementation
      options - optional (possibly null) options from the caller
      Throws:
      IOException - On any exception that might happen