Save This Page
Home » dom4j-1.6.1 » org.dom4j.util » [javadoc | source]
    1   /*
    2    * Copyright 2001-2005 (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   
    8   package org.dom4j.util;
    9   
   10   import java.util.Map;
   11   
   12   import org.dom4j.Attribute;
   13   import org.dom4j.CDATA;
   14   import org.dom4j.Comment;
   15   import org.dom4j.Document;
   16   import org.dom4j.DocumentFactory;
   17   import org.dom4j.DocumentType;
   18   import org.dom4j.Element;
   19   import org.dom4j.Entity;
   20   import org.dom4j.Namespace;
   21   import org.dom4j.NodeFilter;
   22   import org.dom4j.ProcessingInstruction;
   23   import org.dom4j.QName;
   24   import org.dom4j.Text;
   25   import org.dom4j.XPath;
   26   import org.dom4j.rule.Pattern;
   27   
   28   import org.jaxen.VariableContext;
   29   
   30   /**
   31    * <p>
   32    * <code>ProxyDocumentFactory</code> implements a proxy to a DocumentFactory
   33    * which is useful for implementation inheritence, allowing the pipelining of
   34    * various factory implementations. For example an EncodingDocumentFactory which
   35    * takes care of encoding strings outside of allowable XML ranges could be used
   36    * with a DatatypeDocumentFactory which is XML Schema Data Type aware.
   37    * </p>
   38    * 
   39    * @author <a href="mailto:jstrachan@apache.org">James Strachan </a>
   40    * @version $Revision: 1.13 $
   41    */
   42   public abstract class ProxyDocumentFactory {
   43       private DocumentFactory proxy;
   44   
   45       public ProxyDocumentFactory() {
   46           // use default factory
   47           this.proxy = DocumentFactory.getInstance();
   48       }
   49   
   50       public ProxyDocumentFactory(DocumentFactory proxy) {
   51           this.proxy = proxy;
   52       }
   53   
   54       // Factory methods
   55       // -------------------------------------------------------------------------
   56       public Document createDocument() {
   57           return proxy.createDocument();
   58       }
   59   
   60       public Document createDocument(Element rootElement) {
   61           return proxy.createDocument(rootElement);
   62       }
   63   
   64       public DocumentType createDocType(String name, String publicId,
   65               String systemId) {
   66           return proxy.createDocType(name, publicId, systemId);
   67       }
   68   
   69       public Element createElement(QName qname) {
   70           return proxy.createElement(qname);
   71       }
   72   
   73       public Element createElement(String name) {
   74           return proxy.createElement(name);
   75       }
   76   
   77       public Attribute createAttribute(Element owner, QName qname, String value) {
   78           return proxy.createAttribute(owner, qname, value);
   79       }
   80   
   81       public Attribute createAttribute(Element owner, String name, String value) {
   82           return proxy.createAttribute(owner, name, value);
   83       }
   84   
   85       public CDATA createCDATA(String text) {
   86           return proxy.createCDATA(text);
   87       }
   88   
   89       public Comment createComment(String text) {
   90           return proxy.createComment(text);
   91       }
   92   
   93       public Text createText(String text) {
   94           return proxy.createText(text);
   95       }
   96   
   97       public Entity createEntity(String name, String text) {
   98           return proxy.createEntity(name, text);
   99       }
  100   
  101       public Namespace createNamespace(String prefix, String uri) {
  102           return proxy.createNamespace(prefix, uri);
  103       }
  104   
  105       public ProcessingInstruction createProcessingInstruction(String target,
  106               String data) {
  107           return proxy.createProcessingInstruction(target, data);
  108       }
  109   
  110       public ProcessingInstruction createProcessingInstruction(String target,
  111               Map data) {
  112           return proxy.createProcessingInstruction(target, data);
  113       }
  114   
  115       public QName createQName(String localName, Namespace namespace) {
  116           return proxy.createQName(localName, namespace);
  117       }
  118   
  119       public QName createQName(String localName) {
  120           return proxy.createQName(localName);
  121       }
  122   
  123       public QName createQName(String name, String prefix, String uri) {
  124           return proxy.createQName(name, prefix, uri);
  125       }
  126   
  127       public QName createQName(String qualifiedName, String uri) {
  128           return proxy.createQName(qualifiedName, uri);
  129       }
  130   
  131       public XPath createXPath(String xpathExpression) {
  132           return proxy.createXPath(xpathExpression);
  133       }
  134   
  135       public XPath createXPath(String xpathExpression,
  136               VariableContext variableContext) {
  137           return proxy.createXPath(xpathExpression, variableContext);
  138       }
  139   
  140       public NodeFilter createXPathFilter(String xpathFilterExpression,
  141               VariableContext variableContext) {
  142           return proxy.createXPathFilter(xpathFilterExpression, variableContext);
  143       }
  144   
  145       public NodeFilter createXPathFilter(String xpathFilterExpression) {
  146           return proxy.createXPathFilter(xpathFilterExpression);
  147       }
  148   
  149       public Pattern createPattern(String xpathPattern) {
  150           return proxy.createPattern(xpathPattern);
  151       }
  152   
  153       // Implementation methods
  154       // -------------------------------------------------------------------------
  155       protected DocumentFactory getProxy() {
  156           return proxy;
  157       }
  158   
  159       protected void setProxy(DocumentFactory proxy) {
  160           if (proxy == null) {
  161               // use default factory
  162               proxy = DocumentFactory.getInstance();
  163           }
  164   
  165           this.proxy = proxy;
  166       }
  167   }
  168   
  169   /*
  170    * Redistribution and use of this software and associated documentation
  171    * ("Software"), with or without modification, are permitted provided that the
  172    * following conditions are met:
  173    * 
  174    * 1. Redistributions of source code must retain copyright statements and
  175    * notices. Redistributions must also contain a copy of this document.
  176    * 
  177    * 2. Redistributions in binary form must reproduce the above copyright notice,
  178    * this list of conditions and the following disclaimer in the documentation
  179    * and/or other materials provided with the distribution.
  180    * 
  181    * 3. The name "DOM4J" must not be used to endorse or promote products derived
  182    * from this Software without prior written permission of MetaStuff, Ltd. For
  183    * written permission, please contact dom4j-info@metastuff.com.
  184    * 
  185    * 4. Products derived from this Software may not be called "DOM4J" nor may
  186    * "DOM4J" appear in their names without prior written permission of MetaStuff,
  187    * Ltd. DOM4J is a registered trademark of MetaStuff, Ltd.
  188    * 
  189    * 5. Due credit should be given to the DOM4J Project - http://www.dom4j.org
  190    * 
  191    * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' AND
  192    * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  193    * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  194    * ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS CONTRIBUTORS BE
  195    * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  196    * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  197    * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  198    * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  199    * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  200    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  201    * POSSIBILITY OF SUCH DAMAGE.
  202    * 
  203    * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
  204    */

Save This Page
Home » dom4j-1.6.1 » org.dom4j.util » [javadoc | source]