Interface Parser


public interface Parser
Defines a service interface for converting between Objects and external representations of them. Objects can be represented in a myriad of ways for transport and interoperability with other systems; this service is intended to isolate some of the more particular needs of various conversion libraries.
  • Method Details

    • configureParser

      ParserConfigurator configureParser(List<String> contextPath, ClassLoader loader)
      Creates an initial configurator object to be used to facilitate the marshaling and unmarshaling processes.
      Parameters:
      contextPath - a list of paths that implementations can search in order to find binding information
      loader - the classloader for the parser to use
      Returns:
      a configuration object with the specified contextPath and loader
    • marshal

      void marshal(ParserConfigurator configurator, Object obj, OutputStream os) throws ParserException
      Converts an object graph into the appropriate output format, writing it to the given stream.
      Parameters:
      configurator - object containing the relevant configuration information needed to perform the conversion
      obj - the root of the object graph to convert
      os - the output stream on which the converted object is written
      Throws:
      ParserException
    • marshal

      void marshal(ParserConfigurator configurator, Object obj, Node node) throws ParserException
      Converts an object graph into a Node,
      Parameters:
      configurator -
      obj -
      node -
      Throws:
      ParserException
    • unmarshal

      <T> T unmarshal(ParserConfigurator configurator, Class<? extends T> cls, InputStream stream) throws ParserException
      Converts a representation of an object graph into an instance of type T.
      Type Parameters:
      T - expected return object
      Parameters:
      configurator - object containing the relevant configuration information needed to perform the conversion
      cls - Class for the conversion
      stream - input stream which is read for the object data
      Returns:
      an object of type T as read and converted from the stream
      Throws:
      ParserException
    • unmarshal

      <T> T unmarshal(ParserConfigurator configurator, Class<? extends T> cls, Node node) throws ParserException
      Converts a representation of an object graph into an instance of type T.
      Type Parameters:
      T -
      Parameters:
      cls -
      node -
      Returns:
      an object of type T as read and converted from the node
      Throws:
      ParserException
    • unmarshal

      <T> T unmarshal(ParserConfigurator configurator, Class<? extends T> cls, Source source) throws ParserException
      Converts a representation of an object graph into an instance of type T.
      Type Parameters:
      T -
      Parameters:
      cls -
      source -
      Returns:
      an object of type T as read and converted from the source
      Throws:
      ParserException