Save This Page
Home » dom4j-1.6.1 » org.dom4j.io » [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.io;
    9   
   10   import org.dom4j.DocumentFactory;
   11   
   12   import org.xml.sax.SAXException;
   13   import org.xml.sax.XMLReader;
   14   
   15   /**
   16    * The SAXModifier parses, updates and writes an XML document. <br>
   17    * The input that is parsed is directly written to the specified output, unless
   18    * the current xml element has an associated ElementHandler. <br>
   19    * The {@link org.dom4j.ElementHandler}objects make it possible to update the
   20    * document on the fly, without having read tje complete document.
   21    * 
   22    * @author Wonne Keysers (Realsoftware.be)
   23    * 
   24    * @see org.dom4j.io.SAXReader
   25    * @see org.dom4j.io.XMLWriters
   26    */
   27   class SAXModifyReader extends SAXReader {
   28       private XMLWriter xmlWriter;
   29   
   30       private boolean pruneElements;
   31   
   32       public SAXModifyReader() {
   33       }
   34   
   35       public SAXModifyReader(boolean validating) {
   36           super(validating);
   37       }
   38   
   39       public SAXModifyReader(DocumentFactory factory) {
   40           super(factory);
   41       }
   42   
   43       public SAXModifyReader(DocumentFactory factory, boolean validating) {
   44           super(factory, validating);
   45       }
   46   
   47       public SAXModifyReader(XMLReader xmlReader) {
   48           super(xmlReader);
   49       }
   50   
   51       public SAXModifyReader(XMLReader xmlReader, boolean validating) {
   52           super(xmlReader, validating);
   53       }
   54   
   55       public SAXModifyReader(String xmlReaderClassName) throws SAXException {
   56           super(xmlReaderClassName);
   57       }
   58   
   59       public SAXModifyReader(String xmlReaderClassName, boolean validating)
   60               throws SAXException {
   61           super(xmlReaderClassName, validating);
   62       }
   63   
   64       public void setXMLWriter(XMLWriter writer) {
   65           this.xmlWriter = writer;
   66       }
   67   
   68       public boolean isPruneElements() {
   69           return pruneElements;
   70       }
   71   
   72       public void setPruneElements(boolean pruneElements) {
   73           this.pruneElements = pruneElements;
   74       }
   75   
   76       protected SAXContentHandler createContentHandler(XMLReader reader) {
   77           SAXModifyContentHandler handler = new SAXModifyContentHandler(
   78                   getDocumentFactory(), getDispatchHandler());
   79   
   80           handler.setXMLWriter(xmlWriter);
   81   
   82           return handler;
   83       }
   84   
   85       protected XMLWriter getXMLWriter() {
   86           return this.xmlWriter;
   87       }
   88   }
   89   
   90   /*
   91    * Redistribution and use of this software and associated documentation
   92    * ("Software"), with or without modification, are permitted provided that the
   93    * following conditions are met:
   94    * 
   95    * 1. Redistributions of source code must retain copyright statements and
   96    * notices. Redistributions must also contain a copy of this document.
   97    * 
   98    * 2. Redistributions in binary form must reproduce the above copyright notice,
   99    * this list of conditions and the following disclaimer in the documentation
  100    * and/or other materials provided with the distribution.
  101    * 
  102    * 3. The name "DOM4J" must not be used to endorse or promote products derived
  103    * from this Software without prior written permission of MetaStuff, Ltd. For
  104    * written permission, please contact dom4j-info@metastuff.com.
  105    * 
  106    * 4. Products derived from this Software may not be called "DOM4J" nor may
  107    * "DOM4J" appear in their names without prior written permission of MetaStuff,
  108    * Ltd. DOM4J is a registered trademark of MetaStuff, Ltd.
  109    * 
  110    * 5. Due credit should be given to the DOM4J Project - http://www.dom4j.org
  111    * 
  112    * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' AND
  113    * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  114    * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  115    * ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS CONTRIBUTORS BE
  116    * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  117    * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  118    * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  119    * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  120    * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  121    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  122    * POSSIBILITY OF SUCH DAMAGE.
  123    * 
  124    * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
  125    */

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