net.n3.nanoxml
Class StdXMLReader
- IXMLReader
public class StdXMLReader
StdXMLReader reads the data to be parsed.
Version:
- Marc De Scheemaecker
StdXMLReader(InputStream stream) - Initializes the XML reader.
|
StdXMLReader(Reader reader) - Initializes the XML reader.
|
StdXMLReader(String publicID, String systemID) - Initializes the reader from a system and public ID.
|
boolean | atEOF() - Returns true if there are no more characters left to be read.
|
boolean | atEOFOfCurrentStream() - Returns true if the current stream has no more characters left to be
read.
|
static IXMLReader | fileReader(String filename) - Creates a new reader using a file as input.
|
protected void | finalize() - Cleans up the object when it's destroyed.
|
protected String | getEncoding(String str) - Scans the encoding from an <?xml...?> tag.
|
int | getLineNr() - Returns the line number of the data in the current stream.
|
String | getPublicID() - Returns the current public ID.
|
int | getStreamLevel() - Returns the current "level" of the stream on the stack of streams.
|
String | getSystemID() - Returns the current system ID.
|
Reader | openStream(String publicID, String systemID) - Opens a stream from a public and system ID.
|
char | read() - Reads a character.
|
void | setPublicID(String publicID) - Sets the public ID of the current stream.
|
void | setSystemID(String systemID) - Sets the system ID of the current stream.
|
void | startNewStream(Reader reader) - Starts a new stream from a Java reader.
|
void | startNewStream(Reader reader, boolean isInternalEntity) - Starts a new stream from a Java reader.
|
protected Reader | stream2reader(InputStream stream, StringBuffer charsRead) - Converts a stream to a reader while detecting the encoding.
|
static IXMLReader | stringReader(String str) - Creates a new reader using a string as input.
|
void | unread(char ch) - Pushes the last character read back to the stream.
|
StdXMLReader
public StdXMLReader(InputStream stream)
throws IOException
Initializes the XML reader.
stream
- the input for the XML data.
StdXMLReader
public StdXMLReader(Reader reader)
Initializes the XML reader.
reader
- the input for the XML data.
StdXMLReader
public StdXMLReader(String publicID,
String systemID)
throws MalformedURLException,
FileNotFoundException,
IOException
Initializes the reader from a system and public ID.
publicID
- the public ID which may be null.systemID
- the non-null system ID.
atEOF
public boolean atEOF()
throws IOException
Returns true if there are no more characters left to be read.
- atEOF in interface IXMLReader
atEOFOfCurrentStream
public boolean atEOFOfCurrentStream()
throws IOException
Returns true if the current stream has no more characters left to be
read.
- atEOFOfCurrentStream in interface IXMLReader
fileReader
public static IXMLReader fileReader(String filename)
throws FileNotFoundException,
IOException
Creates a new reader using a file as input.
filename
- the name of the file containing the XML data
finalize
protected void finalize()
throws Throwable
Cleans up the object when it's destroyed.
getEncoding
protected String getEncoding(String str)
Scans the encoding from an <?xml...?> tag.
str
- the first tag in the XML data.
- the encoding, or null if no encoding has been specified.
getLineNr
public int getLineNr()
Returns the line number of the data in the current stream.
- getLineNr in interface IXMLReader
getPublicID
public String getPublicID()
Returns the current public ID.
- getPublicID in interface IXMLReader
getStreamLevel
public int getStreamLevel()
Returns the current "level" of the stream on the stack of streams.
- getStreamLevel in interface IXMLReader
getSystemID
public String getSystemID()
Returns the current system ID.
- getSystemID in interface IXMLReader
openStream
public Reader openStream(String publicID,
String systemID)
throws MalformedURLException,
FileNotFoundException,
IOException
Opens a stream from a public and system ID.
- openStream in interface IXMLReader
publicID
- the public ID, which may be nullsystemID
- the system ID, which is never null
read
public char read()
throws IOException
Reads a character.
- read in interface IXMLReader
- the character
setPublicID
public void setPublicID(String publicID)
Sets the public ID of the current stream.
- setPublicID in interface IXMLReader
publicID
- the public ID
setSystemID
public void setSystemID(String systemID)
throws MalformedURLException
Sets the system ID of the current stream.
- setSystemID in interface IXMLReader
systemID
- the system ID
startNewStream
public void startNewStream(Reader reader)
Starts a new stream from a Java reader. The new stream is used
temporary to read data from. If that stream is exhausted, control
returns to the parent stream.
- startNewStream in interface IXMLReader
reader
- the non-null reader to read the new data from
startNewStream
public void startNewStream(Reader reader,
boolean isInternalEntity)
Starts a new stream from a Java reader. The new stream is used
temporary to read data from. If that stream is exhausted, control
returns to the parent stream.
- startNewStream in interface IXMLReader
reader
- the non-null reader to read the new data fromisInternalEntity
- true if the reader is produced by resolving
an internal entity
stream2reader
protected Reader stream2reader(InputStream stream,
StringBuffer charsRead)
throws IOException
Converts a stream to a reader while detecting the encoding.
stream
- the input for the XML data.charsRead
- buffer where to put characters that have been read
stringReader
public static IXMLReader stringReader(String str)
Creates a new reader using a string as input.
str
- the string containing the XML data
unread
public void unread(char ch)
throws IOException
Pushes the last character read back to the stream.
- unread in interface IXMLReader
ch
- the character to push back.