com.marsching.flexiparse.parser
Interface Parser

All Known Implementing Classes:
ClasspathConfiguredParser, OSGiAwareParser, SimpleParser, XMLConfiguredParser

public interface Parser

Parsers parse XML files and produce object trees .

Author:
Sebastian Marsching
See Also:
NodeHandler, ParsingHandler, ObjectTreeElement

Method Summary
 void addElementMappingConfiguration(ElementMappingConfiguration configuration)
          Adds an element mapping configuration to this parser.
 void addNodeHandler(NodeHandler nodeHandler)
          Adds a node handler to this parser.
 Collection<? extends ElementMappingConfiguration> getElementMappingConfigurations()
          Returns all element mapping configurations that are active for this parser.
 Collection<? extends NodeHandler> getNodeHandlers()
          Returns all node handlers configured for this parser.
 ObjectTreeElement parse(Document document, Object... rootObjects)
          Parses a DOM document.
 ObjectTreeElement parse(File file, Object... rootObjects)
          Parses a DOM document.
 ObjectTreeElement parse(InputSource inputSource, Object... rootObjects)
          Parses a XML document obtained from an input source.
 ObjectTreeElement parse(InputStream inputStream, Object... rootObjects)
          Parses a XML document provided by a input stream.
 boolean removeElementMappingConfiguration(ElementMappingConfiguration configuration)
          Removes an element mapping configuration from this parser.
 boolean removeNodeHandler(NodeHandler nodeHandler)
          Removes a handler from this parser.
 

Method Detail

parse

ObjectTreeElement parse(Document document,
                        Object... rootObjects)
                        throws ParserException
Parses a DOM document.

Parameters:
document - DOM document
rootObjects - objects that should be attached to the root node of the object tree before parsing the document
Returns:
Root node of the resulting object tree
Throws:
ParserException - if an error occurs during the parsing process

addNodeHandler

void addNodeHandler(NodeHandler nodeHandler)
Adds a node handler to this parser. A node handler is called for the configured XML nodes and can add objects to the object tree.

Parameters:
nodeHandler - handler to add to the parser

removeNodeHandler

boolean removeNodeHandler(NodeHandler nodeHandler)
Removes a handler from this parser.

Parameters:
nodeHandler - handler to remove from this parser
Returns:
true if the handler was removed, false otherwise

getNodeHandlers

Collection<? extends NodeHandler> getNodeHandlers()
Returns all node handlers configured for this parser.

Returns:
node handlers for this parser

addElementMappingConfiguration

void addElementMappingConfiguration(ElementMappingConfiguration configuration)
Adds an element mapping configuration to this parser. Element mappings are used by the xml2object code to automatically create objects from the XML tree without having to explicitly write a handler.

Parameters:
configuration - mapping configuration that is going to be used by this parser

removeElementMappingConfiguration

boolean removeElementMappingConfiguration(ElementMappingConfiguration configuration)
Removes an element mapping configuration from this parser.

Parameters:
configuration - mapping configuration that should be removed
Returns:
true if the mapping configuration has been removed, false otherwise

getElementMappingConfigurations

Collection<? extends ElementMappingConfiguration> getElementMappingConfigurations()
Returns all element mapping configurations that are active for this parser.

Returns:
all element mapping configurations known by this parser

parse

ObjectTreeElement parse(File file,
                        Object... rootObjects)
                        throws ParserException
Parses a DOM document.

Parameters:
file - file containing the xml document to be parsed
rootObjects - objects that should be attached to the root node of the object tree before parsing the document
Returns:
Root node of the resulting object tree
Throws:
ParserException - if an error occurs during the parsing process

parse

ObjectTreeElement parse(InputStream inputStream,
                        Object... rootObjects)
                        throws ParserException
Parses a XML document provided by a input stream.

Parameters:
inputStream - stream to read from
rootObjects - objects that should be attached to the root node of the object tree before parsing the document
Returns:
Root node of the resulting object tree
Throws:
ParserException - if an error occurs during the parsing process

parse

ObjectTreeElement parse(InputSource inputSource,
                        Object... rootObjects)
                        throws ParserException
Parses a XML document obtained from an input source.

Parameters:
inputSource - source providing the XML document
rootObjects - objects that should be attached to the root node of the object tree before parsing the document
Returns:
Root node of the resulting object tree
Throws:
ParserException - if an error occurs during the parsing process


Copyright © 2008-2009. All Rights Reserved.