1 /*
2 * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved.
3 *
4 * This software is open source.
5 * See the bottom of this file for the licence.
6 *
7 * $Id: IndexedDocumentFactory.java,v 1.7 2004/06/25 08:03:41 maartenc Exp $
8 */
9
10 package org.dom4j.util;
11
12 import org.dom4j.DocumentFactory;
13 import org.dom4j.Element;
14 import org.dom4j.QName;
15
16 /*** <p><code>IndexedDocumentFactory</code> is a factory of XML objects which
17 * create indexed Element implementations to allow quicker lookup via name
18 * of Element and Attributes though at the expense of more memory used
19 * to create the name indexes.</p>
20 *
21 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
22 * @version $Revision: 1.7 $
23 */
24 public class IndexedDocumentFactory extends DocumentFactory {
25
26 /*** The Singleton instance */
27 static transient IndexedDocumentFactory singleton = new IndexedDocumentFactory();
28
29
30 /*** <p>Access to the singleton instance of this factory.</p>
31 *
32 * @return the default singleon instance
33 */
34 public static DocumentFactory getInstance() {
35 return singleton;
36 }
37
38
39 // DocumentFactory methods
40 //-------------------------------------------------------------------------
41
42 public Element createElement(QName qname) {
43 return new IndexedElement(qname);
44 }
45
46 public Element createElement(QName qname, int attributeCount) {
47 return new IndexedElement(qname, attributeCount);
48 }
49 }
50
51
52
53
54 /*
55 * Redistribution and use of this software and associated documentation
56 * ("Software"), with or without modification, are permitted provided
57 * that the following conditions are met:
58 *
59 * 1. Redistributions of source code must retain copyright
60 * statements and notices. Redistributions must also contain a
61 * copy of this document.
62 *
63 * 2. Redistributions in binary form must reproduce the
64 * above copyright notice, this list of conditions and the
65 * following disclaimer in the documentation and/or other
66 * materials provided with the distribution.
67 *
68 * 3. The name "DOM4J" must not be used to endorse or promote
69 * products derived from this Software without prior written
70 * permission of MetaStuff, Ltd. For written permission,
71 * please contact dom4j-info@metastuff.com.
72 *
73 * 4. Products derived from this Software may not be called "DOM4J"
74 * nor may "DOM4J" appear in their names without prior written
75 * permission of MetaStuff, Ltd. DOM4J is a registered
76 * trademark of MetaStuff, Ltd.
77 *
78 * 5. Due credit should be given to the DOM4J Project -
79 * http://www.dom4j.org
80 *
81 * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
82 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
83 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
84 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
85 * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
86 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
87 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
88 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
89 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
90 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
91 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
92 * OF THE POSSIBILITY OF SUCH DAMAGE.
93 *
94 * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved.
95 *
96 * $Id: IndexedDocumentFactory.java,v 1.7 2004/06/25 08:03:41 maartenc Exp $
97 */