org.eclipse.emf.ecore.xmi
Interface XMLParserPool

All Known Implementing Classes:
XMLParserPoolImpl

public interface XMLParserPool

Defines an interface to cache parsers and parser's handlers (XMLDefaultHandler) to improve deserialization performance. The use of a parser pool can be specified using XMLResource.OPTION_USE_PARSER_POOL load option.

The parser instance is retrieved and placed back to the pool based on the features and properties specified for this parser. The default implementation is provided by XMLParserPoolImpl.

Note that the correct properties and feature maps for this parser instance must be provided when retrieving the parser from the pool and, even more importantly when, releasing the parser back to the pool. Failure to do so will result in improperly configured parsers.

The handler instance is retrieved and placed back to the pool based on the options map specified for loading a resource. The default implementation is provided by XMLParserPoolImpl.


Method Summary
 javax.xml.parsers.SAXParser get(java.util.Map<java.lang.String,java.lang.Boolean> features, java.util.Map<java.lang.String,?> properties, boolean useLexicalHandler)
          Retrieves a parser from the pool given specified properties and features.
 XMLDefaultHandler getDefaultHandler(XMLResource resource, XMLLoad xmlLoad, XMLHelper helper, java.util.Map<?,?> options)
          Retrieves XMLDefaultHandler from the pool and initializes / prepares it.
 void release(javax.xml.parsers.SAXParser parser, java.util.Map<java.lang.String,java.lang.Boolean> features, java.util.Map<java.lang.String,?> properties, boolean useLexicalHandler)
          Returns the parser to the pool.
 void releaseDefaultHandler(XMLDefaultHandler handler, java.util.Map<?,?> options)
          Returns the XMLDefaultHandler to the pool.
 

Method Detail

get

javax.xml.parsers.SAXParser get(java.util.Map<java.lang.String,java.lang.Boolean> features,
                                java.util.Map<java.lang.String,?> properties,
                                boolean useLexicalHandler)
                                throws javax.xml.parsers.ParserConfigurationException,
                                       org.xml.sax.SAXException
Retrieves a parser from the pool given specified properties and features. If parser can't be created using specified properties or features, an exception can be thrown.

Parameters:
features - a map of the parser features and their values.
properties - a map of a parser properties and their values.
useLexicalHandler - whether a lexical handler was set during loading.
Returns:
A parser instance with given features and properties.
Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

release

void release(javax.xml.parsers.SAXParser parser,
             java.util.Map<java.lang.String,java.lang.Boolean> features,
             java.util.Map<java.lang.String,?> properties,
             boolean useLexicalHandler)
Returns the parser to the pool.

Parameters:
parser - the parser to return to the pool.
features - a map of the parser features and their values.
properties - a map of a parser properties and their values.
useLexicalHandler - whether a lexical handler was set during loading.

getDefaultHandler

XMLDefaultHandler getDefaultHandler(XMLResource resource,
                                    XMLLoad xmlLoad,
                                    XMLHelper helper,
                                    java.util.Map<?,?> options)
Retrieves XMLDefaultHandler from the pool and initializes / prepares it.

Parameters:
resource - - the resource
xmlLoad - - the XMLLoad
helper - - XMLHelper
options -

releaseDefaultHandler

void releaseDefaultHandler(XMLDefaultHandler handler,
                           java.util.Map<?,?> options)
Returns the XMLDefaultHandler to the pool.

Parameters:
handler - the handler to return to the pool
options -

Copyright 2001-2012 IBM Corporation and others.
All Rights Reserved.