286N/A/*
286N/A * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
286N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
286N/A *
286N/A * This code is free software; you can redistribute it and/or modify it
286N/A * under the terms of the GNU General Public License version 2 only, as
286N/A * published by the Free Software Foundation. Oracle designates this
286N/A * particular file as subject to the "Classpath" exception as provided
286N/A * by Oracle in the LICENSE file that accompanied this code.
286N/A *
286N/A * This code is distributed in the hope that it will be useful, but WITHOUT
286N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
286N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
286N/A * version 2 for more details (a copy is included in the LICENSE file that
286N/A * accompanied this code).
286N/A *
286N/A * You should have received a copy of the GNU General Public License version
286N/A * 2 along with this work; if not, write to the Free Software Foundation,
286N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
286N/A *
286N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
286N/A * or visit www.oracle.com if you need additional information or have any
286N/A * questions.
286N/A */
286N/A
286N/Apackage javax.xml.transform.sax;
286N/A
286N/Aimport javax.xml.transform.Result;
286N/A
286N/Aimport org.xml.sax.ContentHandler;
286N/Aimport org.xml.sax.ext.LexicalHandler;
286N/A
286N/A/**
286N/A * <p>Acts as an holder for a transformation Result.</p>
286N/A *
286N/A * @author <a href="Jeff.Suttor@Sun.com">Jeff Suttor</a>
286N/A */
286N/Apublic class SAXResult implements Result {
286N/A
286N/A /**
286N/A * If {@link javax.xml.transform.TransformerFactory#getFeature}
286N/A * returns true when passed this value as an argument,
286N/A * the Transformer supports Result output of this type.
286N/A */
286N/A public static final String FEATURE =
286N/A "http://javax.xml.transform.sax.SAXResult/feature";
286N/A
286N/A /**
286N/A * Zero-argument default constructor.
286N/A */
286N/A public SAXResult() {
286N/A }
286N/A
286N/A /**
286N/A * Create a SAXResult that targets a SAX2 {@link org.xml.sax.ContentHandler}.
286N/A *
286N/A * @param handler Must be a non-null ContentHandler reference.
286N/A */
286N/A public SAXResult(ContentHandler handler) {
286N/A setHandler(handler);
286N/A }
286N/A
286N/A /**
286N/A * Set the target to be a SAX2 {@link org.xml.sax.ContentHandler}.
286N/A *
286N/A * @param handler Must be a non-null ContentHandler reference.
286N/A */
286N/A public void setHandler(ContentHandler handler) {
286N/A this.handler = handler;
286N/A }
286N/A
286N/A /**
286N/A * Get the {@link org.xml.sax.ContentHandler} that is the Result.
286N/A *
286N/A * @return The ContentHandler that is to be transformation output.
286N/A */
286N/A public ContentHandler getHandler() {
286N/A return handler;
286N/A }
286N/A
286N/A /**
286N/A * Set the SAX2 {@link org.xml.sax.ext.LexicalHandler} for the output.
286N/A *
286N/A * <p>This is needed to handle XML comments and the like. If the
286N/A * lexical handler is not set, an attempt should be made by the
286N/A * transformer to cast the {@link org.xml.sax.ContentHandler} to a
286N/A * <code>LexicalHandler</code>.</p>
286N/A *
286N/A * @param handler A non-null <code>LexicalHandler</code> for
286N/A * handling lexical parse events.
286N/A */
286N/A public void setLexicalHandler(LexicalHandler handler) {
286N/A this.lexhandler = handler;
286N/A }
286N/A
286N/A /**
286N/A * Get a SAX2 {@link org.xml.sax.ext.LexicalHandler} for the output.
286N/A *
286N/A * @return A <code>LexicalHandler</code>, or null.
286N/A */
286N/A public LexicalHandler getLexicalHandler() {
286N/A return lexhandler;
286N/A }
286N/A
286N/A /**
286N/A * Method setSystemId Set the systemID that may be used in association
286N/A * with the {@link org.xml.sax.ContentHandler}.
286N/A *
286N/A * @param systemId The system identifier as a URI string.
286N/A */
286N/A public void setSystemId(String systemId) {
286N/A this.systemId = systemId;
286N/A }
286N/A
286N/A /**
286N/A * Get the system identifier that was set with setSystemId.
286N/A *
286N/A * @return The system identifier that was set with setSystemId, or null
286N/A * if setSystemId was not called.
286N/A */
286N/A public String getSystemId() {
286N/A return systemId;
286N/A }
286N/A
286N/A //////////////////////////////////////////////////////////////////////
286N/A // Internal state.
286N/A //////////////////////////////////////////////////////////////////////
286N/A
286N/A /**
286N/A * The handler for parse events.
286N/A */
286N/A private ContentHandler handler;
286N/A
286N/A /**
286N/A * The handler for lexical events.
286N/A */
286N/A private LexicalHandler lexhandler;
286N/A
286N/A /**
286N/A * The systemID that may be used in association
286N/A * with the node.
286N/A */
286N/A private String systemId;
286N/A}