KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > ecore > xmi > XMLParserPool


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  *$Id: XMLParserPool.java,v 1.2 2005/06/08 06:16:07 nickb Exp $
16  */

17
18 package org.eclipse.emf.ecore.xmi;
19
20 import java.util.Map JavaDoc;
21 import javax.xml.parsers.ParserConfigurationException JavaDoc;
22 import javax.xml.parsers.SAXParser JavaDoc;
23 import org.xml.sax.SAXException JavaDoc;
24
25 /**
26  * A pool of parsers that a resource implementation can use to get a parser instance for parsing XML instance documents.
27  * The use of a parser pool can be specified using {@link XMLResource#OPTION_USE_PARSER_POOL} load option.
28  * <p>
29  * The parser instance is retrieved and placed back to the pool
30  * based on the features and properties specified for this parser.
31  * The default implementation is provided by {@link org.eclipse.emf.ecore.xmi.impl.XMLParserPoolImpl XMLParserPoolImpl}.
32  * </p>
33  * <p>
34  * Note that the correct properties and feature maps for this parser instance
35  * <b>must</b> be provided when retrieving the parser from the pool and, even more importantly when,
36  * releasing the parser back to the pool.
37  * Failure to do so will result in improperly configured parsers.
38  * </p>
39  */

40 public interface XMLParserPool
41 {
42   /**
43    * Retrieves a parser from the pool given specified properties and features.
44    * If parser can't be created using specified properties or features,
45    * an exception can be thrown.
46    *
47    * @param features a map of the parser features and their values.
48    * @param properties a map of a parser properties and their values.
49    * @param useLexicalHandler whether a lexical handler was set during loading.
50    * @return A parser instance with given features and properties.
51    * @throws ParserConfigurationException
52    * @throws SAXException
53    */

54   public SAXParser JavaDoc get(Map JavaDoc features, Map JavaDoc properties, boolean useLexicalHandler) throws ParserConfigurationException JavaDoc, SAXException JavaDoc;
55
56   /**
57    * Returns the parser to the pool.
58    * @param parser the parser to return to the pool.
59    * @param features a map of the parser features and their values.
60    * @param properties a map of a parser properties and their values.
61    * @param useLexicalHandler whether a lexical handler was set during loading.
62    */

63   public void release(SAXParser JavaDoc parser, Map JavaDoc features, Map JavaDoc properties, boolean useLexicalHandler);
64 }
65
Popular Tags