001/* 002 * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved. 003 * 004 * This software is open source. 005 * See the bottom of this file for the licence. 006 * 007 * $Id: IndexedDocumentFactory.java,v 1.3 2001/07/03 14:42:43 jstrachan Exp $ 008 */ 009 010package org.dom4j.util; 011 012import java.util.Map; 013 014import org.dom4j.Attribute; 015import org.dom4j.Document; 016import org.dom4j.DocumentFactory; 017import org.dom4j.Element; 018import org.dom4j.Namespace; 019import org.dom4j.QName; 020 021/** <p><code>IndexedDocumentFactory</code> is a factory of XML objects which 022 * create indexed Element implementations to allow quicker lookup via name 023 * of Element and Attributes though at the expense of more memory used 024 * to create the name indexes.</p> 025 * 026 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a> 027 * @version $Revision: 1.3 $ 028 */ 029public class IndexedDocumentFactory extends DocumentFactory { 030 031 /** The Singleton instance */ 032 static transient IndexedDocumentFactory singleton = new IndexedDocumentFactory(); 033 034 035 /** <p>Access to the singleton instance of this factory.</p> 036 * 037 * @return the default singleon instance 038 */ 039 public static DocumentFactory getInstance() { 040 return singleton; 041 } 042 043 044 // DocumentFactory methods 045 //------------------------------------------------------------------------- 046 047 public Element createElement(QName qname) { 048 return new IndexedElement(qname); 049 } 050 051 public Element createElement(QName qname, int attributeCount) { 052 return new IndexedElement(qname, attributeCount); 053 } 054} 055 056 057 058 059/* 060 * Redistribution and use of this software and associated documentation 061 * ("Software"), with or without modification, are permitted provided 062 * that the following conditions are met: 063 * 064 * 1. Redistributions of source code must retain copyright 065 * statements and notices. Redistributions must also contain a 066 * copy of this document. 067 * 068 * 2. Redistributions in binary form must reproduce the 069 * above copyright notice, this list of conditions and the 070 * following disclaimer in the documentation and/or other 071 * materials provided with the distribution. 072 * 073 * 3. The name "DOM4J" must not be used to endorse or promote 074 * products derived from this Software without prior written 075 * permission of MetaStuff, Ltd. For written permission, 076 * please contact dom4j-info@metastuff.com. 077 * 078 * 4. Products derived from this Software may not be called "DOM4J" 079 * nor may "DOM4J" appear in their names without prior written 080 * permission of MetaStuff, Ltd. DOM4J is a registered 081 * trademark of MetaStuff, Ltd. 082 * 083 * 5. Due credit should be given to the DOM4J Project 084 * (http://dom4j.org/). 085 * 086 * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS 087 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT 088 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 089 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 090 * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 091 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 092 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 093 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 094 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 095 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 096 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 097 * OF THE POSSIBILITY OF SUCH DAMAGE. 098 * 099 * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved. 100 * 101 * $Id: IndexedDocumentFactory.java,v 1.3 2001/07/03 14:42:43 jstrachan Exp $ 102 */