jaxp/src/share/classes/org/xml/sax/InputSource.java
author kvn
Fri, 20 Jun 2008 11:10:05 -0700
changeset 762 1b26adb5fea1
parent 6 7f561c08de6b
permissions -rw-r--r--
6715633: when matching a memory node the adr_type should not change Summary: verify the adr_type of a mach node was not changed Reviewed-by: rasbold, never
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
     2
 * Copyright 2000-2005 Sun Microsystems, Inc.  All Rights Reserved.
7f561c08de6b Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7f561c08de6b Initial load
duke
parents:
diff changeset
     4
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
7f561c08de6b Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
7f561c08de6b Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
7f561c08de6b Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
7f561c08de6b Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
7f561c08de6b Initial load
duke
parents:
diff changeset
    10
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
7f561c08de6b Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7f561c08de6b Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7f561c08de6b Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
7f561c08de6b Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
7f561c08de6b Initial load
duke
parents:
diff changeset
    16
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
7f561c08de6b Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
7f561c08de6b Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7f561c08de6b Initial load
duke
parents:
diff changeset
    20
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
7f561c08de6b Initial load
duke
parents:
diff changeset
    23
 * have any questions.
7f561c08de6b Initial load
duke
parents:
diff changeset
    24
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    25
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
// SAX input source.
7f561c08de6b Initial load
duke
parents:
diff changeset
    27
// http://www.saxproject.org
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
// No warranty; no copyright -- use this as you will.
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
// $Id: InputSource.java,v 1.2 2004/11/03 22:55:32 jsuttor Exp $
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
package org.xml.sax;
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
import java.io.Reader;
7f561c08de6b Initial load
duke
parents:
diff changeset
    34
import java.io.InputStream;
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
 * A single input source for an XML entity.
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
 * <blockquote>
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
 * <em>This module, both source code and documentation, is in the
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
 * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
 * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
 * for further information.
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
 * </blockquote>
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
 * <p>This class allows a SAX application to encapsulate information
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
 * about an input source in a single object, which may include
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
 * a public identifier, a system identifier, a byte stream (possibly
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
 * with a specified encoding), and/or a character stream.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    50
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    51
 * <p>There are two places that the application can deliver an
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
 * input source to the parser: as the argument to the Parser.parse
7f561c08de6b Initial load
duke
parents:
diff changeset
    53
 * method, or as the return value of the EntityResolver.resolveEntity
7f561c08de6b Initial load
duke
parents:
diff changeset
    54
 * method.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
 * <p>The SAX parser will use the InputSource object to determine how
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
 * to read XML input.  If there is a character stream available, the
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
 * parser will read that stream directly, disregarding any text
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
 * encoding declaration found in that stream.
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
 * If there is no character stream, but there is
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
 * a byte stream, the parser will use that byte stream, using the
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
 * encoding specified in the InputSource or else (if no encoding is
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
 * specified) autodetecting the character encoding using an algorithm
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
 * such as the one in the XML specification.  If neither a character
7f561c08de6b Initial load
duke
parents:
diff changeset
    65
 * stream nor a
7f561c08de6b Initial load
duke
parents:
diff changeset
    66
 * byte stream is available, the parser will attempt to open a URI
7f561c08de6b Initial load
duke
parents:
diff changeset
    67
 * connection to the resource identified by the system
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
 * identifier.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
 * <p>An InputSource object belongs to the application: the SAX parser
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
 * shall never modify it in any way (it may modify a copy if
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
 * necessary).  However, standard processing of both byte and
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
 * character streams is to close them on as part of end-of-parse cleanup,
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
 * so applications should not attempt to re-use such streams after they
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
 * have been handed to a parser.  </p>
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    77
 * @since SAX 1.0
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
 * @author David Megginson
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
 * @see org.xml.sax.XMLReader#parse(org.xml.sax.InputSource)
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
 * @see org.xml.sax.EntityResolver#resolveEntity
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
 * @see java.io.InputStream
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
 * @see java.io.Reader
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
public class InputSource {
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    87
     * Zero-argument default constructor.
7f561c08de6b Initial load
duke
parents:
diff changeset
    88
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
    89
     * @see #setPublicId
7f561c08de6b Initial load
duke
parents:
diff changeset
    90
     * @see #setSystemId
7f561c08de6b Initial load
duke
parents:
diff changeset
    91
     * @see #setByteStream
7f561c08de6b Initial load
duke
parents:
diff changeset
    92
     * @see #setCharacterStream
7f561c08de6b Initial load
duke
parents:
diff changeset
    93
     * @see #setEncoding
7f561c08de6b Initial load
duke
parents:
diff changeset
    94
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
    public InputSource ()
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
    97
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    98
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
7f561c08de6b Initial load
duke
parents:
diff changeset
   100
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
     * Create a new input source with a system identifier.
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   103
     * <p>Applications may use setPublicId to include a
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
     * public identifier as well, or setEncoding to specify
7f561c08de6b Initial load
duke
parents:
diff changeset
   105
     * the character encoding, if known.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   107
     * <p>If the system identifier is a URL, it must be fully
7f561c08de6b Initial load
duke
parents:
diff changeset
   108
     * resolved (it may not be a relative URL).</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   109
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   110
     * @param systemId The system identifier (URI).
7f561c08de6b Initial load
duke
parents:
diff changeset
   111
     * @see #setPublicId
7f561c08de6b Initial load
duke
parents:
diff changeset
   112
     * @see #setSystemId
7f561c08de6b Initial load
duke
parents:
diff changeset
   113
     * @see #setByteStream
7f561c08de6b Initial load
duke
parents:
diff changeset
   114
     * @see #setEncoding
7f561c08de6b Initial load
duke
parents:
diff changeset
   115
     * @see #setCharacterStream
7f561c08de6b Initial load
duke
parents:
diff changeset
   116
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   117
    public InputSource (String systemId)
7f561c08de6b Initial load
duke
parents:
diff changeset
   118
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   119
        setSystemId(systemId);
7f561c08de6b Initial load
duke
parents:
diff changeset
   120
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   121
7f561c08de6b Initial load
duke
parents:
diff changeset
   122
7f561c08de6b Initial load
duke
parents:
diff changeset
   123
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   124
     * Create a new input source with a byte stream.
7f561c08de6b Initial load
duke
parents:
diff changeset
   125
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   126
     * <p>Application writers should use setSystemId() to provide a base
7f561c08de6b Initial load
duke
parents:
diff changeset
   127
     * for resolving relative URIs, may use setPublicId to include a
7f561c08de6b Initial load
duke
parents:
diff changeset
   128
     * public identifier, and may use setEncoding to specify the object's
7f561c08de6b Initial load
duke
parents:
diff changeset
   129
     * character encoding.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   130
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   131
     * @param byteStream The raw byte stream containing the document.
7f561c08de6b Initial load
duke
parents:
diff changeset
   132
     * @see #setPublicId
7f561c08de6b Initial load
duke
parents:
diff changeset
   133
     * @see #setSystemId
7f561c08de6b Initial load
duke
parents:
diff changeset
   134
     * @see #setEncoding
7f561c08de6b Initial load
duke
parents:
diff changeset
   135
     * @see #setByteStream
7f561c08de6b Initial load
duke
parents:
diff changeset
   136
     * @see #setCharacterStream
7f561c08de6b Initial load
duke
parents:
diff changeset
   137
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   138
    public InputSource (InputStream byteStream)
7f561c08de6b Initial load
duke
parents:
diff changeset
   139
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   140
        setByteStream(byteStream);
7f561c08de6b Initial load
duke
parents:
diff changeset
   141
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   142
7f561c08de6b Initial load
duke
parents:
diff changeset
   143
7f561c08de6b Initial load
duke
parents:
diff changeset
   144
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   145
     * Create a new input source with a character stream.
7f561c08de6b Initial load
duke
parents:
diff changeset
   146
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   147
     * <p>Application writers should use setSystemId() to provide a base
7f561c08de6b Initial load
duke
parents:
diff changeset
   148
     * for resolving relative URIs, and may use setPublicId to include a
7f561c08de6b Initial load
duke
parents:
diff changeset
   149
     * public identifier.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   150
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   151
     * <p>The character stream shall not include a byte order mark.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   152
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   153
     * @see #setPublicId
7f561c08de6b Initial load
duke
parents:
diff changeset
   154
     * @see #setSystemId
7f561c08de6b Initial load
duke
parents:
diff changeset
   155
     * @see #setByteStream
7f561c08de6b Initial load
duke
parents:
diff changeset
   156
     * @see #setCharacterStream
7f561c08de6b Initial load
duke
parents:
diff changeset
   157
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   158
    public InputSource (Reader characterStream)
7f561c08de6b Initial load
duke
parents:
diff changeset
   159
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   160
        setCharacterStream(characterStream);
7f561c08de6b Initial load
duke
parents:
diff changeset
   161
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   162
7f561c08de6b Initial load
duke
parents:
diff changeset
   163
7f561c08de6b Initial load
duke
parents:
diff changeset
   164
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   165
     * Set the public identifier for this input source.
7f561c08de6b Initial load
duke
parents:
diff changeset
   166
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   167
     * <p>The public identifier is always optional: if the application
7f561c08de6b Initial load
duke
parents:
diff changeset
   168
     * writer includes one, it will be provided as part of the
7f561c08de6b Initial load
duke
parents:
diff changeset
   169
     * location information.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   170
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   171
     * @param publicId The public identifier as a string.
7f561c08de6b Initial load
duke
parents:
diff changeset
   172
     * @see #getPublicId
7f561c08de6b Initial load
duke
parents:
diff changeset
   173
     * @see org.xml.sax.Locator#getPublicId
7f561c08de6b Initial load
duke
parents:
diff changeset
   174
     * @see org.xml.sax.SAXParseException#getPublicId
7f561c08de6b Initial load
duke
parents:
diff changeset
   175
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   176
    public void setPublicId (String publicId)
7f561c08de6b Initial load
duke
parents:
diff changeset
   177
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   178
        this.publicId = publicId;
7f561c08de6b Initial load
duke
parents:
diff changeset
   179
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   180
7f561c08de6b Initial load
duke
parents:
diff changeset
   181
7f561c08de6b Initial load
duke
parents:
diff changeset
   182
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   183
     * Get the public identifier for this input source.
7f561c08de6b Initial load
duke
parents:
diff changeset
   184
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   185
     * @return The public identifier, or null if none was supplied.
7f561c08de6b Initial load
duke
parents:
diff changeset
   186
     * @see #setPublicId
7f561c08de6b Initial load
duke
parents:
diff changeset
   187
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   188
    public String getPublicId ()
7f561c08de6b Initial load
duke
parents:
diff changeset
   189
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   190
        return publicId;
7f561c08de6b Initial load
duke
parents:
diff changeset
   191
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   192
7f561c08de6b Initial load
duke
parents:
diff changeset
   193
7f561c08de6b Initial load
duke
parents:
diff changeset
   194
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   195
     * Set the system identifier for this input source.
7f561c08de6b Initial load
duke
parents:
diff changeset
   196
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   197
     * <p>The system identifier is optional if there is a byte stream
7f561c08de6b Initial load
duke
parents:
diff changeset
   198
     * or a character stream, but it is still useful to provide one,
7f561c08de6b Initial load
duke
parents:
diff changeset
   199
     * since the application can use it to resolve relative URIs
7f561c08de6b Initial load
duke
parents:
diff changeset
   200
     * and can include it in error messages and warnings (the parser
7f561c08de6b Initial load
duke
parents:
diff changeset
   201
     * will attempt to open a connection to the URI only if
7f561c08de6b Initial load
duke
parents:
diff changeset
   202
     * there is no byte stream or character stream specified).</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   203
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   204
     * <p>If the application knows the character encoding of the
7f561c08de6b Initial load
duke
parents:
diff changeset
   205
     * object pointed to by the system identifier, it can register
7f561c08de6b Initial load
duke
parents:
diff changeset
   206
     * the encoding using the setEncoding method.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   207
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   208
     * <p>If the system identifier is a URL, it must be fully
7f561c08de6b Initial load
duke
parents:
diff changeset
   209
     * resolved (it may not be a relative URL).</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   210
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   211
     * @param systemId The system identifier as a string.
7f561c08de6b Initial load
duke
parents:
diff changeset
   212
     * @see #setEncoding
7f561c08de6b Initial load
duke
parents:
diff changeset
   213
     * @see #getSystemId
7f561c08de6b Initial load
duke
parents:
diff changeset
   214
     * @see org.xml.sax.Locator#getSystemId
7f561c08de6b Initial load
duke
parents:
diff changeset
   215
     * @see org.xml.sax.SAXParseException#getSystemId
7f561c08de6b Initial load
duke
parents:
diff changeset
   216
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   217
    public void setSystemId (String systemId)
7f561c08de6b Initial load
duke
parents:
diff changeset
   218
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   219
        this.systemId = systemId;
7f561c08de6b Initial load
duke
parents:
diff changeset
   220
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   221
7f561c08de6b Initial load
duke
parents:
diff changeset
   222
7f561c08de6b Initial load
duke
parents:
diff changeset
   223
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   224
     * Get the system identifier for this input source.
7f561c08de6b Initial load
duke
parents:
diff changeset
   225
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   226
     * <p>The getEncoding method will return the character encoding
7f561c08de6b Initial load
duke
parents:
diff changeset
   227
     * of the object pointed to, or null if unknown.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   228
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   229
     * <p>If the system ID is a URL, it will be fully resolved.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   230
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   231
     * @return The system identifier, or null if none was supplied.
7f561c08de6b Initial load
duke
parents:
diff changeset
   232
     * @see #setSystemId
7f561c08de6b Initial load
duke
parents:
diff changeset
   233
     * @see #getEncoding
7f561c08de6b Initial load
duke
parents:
diff changeset
   234
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   235
    public String getSystemId ()
7f561c08de6b Initial load
duke
parents:
diff changeset
   236
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   237
        return systemId;
7f561c08de6b Initial load
duke
parents:
diff changeset
   238
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   239
7f561c08de6b Initial load
duke
parents:
diff changeset
   240
7f561c08de6b Initial load
duke
parents:
diff changeset
   241
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   242
     * Set the byte stream for this input source.
7f561c08de6b Initial load
duke
parents:
diff changeset
   243
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   244
     * <p>The SAX parser will ignore this if there is also a character
7f561c08de6b Initial load
duke
parents:
diff changeset
   245
     * stream specified, but it will use a byte stream in preference
7f561c08de6b Initial load
duke
parents:
diff changeset
   246
     * to opening a URI connection itself.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   247
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   248
     * <p>If the application knows the character encoding of the
7f561c08de6b Initial load
duke
parents:
diff changeset
   249
     * byte stream, it should set it with the setEncoding method.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   250
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   251
     * @param byteStream A byte stream containing an XML document or
7f561c08de6b Initial load
duke
parents:
diff changeset
   252
     *        other entity.
7f561c08de6b Initial load
duke
parents:
diff changeset
   253
     * @see #setEncoding
7f561c08de6b Initial load
duke
parents:
diff changeset
   254
     * @see #getByteStream
7f561c08de6b Initial load
duke
parents:
diff changeset
   255
     * @see #getEncoding
7f561c08de6b Initial load
duke
parents:
diff changeset
   256
     * @see java.io.InputStream
7f561c08de6b Initial load
duke
parents:
diff changeset
   257
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   258
    public void setByteStream (InputStream byteStream)
7f561c08de6b Initial load
duke
parents:
diff changeset
   259
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   260
        this.byteStream = byteStream;
7f561c08de6b Initial load
duke
parents:
diff changeset
   261
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   262
7f561c08de6b Initial load
duke
parents:
diff changeset
   263
7f561c08de6b Initial load
duke
parents:
diff changeset
   264
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   265
     * Get the byte stream for this input source.
7f561c08de6b Initial load
duke
parents:
diff changeset
   266
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   267
     * <p>The getEncoding method will return the character
7f561c08de6b Initial load
duke
parents:
diff changeset
   268
     * encoding for this byte stream, or null if unknown.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   269
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   270
     * @return The byte stream, or null if none was supplied.
7f561c08de6b Initial load
duke
parents:
diff changeset
   271
     * @see #getEncoding
7f561c08de6b Initial load
duke
parents:
diff changeset
   272
     * @see #setByteStream
7f561c08de6b Initial load
duke
parents:
diff changeset
   273
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   274
    public InputStream getByteStream ()
7f561c08de6b Initial load
duke
parents:
diff changeset
   275
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   276
        return byteStream;
7f561c08de6b Initial load
duke
parents:
diff changeset
   277
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   278
7f561c08de6b Initial load
duke
parents:
diff changeset
   279
7f561c08de6b Initial load
duke
parents:
diff changeset
   280
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   281
     * Set the character encoding, if known.
7f561c08de6b Initial load
duke
parents:
diff changeset
   282
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   283
     * <p>The encoding must be a string acceptable for an
7f561c08de6b Initial load
duke
parents:
diff changeset
   284
     * XML encoding declaration (see section 4.3.3 of the XML 1.0
7f561c08de6b Initial load
duke
parents:
diff changeset
   285
     * recommendation).</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   286
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   287
     * <p>This method has no effect when the application provides a
7f561c08de6b Initial load
duke
parents:
diff changeset
   288
     * character stream.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   289
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   290
     * @param encoding A string describing the character encoding.
7f561c08de6b Initial load
duke
parents:
diff changeset
   291
     * @see #setSystemId
7f561c08de6b Initial load
duke
parents:
diff changeset
   292
     * @see #setByteStream
7f561c08de6b Initial load
duke
parents:
diff changeset
   293
     * @see #getEncoding
7f561c08de6b Initial load
duke
parents:
diff changeset
   294
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   295
    public void setEncoding (String encoding)
7f561c08de6b Initial load
duke
parents:
diff changeset
   296
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   297
        this.encoding = encoding;
7f561c08de6b Initial load
duke
parents:
diff changeset
   298
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   299
7f561c08de6b Initial load
duke
parents:
diff changeset
   300
7f561c08de6b Initial load
duke
parents:
diff changeset
   301
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   302
     * Get the character encoding for a byte stream or URI.
7f561c08de6b Initial load
duke
parents:
diff changeset
   303
     * This value will be ignored when the application provides a
7f561c08de6b Initial load
duke
parents:
diff changeset
   304
     * character stream.
7f561c08de6b Initial load
duke
parents:
diff changeset
   305
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   306
     * @return The encoding, or null if none was supplied.
7f561c08de6b Initial load
duke
parents:
diff changeset
   307
     * @see #setByteStream
7f561c08de6b Initial load
duke
parents:
diff changeset
   308
     * @see #getSystemId
7f561c08de6b Initial load
duke
parents:
diff changeset
   309
     * @see #getByteStream
7f561c08de6b Initial load
duke
parents:
diff changeset
   310
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   311
    public String getEncoding ()
7f561c08de6b Initial load
duke
parents:
diff changeset
   312
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   313
        return encoding;
7f561c08de6b Initial load
duke
parents:
diff changeset
   314
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   315
7f561c08de6b Initial load
duke
parents:
diff changeset
   316
7f561c08de6b Initial load
duke
parents:
diff changeset
   317
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   318
     * Set the character stream for this input source.
7f561c08de6b Initial load
duke
parents:
diff changeset
   319
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   320
     * <p>If there is a character stream specified, the SAX parser
7f561c08de6b Initial load
duke
parents:
diff changeset
   321
     * will ignore any byte stream and will not attempt to open
7f561c08de6b Initial load
duke
parents:
diff changeset
   322
     * a URI connection to the system identifier.</p>
7f561c08de6b Initial load
duke
parents:
diff changeset
   323
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   324
     * @param characterStream The character stream containing the
7f561c08de6b Initial load
duke
parents:
diff changeset
   325
     *        XML document or other entity.
7f561c08de6b Initial load
duke
parents:
diff changeset
   326
     * @see #getCharacterStream
7f561c08de6b Initial load
duke
parents:
diff changeset
   327
     * @see java.io.Reader
7f561c08de6b Initial load
duke
parents:
diff changeset
   328
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   329
    public void setCharacterStream (Reader characterStream)
7f561c08de6b Initial load
duke
parents:
diff changeset
   330
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   331
        this.characterStream = characterStream;
7f561c08de6b Initial load
duke
parents:
diff changeset
   332
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   333
7f561c08de6b Initial load
duke
parents:
diff changeset
   334
7f561c08de6b Initial load
duke
parents:
diff changeset
   335
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   336
     * Get the character stream for this input source.
7f561c08de6b Initial load
duke
parents:
diff changeset
   337
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   338
     * @return The character stream, or null if none was supplied.
7f561c08de6b Initial load
duke
parents:
diff changeset
   339
     * @see #setCharacterStream
7f561c08de6b Initial load
duke
parents:
diff changeset
   340
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   341
    public Reader getCharacterStream ()
7f561c08de6b Initial load
duke
parents:
diff changeset
   342
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   343
        return characterStream;
7f561c08de6b Initial load
duke
parents:
diff changeset
   344
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   345
7f561c08de6b Initial load
duke
parents:
diff changeset
   346
7f561c08de6b Initial load
duke
parents:
diff changeset
   347
7f561c08de6b Initial load
duke
parents:
diff changeset
   348
    ////////////////////////////////////////////////////////////////////
7f561c08de6b Initial load
duke
parents:
diff changeset
   349
    // Internal state.
7f561c08de6b Initial load
duke
parents:
diff changeset
   350
    ////////////////////////////////////////////////////////////////////
7f561c08de6b Initial load
duke
parents:
diff changeset
   351
7f561c08de6b Initial load
duke
parents:
diff changeset
   352
    private String publicId;
7f561c08de6b Initial load
duke
parents:
diff changeset
   353
    private String systemId;
7f561c08de6b Initial load
duke
parents:
diff changeset
   354
    private InputStream byteStream;
7f561c08de6b Initial load
duke
parents:
diff changeset
   355
    private String encoding;
7f561c08de6b Initial load
duke
parents:
diff changeset
   356
    private Reader characterStream;
7f561c08de6b Initial load
duke
parents:
diff changeset
   357
7f561c08de6b Initial load
duke
parents:
diff changeset
   358
}
7f561c08de6b Initial load
duke
parents:
diff changeset
   359
7f561c08de6b Initial load
duke
parents:
diff changeset
   360
// end of InputSource.java