## org.eclipse.emf.ecore.xmi.impl
Class XMLParserPoolImpl

    java.lang.Object
      org.eclipse.emf.ecore.xmi.impl.XMLParserPoolImpl

All Implemented Interfaces:
  XMLParserPool

    public class XMLParserPoolImpl

extends java.lang.Object
implements XMLParserPool

This is the default thread safe implementation of XMLParserPool. This implementation is tuned for caching parsers and handlers created using same loading options. To avoid possible memory leak (in case user is trying to parse documents using different options for every parse), there is a restriction on the size of the pool. The key used for handler caching is based on the option map passed to load.

Constructor Summary
`XMLParserPoolImpl()` Creates an instance that caches only parsers but not handlers.
`XMLParserPoolImpl(boolean useHandlerCache)` Creates an instance that caches parsers and caches handlers as specified.
`XMLParserPoolImpl(int size, boolean useHandlerCache)` Creates an instance that caches parsers and caches handlers as specified.

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.
`protected javax.xml.parsers.SAXParser` `makeParser(java.util.Map<java.lang.String,java.lang.Boolean> features, java.util.Map<java.lang.String,?> properties)`
`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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### XMLParserPoolImpl

    public XMLParserPoolImpl()

  Creates an instance that caches only parsers but not handlers.

  See Also:
    `XMLParserPoolImpl(boolean)`

### XMLParserPoolImpl

    public XMLParserPoolImpl(boolean useHandlerCache)

  Creates an instance that caches parsers and caches handlers as specified.

  Parameters:
    `useHandlerCache` - indicates whether handler caching should be use.
  See Also:
    `XMLParserPoolImpl(boolean)`

### XMLParserPoolImpl

    public XMLParserPoolImpl(int size,
                             boolean useHandlerCache)

  Creates an instance that caches parsers and caches handlers as specified.

  Parameters:
    `size` - indicates the maximum number of instances parser or handler instances that will be cached.
    `useHandlerCache` - indicates whether handler caching should be use.
  See Also:
    `XMLParserPoolImpl(boolean)`

Method Detail

### get

    public 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

  Description copied from interface: `XMLParserPool`
  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.

  Specified by:
    `get` in interface `XMLParserPool`
  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`
  See Also:
    `XMLParserPool.get(Map, Map, boolean)`

### release

    public 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)

  Description copied from interface: `XMLParserPool`
  Returns the parser to the pool.

  Specified by:
    `release` in interface `XMLParserPool`
  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.
  See Also:
    `XMLParserPool.release(SAXParser, Map, Map, boolean)`

### makeParser

    protected javax.xml.parsers.SAXParser makeParser(java.util.Map<java.lang.String,java.lang.Boolean> features,
                                                     java.util.Map<java.lang.String,?> properties)
                                              throws javax.xml.parsers.ParserConfigurationException,
                                                     org.xml.sax.SAXException

  Throws:
    `javax.xml.parsers.ParserConfigurationException`
    `org.xml.sax.SAXException`

### getDefaultHandler

    public XMLDefaultHandler getDefaultHandler(XMLResource resource,
                                               XMLLoad xmlLoad,
                                               XMLHelper helper,
                                               java.util.Map<?,?> options)

  Description copied from interface: `XMLParserPool`
  Retrieves XMLDefaultHandler from the pool and initializes / prepares it.

  Specified by:
    `getDefaultHandler` in interface `XMLParserPool`
  Parameters:
    `resource` - - the resource
    `xmlLoad` - - the XMLLoad
    `helper` - - XMLHelper

### releaseDefaultHandler

    public void releaseDefaultHandler(XMLDefaultHandler handler,
                                      java.util.Map<?,?> options)

  Description copied from interface: `XMLParserPool`
  Returns the XMLDefaultHandler to the pool.

  Specified by:
    `releaseDefaultHandler` in interface `XMLParserPool`
  Parameters:
    `handler` - the handler to return to the pool

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