286N/A/*
286N/A * reserved comment block
286N/A * DO NOT REMOVE OR ALTER!
286N/A */
286N/A/*
286N/A * Copyright 2005 The Apache Software Foundation.
286N/A *
286N/A * Licensed under the Apache License, Version 2.0 (the "License");
286N/A * you may not use this file except in compliance with the License.
286N/A * You may obtain a copy of the License at
286N/A *
286N/A * http://www.apache.org/licenses/LICENSE-2.0
286N/A *
286N/A * Unless required by applicable law or agreed to in writing, software
286N/A * distributed under the License is distributed on an "AS IS" BASIS,
286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
286N/A * See the License for the specific language governing permissions and
286N/A * limitations under the License.
286N/A */
286N/A
286N/Apackage com.sun.org.apache.xerces.internal.util;
286N/A
286N/Aimport java.io.InputStream;
286N/Aimport java.io.Reader;
286N/A
286N/Aimport com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
286N/Aimport org.xml.sax.InputSource;
286N/Aimport org.xml.sax.XMLReader;
286N/A
286N/A/**
286N/A * <p>An <code>XMLInputSource</code> analogue to <code>javax.xml.transform.sax.SAXSource</code>.</p>
286N/A *
286N/A */
286N/Apublic final class SAXInputSource extends XMLInputSource {
286N/A
286N/A private XMLReader fXMLReader;
286N/A private InputSource fInputSource;
286N/A
286N/A public SAXInputSource() {
286N/A this(null);
286N/A }
286N/A
286N/A public SAXInputSource(InputSource inputSource) {
286N/A this(null, inputSource);
286N/A }
286N/A
286N/A public SAXInputSource(XMLReader reader, InputSource inputSource) {
286N/A super(inputSource != null ? inputSource.getPublicId() : null,
286N/A inputSource != null ? inputSource.getSystemId() : null, null);
286N/A if (inputSource != null) {
286N/A setByteStream(inputSource.getByteStream());
286N/A setCharacterStream(inputSource.getCharacterStream());
286N/A setEncoding(inputSource.getEncoding());
286N/A }
286N/A fInputSource = inputSource;
286N/A fXMLReader = reader;
286N/A }
286N/A
286N/A public void setXMLReader(XMLReader reader) {
286N/A fXMLReader = reader;
286N/A }
286N/A
286N/A public XMLReader getXMLReader() {
286N/A return fXMLReader;
286N/A }
286N/A
286N/A public void setInputSource(InputSource inputSource) {
286N/A if (inputSource != null) {
286N/A setPublicId(inputSource.getPublicId());
286N/A setSystemId(inputSource.getSystemId());
286N/A setByteStream(inputSource.getByteStream());
286N/A setCharacterStream(inputSource.getCharacterStream());
286N/A setEncoding(inputSource.getEncoding());
286N/A }
286N/A else {
286N/A setPublicId(null);
286N/A setSystemId(null);
286N/A setByteStream(null);
286N/A setCharacterStream(null);
286N/A setEncoding(null);
286N/A }
286N/A fInputSource = inputSource;
286N/A }
286N/A
286N/A public InputSource getInputSource() {
286N/A return fInputSource;
286N/A }
286N/A
286N/A /**
286N/A * Sets the public identifier.
286N/A *
286N/A * @param publicId The new public identifier.
286N/A */
286N/A public void setPublicId(String publicId) {
286N/A super.setPublicId(publicId);
286N/A if (fInputSource == null) {
286N/A fInputSource = new InputSource();
286N/A }
286N/A fInputSource.setPublicId(publicId);
286N/A } // setPublicId(String)
286N/A
286N/A /**
286N/A * Sets the system identifier.
286N/A *
286N/A * @param systemId The new system identifier.
286N/A */
286N/A public void setSystemId(String systemId) {
286N/A super.setSystemId(systemId);
286N/A if (fInputSource == null) {
286N/A fInputSource = new InputSource();
286N/A }
286N/A fInputSource.setSystemId(systemId);
286N/A } // setSystemId(String)
286N/A
286N/A /**
286N/A * Sets the byte stream. If the byte stream is not already opened
286N/A * when this object is instantiated, then the code that opens the
286N/A * stream should also set the byte stream on this object. Also, if
286N/A * the encoding is auto-detected, then the encoding should also be
286N/A * set on this object.
286N/A *
286N/A * @param byteStream The new byte stream.
286N/A */
286N/A public void setByteStream(InputStream byteStream) {
286N/A super.setByteStream(byteStream);
286N/A if (fInputSource == null) {
286N/A fInputSource = new InputSource();
286N/A }
286N/A fInputSource.setByteStream(byteStream);
286N/A } // setByteStream(InputStream)
286N/A
286N/A /**
286N/A * Sets the character stream. If the character stream is not already
286N/A * opened when this object is instantiated, then the code that opens
286N/A * the stream should also set the character stream on this object.
286N/A * Also, the encoding of the byte stream used by the reader should
286N/A * also be set on this object, if known.
286N/A *
286N/A * @param charStream The new character stream.
286N/A *
286N/A * @see #setEncoding
286N/A */
286N/A public void setCharacterStream(Reader charStream) {
286N/A super.setCharacterStream(charStream);
286N/A if (fInputSource == null) {
286N/A fInputSource = new InputSource();
286N/A }
286N/A fInputSource.setCharacterStream(charStream);
286N/A } // setCharacterStream(Reader)
286N/A
286N/A /**
286N/A * Sets the encoding of the stream.
286N/A *
286N/A * @param encoding The new encoding.
286N/A */
286N/A public void setEncoding(String encoding) {
286N/A super.setEncoding(encoding);
286N/A if (fInputSource == null) {
286N/A fInputSource = new InputSource();
286N/A }
286N/A fInputSource.setEncoding(encoding);
286N/A } // setEncoding(String)
286N/A
286N/A} // SAXInputSource