|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.n3.nanoxml.StdXMLReader
public class StdXMLReader
StdXMLReader reads the data to be parsed.
Field Summary | |
---|---|
private java.io.LineNumberReader |
currentLineReader
The current line-number reader. |
private java.io.PushbackReader |
currentPbReader
The current push-back reader. |
private java.lang.String |
currentPublicID
The current public ID. |
private java.net.URL |
currentSystemID
The current system ID. |
private java.util.Stack |
linereaders
The stack of line-number readers. |
private java.util.Stack |
pbreaders
The stack of push-back readers. |
private java.util.Stack |
publicIds
The stack of public ids. |
private java.util.Stack |
systemIds
The stack of system ids. |
Constructor Summary | |
---|---|
StdXMLReader(java.io.InputStream stream)
Initializes the XML reader. |
|
StdXMLReader(java.io.Reader reader)
Initializes the XML reader. |
|
StdXMLReader(java.lang.String publicID,
java.lang.String systemID)
Initializes the reader from a system and public ID. |
Method Summary | |
---|---|
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(java.lang.String filename)
Creates a new reader using a file as input. |
protected void |
finalize()
Cleans up the object when it's destroyed. |
protected java.lang.String |
getEncoding(java.lang.String str)
Scans the encoding from an <?xml?> tag. |
int |
getLineNr()
Returns the line number of the data in the current stream. |
java.lang.String |
getPublicID()
Returns the current public ID. |
java.lang.String |
getSystemID()
Returns the current system ID. |
java.io.Reader |
openStream(java.lang.String publicID,
java.lang.String systemID)
Opens a stream from a public and system ID. |
char |
read()
Reads a character. |
void |
setPublicID(java.lang.String publicID)
Sets the public ID of the current stream. |
void |
setSystemID(java.lang.String systemID)
Sets the system ID of the current stream. |
void |
startNewStream(java.io.Reader reader)
Starts a new stream from a Java reader. |
protected java.io.Reader |
stream2reader(java.io.InputStream stream,
java.lang.StringBuffer charsRead)
Converts a stream to a reader while detecting the encoding. |
static IXMLReader |
stringReader(java.lang.String str)
Creates a new reader using a string as input. |
void |
unread(char ch)
Pushes the last character read back to the stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.util.Stack pbreaders
private java.util.Stack linereaders
private java.util.Stack systemIds
private java.util.Stack publicIds
private java.io.PushbackReader currentPbReader
private java.io.LineNumberReader currentLineReader
private java.net.URL currentSystemID
private java.lang.String currentPublicID
Constructor Detail |
---|
public StdXMLReader(java.lang.String publicID, java.lang.String systemID) throws java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException
publicID
- the public ID which may be null.systemID
- the non-null system ID.
java.net.MalformedURLException
- if the system ID does not contain a valid URL
java.io.FileNotFoundException
- if the system ID refers to a local file which does not exist
java.io.IOException
- if an error occurred opening the streampublic StdXMLReader(java.io.Reader reader)
reader
- the input for the XML data.public StdXMLReader(java.io.InputStream stream) throws java.io.IOException
stream
- the input for the XML data.
java.io.IOException
- if an I/O error occurredMethod Detail |
---|
public static IXMLReader stringReader(java.lang.String str)
str
- the string containing the XML datapublic static IXMLReader fileReader(java.lang.String filename) throws java.io.FileNotFoundException, java.io.IOException
filename
- the name of the file containing the XML data
java.io.FileNotFoundException
- if the file could not be found
java.io.IOException
- if an I/O error occurredprotected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
protected java.lang.String getEncoding(java.lang.String str)
str
- the first tag in the XML data.
protected java.io.Reader stream2reader(java.io.InputStream stream, java.lang.StringBuffer charsRead) throws java.io.IOException
stream
- the input for the XML data.charsRead
- buffer where to put characters that have been read
java.io.IOException
- if an I/O error occurredpublic char read() throws java.io.IOException
read
in interface IXMLReader
java.io.IOException
- if no character could be readpublic boolean atEOFOfCurrentStream() throws java.io.IOException
atEOFOfCurrentStream
in interface IXMLReader
java.io.IOException
- if an I/O error occurredpublic boolean atEOF() throws java.io.IOException
atEOF
in interface IXMLReader
java.io.IOException
- if an I/O error occurredpublic void unread(char ch) throws java.io.IOException
unread
in interface IXMLReader
ch
- the character to push back
java.io.IOException
- if an I/O error occurredpublic java.io.Reader openStream(java.lang.String publicID, java.lang.String systemID) throws java.net.MalformedURLException, java.io.FileNotFoundException, java.io.IOException
openStream
in interface IXMLReader
publicID
- the public ID, which may be nullsystemID
- the system ID, which is never null
java.net.MalformedURLException
- if the system ID does not contain a valid URL
java.io.FileNotFoundException
- if the system ID refers to a local file which does not
exist
java.io.IOException
- if an error occurred opening the streampublic void startNewStream(java.io.Reader reader)
startNewStream
in interface IXMLReader
reader
- the non-null reader to read the new data frompublic int getLineNr()
getLineNr
in interface IXMLReader
public void setSystemID(java.lang.String systemID) throws java.net.MalformedURLException
setSystemID
in interface IXMLReader
systemID
- the system ID
java.net.MalformedURLException
- if the system ID does not contain a valid URLpublic void setPublicID(java.lang.String publicID)
setPublicID
in interface IXMLReader
publicID
- the public IDpublic java.lang.String getSystemID()
getSystemID
in interface IXMLReader
public java.lang.String getPublicID()
getPublicID
in interface IXMLReader
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |