286N/A/*
286N/A * reserved comment block
286N/A * DO NOT REMOVE OR ALTER!
286N/A */
286N/A/*
286N/A * Copyright 2000-2002,2004 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.xni.parser;
286N/A
286N/Aimport com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
286N/A
286N/Aimport java.io.InputStream;
286N/Aimport java.io.Reader;
286N/A
286N/A/**
286N/A * This class represents an input source for an XML document. The
286N/A * basic properties of an input source are the following:
286N/A * <ul>
286N/A * <li>public identifier</li>
286N/A * <li>system identifier</li>
286N/A * <li>byte stream or character stream</li>
286N/A * <li>
286N/A * </ul>
286N/A *
286N/A * @author Andy Clark, IBM
286N/A *
286N/A */
286N/Apublic class XMLInputSource {
286N/A
286N/A //
286N/A // Data
286N/A //
286N/A
286N/A /** Public identifier. */
286N/A protected String fPublicId;
286N/A
286N/A /** System identifier. */
286N/A protected String fSystemId;
286N/A
286N/A /** Base system identifier. */
286N/A protected String fBaseSystemId;
286N/A
286N/A /** Byte stream. */
286N/A protected InputStream fByteStream;
286N/A
286N/A /** Character stream. */
286N/A protected Reader fCharStream;
286N/A
286N/A /** Encoding. */
286N/A protected String fEncoding;
286N/A
286N/A //
286N/A // Constructors
286N/A //
286N/A
286N/A /**
286N/A * Constructs an input source from just the public and system
286N/A * identifiers, leaving resolution of the entity and opening of
286N/A * the input stream up to the caller.
286N/A *
286N/A * @param publicId The public identifier, if known.
286N/A * @param systemId The system identifier. This value should
286N/A * always be set, if possible, and can be
286N/A * relative or absolute. If the system identifier
286N/A * is relative, then the base system identifier
286N/A * should be set.
286N/A * @param baseSystemId The base system identifier. This value should
286N/A * always be set to the fully expanded URI of the
286N/A * base system identifier, if possible.
286N/A */
286N/A public XMLInputSource(String publicId, String systemId,
286N/A String baseSystemId) {
286N/A fPublicId = publicId;
286N/A fSystemId = systemId;
286N/A fBaseSystemId = baseSystemId;
286N/A } // <init>(String,String,String)
286N/A
286N/A /**
286N/A * Constructs an input source from a XMLResourceIdentifier
286N/A * object, leaving resolution of the entity and opening of
286N/A * the input stream up to the caller.
286N/A *
286N/A * @param resourceIdentifier the XMLResourceIdentifier containing the information
286N/A */
286N/A public XMLInputSource(XMLResourceIdentifier resourceIdentifier) {
286N/A
286N/A fPublicId = resourceIdentifier.getPublicId();
286N/A fSystemId = resourceIdentifier.getLiteralSystemId();
286N/A fBaseSystemId = resourceIdentifier.getBaseSystemId();
286N/A } // <init>(XMLResourceIdentifier)
286N/A
286N/A /**
286N/A * Constructs an input source from a byte stream.
286N/A *
286N/A * @param publicId The public identifier, if known.
286N/A * @param systemId The system identifier. This value should
286N/A * always be set, if possible, and can be
286N/A * relative or absolute. If the system identifier
286N/A * is relative, then the base system identifier
286N/A * should be set.
286N/A * @param baseSystemId The base system identifier. This value should
286N/A * always be set to the fully expanded URI of the
286N/A * base system identifier, if possible.
286N/A * @param byteStream The byte stream.
286N/A * @param encoding The encoding of the byte stream, if known.
286N/A */
286N/A public XMLInputSource(String publicId, String systemId,
286N/A String baseSystemId, InputStream byteStream,
286N/A String encoding) {
286N/A fPublicId = publicId;
286N/A fSystemId = systemId;
286N/A fBaseSystemId = baseSystemId;
286N/A fByteStream = byteStream;
286N/A fEncoding = encoding;
286N/A } // <init>(String,String,String,InputStream,String)
286N/A
286N/A /**
286N/A * Constructs an input source from a character stream.
286N/A *
286N/A * @param publicId The public identifier, if known.
286N/A * @param systemId The system identifier. This value should
286N/A * always be set, if possible, and can be
286N/A * relative or absolute. If the system identifier
286N/A * is relative, then the base system identifier
286N/A * should be set.
286N/A * @param baseSystemId The base system identifier. This value should
286N/A * always be set to the fully expanded URI of the
286N/A * base system identifier, if possible.
286N/A * @param charStream The character stream.
286N/A * @param encoding The original encoding of the byte stream
286N/A * used by the reader, if known.
286N/A */
286N/A public XMLInputSource(String publicId, String systemId,
286N/A String baseSystemId, Reader charStream,
286N/A String encoding) {
286N/A fPublicId = publicId;
286N/A fSystemId = systemId;
286N/A fBaseSystemId = baseSystemId;
286N/A fCharStream = charStream;
286N/A fEncoding = encoding;
286N/A } // <init>(String,String,String,Reader,String)
286N/A
286N/A //
286N/A // Public methods
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 fPublicId = publicId;
286N/A } // setPublicId(String)
286N/A
286N/A /** Returns the public identifier. */
286N/A public String getPublicId() {
286N/A return fPublicId;
286N/A } // getPublicId():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 fSystemId = systemId;
286N/A } // setSystemId(String)
286N/A
286N/A /** Returns the system identifier. */
286N/A public String getSystemId() {
286N/A return fSystemId;
286N/A } // getSystemId():String
286N/A
286N/A /**
286N/A * Sets the base system identifier.
286N/A *
286N/A * @param baseSystemId The new base system identifier.
286N/A */
286N/A public void setBaseSystemId(String baseSystemId) {
286N/A fBaseSystemId = baseSystemId;
286N/A } // setBaseSystemId(String)
286N/A
286N/A /** Returns the base system identifier. */
286N/A public String getBaseSystemId() {
286N/A return fBaseSystemId;
286N/A } // getBaseSystemId():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 fByteStream = byteStream;
286N/A } // setByteStream(InputSource)
286N/A
286N/A /** Returns the byte stream. */
286N/A public InputStream getByteStream() {
286N/A return fByteStream;
286N/A } // getByteStream():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 fCharStream = charStream;
286N/A } // setCharacterStream(Reader)
286N/A
286N/A /** Returns the character stream. */
286N/A public Reader getCharacterStream() {
286N/A return fCharStream;
286N/A } // getCharacterStream():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 fEncoding = encoding;
286N/A } // setEncoding(String)
286N/A
286N/A /** Returns the encoding of the stream, or null if not known. */
286N/A public String getEncoding() {
286N/A return fEncoding;
286N/A } // getEncoding():String
286N/A
286N/A} // class XMLInputSource