| java.lang.Object org.apache.xerces.xinclude.XIncludeTextReader
All known Subclasses: org.apache.xerces.xinclude.XInclude11TextReader,
XIncludeTextReader | public class XIncludeTextReader (Code) | | This class is used for reading resources requested in <include> elements,
when the parse attribute of the <include> element is "text". Using this
class will open the location, detect the encoding, and discard the byte order
mark, if applicable.
REVISIT:
Much of the code in this class is taken from XMLEntityManager. It would be nice
if this code could be shared in some way. However, since XMLEntityManager is used
for reading files as XML, and this needs to read files as text, there would need
to be some refactoring done.
author: Michael Glavassevich, IBM author: Peter McCracken, IBM author: Ankit Pasricha, IBM author: Arun Yadav, Sun Microsystems Inc. version: $Id: XIncludeTextReader.java 572046 2007-09-02 17:33:57Z mrglavas $ See Also: XIncludeHandler |
Method Summary | |
public void | close() Closes the stream. | protected String | consumeBOM(InputStream stream, String encoding) Removes the byte order mark from the stream, if
it exists and returns the encoding name. | protected String | getEncodingName(InputStream stream) XMLEntityManager cares about endian-ness, since it creates its own optimized
readers. | protected String | getEncodingName(byte[] b4) REVISIT: This code is taken from org.apache.xerces.impl.XMLEntityManager.
Is there any way we can share the code, without having it implemented twice?
I think we should make it public and static in XMLEntityManager. | protected Reader | getReader(XMLInputSource source) Return the Reader for given XMLInputSource. | protected boolean | isValid(int ch) Returns true if the specified character is a valid XML character
as per the rules of XML 1.0. | public void | parse() Read the input stream as text, and pass the text on to the XIncludeHandler
using calls to characters(). | protected void | setBufferSize(int bufferSize) | public void | setErrorReporter(XMLErrorReporter errorReporter) Sets the XMLErrorReporter used for reporting errors while
reading the text include. | public void | setInputSource(XMLInputSource source) Sets the input source on this text reader. |
XIncludeTextReader | public XIncludeTextReader(XMLInputSource source, XIncludeHandler handler, int bufferSize) throws IOException(Code) | | Construct the XIncludeReader using the XMLInputSource and XIncludeHandler.
Parameters: source - The XMLInputSource to use. Parameters: handler - The XIncludeHandler to use. Parameters: bufferSize - The size of this text reader's buffer. |
close | public void close() throws IOException(Code) | | Closes the stream. Call this after parse(), or when there is no longer any need
for this object.
throws: IOException - |
getEncodingName | protected String getEncodingName(InputStream stream) throws IOException(Code) | | XMLEntityManager cares about endian-ness, since it creates its own optimized
readers. Since we're just using generic Java readers for now, we're not caring
about endian-ness. If this changes, even more code needs to be copied from
XMLEntity manager. -- PJM
|
getEncodingName | protected String getEncodingName(byte[] b4)(Code) | | REVISIT: This code is taken from org.apache.xerces.impl.XMLEntityManager.
Is there any way we can share the code, without having it implemented twice?
I think we should make it public and static in XMLEntityManager. --PJM
Returns the IANA encoding name that is auto-detected from
the bytes specified, with the endian-ness of that encoding where appropriate.
Parameters: b4 - The first four bytes of the input. the encoding name, or null if no encoding could be detected |
isValid | protected boolean isValid(int ch)(Code) | | Returns true if the specified character is a valid XML character
as per the rules of XML 1.0.
Parameters: ch - The character to check. |
parse | public void parse() throws IOException(Code) | | Read the input stream as text, and pass the text on to the XIncludeHandler
using calls to characters(). This will read all of the text it can from the
resource.
throws: IOException - |
setBufferSize | protected void setBufferSize(int bufferSize)(Code) | | Sets the buffer size property for the reader which decides the chunk sizes that are parsed
by the reader at a time and passed to the handler
Parameters: bufferSize - The size of the buffer desired |
setErrorReporter | public void setErrorReporter(XMLErrorReporter errorReporter)(Code) | | Sets the XMLErrorReporter used for reporting errors while
reading the text include.
Parameters: errorReporter - the XMLErrorReporter to be used forreporting errors. |
setInputSource | public void setInputSource(XMLInputSource source)(Code) | | Sets the input source on this text reader.
Parameters: source - The XMLInputSource to use. |
|
|