Save This Page
Home » openjdk-7 » javax » xml » transform » sax » [javadoc | source]
    1   /*
    2    * Copyright 2000-2005 Sun Microsystems, Inc.  All Rights Reserved.
    3    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    4    *
    5    * This code is free software; you can redistribute it and/or modify it
    6    * under the terms of the GNU General Public License version 2 only, as
    7    * published by the Free Software Foundation.  Sun designates this
    8    * particular file as subject to the "Classpath" exception as provided
    9    * by Sun in the LICENSE file that accompanied this code.
   10    *
   11    * This code is distributed in the hope that it will be useful, but WITHOUT
   12    * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13    * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14    * version 2 for more details (a copy is included in the LICENSE file that
   15    * accompanied this code).
   16    *
   17    * You should have received a copy of the GNU General Public License version
   18    * 2 along with this work; if not, write to the Free Software Foundation,
   19    * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20    *
   21    * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   22    * CA 95054 USA or visit www.sun.com if you need additional information or
   23    * have any questions.
   24    */
   25   
   26   package javax.xml.transform.sax;
   27   
   28   import javax.xml.transform.Result;
   29   
   30   import org.xml.sax.ContentHandler;
   31   import org.xml.sax.ext.LexicalHandler;
   32   
   33   /**
   34    * <p>Acts as an holder for a transformation Result.</p>
   35    *
   36    * @author <a href="Jeff.Suttor@Sun.com">Jeff Suttor</a>
   37    */
   38   public class SAXResult implements Result {
   39   
   40       /**
   41        * If {@link javax.xml.transform.TransformerFactory#getFeature}
   42        * returns true when passed this value as an argument,
   43        * the Transformer supports Result output of this type.
   44        */
   45       public static final String FEATURE =
   46           "http://javax.xml.transform.sax.SAXResult/feature";
   47   
   48       /**
   49        * Zero-argument default constructor.
   50        */
   51       public SAXResult() {
   52       }
   53   
   54       /**
   55        * Create a SAXResult that targets a SAX2 {@link org.xml.sax.ContentHandler}.
   56        *
   57        * @param handler Must be a non-null ContentHandler reference.
   58        */
   59       public SAXResult(ContentHandler handler) {
   60           setHandler(handler);
   61       }
   62   
   63       /**
   64        * Set the target to be a SAX2 {@link org.xml.sax.ContentHandler}.
   65        *
   66        * @param handler Must be a non-null ContentHandler reference.
   67        */
   68       public void setHandler(ContentHandler handler) {
   69           this.handler = handler;
   70       }
   71   
   72       /**
   73        * Get the {@link org.xml.sax.ContentHandler} that is the Result.
   74        *
   75        * @return The ContentHandler that is to be transformation output.
   76        */
   77       public ContentHandler getHandler() {
   78           return handler;
   79       }
   80   
   81       /**
   82        * Set the SAX2 {@link org.xml.sax.ext.LexicalHandler} for the output.
   83        *
   84        * <p>This is needed to handle XML comments and the like.  If the
   85        * lexical handler is not set, an attempt should be made by the
   86        * transformer to cast the {@link org.xml.sax.ContentHandler} to a
   87        * <code>LexicalHandler</code>.</p>
   88        *
   89        * @param handler A non-null <code>LexicalHandler</code> for
   90        * handling lexical parse events.
   91        */
   92       public void setLexicalHandler(LexicalHandler handler) {
   93           this.lexhandler = handler;
   94       }
   95   
   96       /**
   97        * Get a SAX2 {@link org.xml.sax.ext.LexicalHandler} for the output.
   98        *
   99        * @return A <code>LexicalHandler</code>, or null.
  100        */
  101       public LexicalHandler getLexicalHandler() {
  102           return lexhandler;
  103       }
  104   
  105       /**
  106        * Method setSystemId Set the systemID that may be used in association
  107        * with the {@link org.xml.sax.ContentHandler}.
  108        *
  109        * @param systemId The system identifier as a URI string.
  110        */
  111       public void setSystemId(String systemId) {
  112           this.systemId = systemId;
  113       }
  114   
  115       /**
  116        * Get the system identifier that was set with setSystemId.
  117        *
  118        * @return The system identifier that was set with setSystemId, or null
  119        * if setSystemId was not called.
  120        */
  121       public String getSystemId() {
  122           return systemId;
  123       }
  124   
  125       //////////////////////////////////////////////////////////////////////
  126       // Internal state.
  127       //////////////////////////////////////////////////////////////////////
  128   
  129       /**
  130        * The handler for parse events.
  131        */
  132       private ContentHandler handler;
  133   
  134       /**
  135        * The handler for lexical events.
  136        */
  137       private LexicalHandler lexhandler;
  138   
  139       /**
  140        * The systemID that may be used in association
  141        * with the node.
  142        */
  143       private String systemId;
  144   }

Save This Page
Home » openjdk-7 » javax » xml » transform » sax » [javadoc | source]