Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxp/src/javax/xml/transform/sax/SAXResult.java
32288 views
/*1* Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.xml.transform.sax;2627import javax.xml.transform.Result;2829import org.xml.sax.ContentHandler;30import org.xml.sax.ext.LexicalHandler;3132/**33* <p>Acts as an holder for a transformation Result.</p>34*35* @author <a href="[email protected]">Jeff Suttor</a>36*/37public class SAXResult implements Result {3839/**40* If {@link javax.xml.transform.TransformerFactory#getFeature}41* returns true when passed this value as an argument,42* the Transformer supports Result output of this type.43*/44public static final String FEATURE =45"http://javax.xml.transform.sax.SAXResult/feature";4647/**48* Zero-argument default constructor.49*/50public SAXResult() {51}5253/**54* Create a SAXResult that targets a SAX2 {@link org.xml.sax.ContentHandler}.55*56* @param handler Must be a non-null ContentHandler reference.57*/58public SAXResult(ContentHandler handler) {59setHandler(handler);60}6162/**63* Set the target to be a SAX2 {@link org.xml.sax.ContentHandler}.64*65* @param handler Must be a non-null ContentHandler reference.66*/67public void setHandler(ContentHandler handler) {68this.handler = handler;69}7071/**72* Get the {@link org.xml.sax.ContentHandler} that is the Result.73*74* @return The ContentHandler that is to be transformation output.75*/76public ContentHandler getHandler() {77return handler;78}7980/**81* Set the SAX2 {@link org.xml.sax.ext.LexicalHandler} for the output.82*83* <p>This is needed to handle XML comments and the like. If the84* lexical handler is not set, an attempt should be made by the85* transformer to cast the {@link org.xml.sax.ContentHandler} to a86* <code>LexicalHandler</code>.</p>87*88* @param handler A non-null <code>LexicalHandler</code> for89* handling lexical parse events.90*/91public void setLexicalHandler(LexicalHandler handler) {92this.lexhandler = handler;93}9495/**96* Get a SAX2 {@link org.xml.sax.ext.LexicalHandler} for the output.97*98* @return A <code>LexicalHandler</code>, or null.99*/100public LexicalHandler getLexicalHandler() {101return lexhandler;102}103104/**105* Method setSystemId Set the systemID that may be used in association106* with the {@link org.xml.sax.ContentHandler}.107*108* @param systemId The system identifier as a URI string.109*/110public void setSystemId(String systemId) {111this.systemId = systemId;112}113114/**115* Get the system identifier that was set with setSystemId.116*117* @return The system identifier that was set with setSystemId, or null118* if setSystemId was not called.119*/120public String getSystemId() {121return systemId;122}123124//////////////////////////////////////////////////////////////////////125// Internal state.126//////////////////////////////////////////////////////////////////////127128/**129* The handler for parse events.130*/131private ContentHandler handler;132133/**134* The handler for lexical events.135*/136private LexicalHandler lexhandler;137138/**139* The systemID that may be used in association140* with the node.141*/142private String systemId;143}144145146