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