|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectkirk.io.sdl.ESDLReader
This class is able to read ESDL files into SDLDocument
s. To make
things as easy as possible, all you have to do is:
SDLDocument sdldocument = ESDLReader.readESDL(<InputStream>);
(when reading from an InputStream
)
or
SDLDocument sdldocument = ESDLReader.readESDLFile(<filename>);
(when reading from a file).
This also means you cannot instantiate this class yourself. If for some reason you
need to do this, extend this class. The constructor is protected.
Note that the ESDL data must be encoded with UTF-16.
SDLDocument
Field Summary | |
protected int |
position
The position in the file. |
protected BufferedReader |
reader
The Reader the ESDL document is read from. |
Constructor Summary | |
protected |
ESDLReader(InputStream in)
Constructs a new ESDLReader with the given input source to read
from. |
Method Summary | |
protected boolean |
checkEndTag(String tagname)
Reads characters from the current position in the reader until as many as the length of the end tag of the given tag name are read. |
protected boolean |
checkStartTag(String tagname)
Reads characters from the current position in the reader until as many as the length of the start tag of the given tag name are read. |
void |
finalize()
The finalize method. |
protected ESDLReadException |
getException(String error)
Returns an ESDLReadException with the given message, and some
other information, like the place it happened in the file. |
protected char |
read()
Reads and return the next character in the stream. |
protected SDLDataElement |
readDataElement()
Reads the data element at the current position in the file, and the contained value. |
protected SDLElement |
readElement()
Reads the element at the current position in the file, and the contained value. |
static SDLDocument |
readESDL(InputStream in)
Reads the given ESDL source into an ESDL document, and returns that. |
protected SDLDocument |
readESDLDocument()
Reads the ESDL document from the given source and returns it as an SDLDocument object. |
static SDLDocument |
readESDLFile(String filename)
Reads the given ESDL file into an ESDL document, and returns that. |
protected SDLNormalElement |
readNormalElement()
Reads the normal element at the current position in the file, and the contained value. |
private String |
readTagValue(String name)
Return the value inbetween the tag pair (start and end tag) with the given name. |
protected void |
skipWhiteSpaceAndComments()
This method is especially for ESDL. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected BufferedReader reader
Reader
the ESDL document is read from.
protected int position
Constructor Detail |
protected ESDLReader(InputStream in) throws IOException
ESDLReader
with the given input source to read
from. If you wish to read from a file for example, supply a
new FileInputStream("filename")
. The input source should provide
raw byte data, which is converted to characters using UTF-16 encoding.
in
- The InputStream
to be read from.
IOException
- When an IO exception occurs. Mmmyeah.Method Detail |
protected SDLDocument readESDLDocument() throws IOException, ESDLReadException
SDLDocument
object.
SDLDocument
tree with all the ESDL data from the file.
IOException
- When IO errors occur (duh).
SDLReadException
- When the ESDL is not correct.
ESDLReadException
protected SDLElement readElement() throws IOException, ESDLReadException
SDLElement
. The current position
in the file has to be followed by <element> or <data>, or those
with whitespace and/or comments before it.
IOException
- When IO errors occur (duh).
SDLReadException
- When the ESDL is not correct.
ESDLReadException
protected SDLNormalElement readNormalElement() throws IOException, ESDLReadException
SDLDNormalElement
. The
current position in the file has NOT to be followed by <element>. This
has already been made sure in readElement()
. There may be
whitespace and/or comment at the current position as well.
This method will only read until the end of the value.
readElement()
will then check for the end tag.
IOException
- When IO errors occur (duh).
ESDLReadException
- When the ESDL is not correct.protected SDLDataElement readDataElement() throws IOException, ESDLReadException
SDLDataElement
. The current
position in the file has NOT to be followed by <data>. This has already
been made sure in readElement()
. There may be whitespace and/or
comment at the current position as well.
This method will only read until the end of the value.
readElement()
will then check for the end tag.
IOException
- When IO errors occur (duh).
ESDLReadException
- When the ESDL is not correct.private String readTagValue(String name) throws IOException, ESDLReadException
name
- The name of the tag.
IOException
- When IO errors occur (duh).
ESDLReadException
- When the ESDL is not correct.protected void skipWhiteSpaceAndComments() throws IOException, ESDLReadException
IOException
- When IO errors occur (duh).
ESDLReadException
- When comments are not correctly constructed.protected boolean checkStartTag(String tagname) throws IOException, ESDLReadException
tagname
- The tag name that the start tag that should be read of.
IOException
- When IO errors occur (duh).
ESDLReadException
- When the end of the stream is reached during
reading.protected boolean checkEndTag(String tagname) throws IOException, ESDLReadException
tagname
- The tag name that the end tag that should be read of.
IOException
- When IO errors occur (duh).
ESDLReadException
- When the end of the stream is reached during reading.protected char read() throws IOException, ESDLReadException
IOException
- When IO errors occur (duh).
ESDLReadException
- When an end of file is reached.protected ESDLReadException getException(String error)
ESDLReadException
with the given message, and some
other information, like the place it happened in the file.
error
- The error that occured.
ESDLReadException
that signifies the given error.public void finalize()
Object.finalize()
public static SDLDocument readESDLFile(String filename) throws IOException, ESDLReadException
filename
- The ESDL file to be read.
SDLDocument
that was constructed from the data in the
file.
IOException
- When IO errors occur.
ESDLReadException
- When the file is not a correct SDL file.public static SDLDocument readESDL(InputStream in) throws IOException, ESDLReadException
in
- The InputStream
that provides the ESDL to be read.
SDLDocument
that was constructed from the data from
the source.
IOException
- When IO errors occur.
ESDLReadException
- When the data does not make up a correct ESDL file.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |