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