org.umber.bellows.loader
Class DatumReader

java.lang.Object
  extended byjava.io.Reader
      extended byjava.io.FilterReader
          extended byorg.umber.bellows.loader.DatumReader

public class DatumReader
extends java.io.FilterReader

Reader for converting an XML stream into a Datum object tree. Instantiates one Datum object for every element in the XML document, and sets Datum properties for each XML attribute. Attempts to deal with XML namespaces as best as it can.

Author:
jsheets

Field Summary
 
Fields inherited from class java.io.FilterReader
in
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
DatumReader(java.io.Reader in)
          Creates a new instance of DatumReader.
DatumReader(java.io.Reader in, java.lang.String parserClass)
          Creates a new instance of DatumReader which uses the custom XML parser class.
DatumReader(java.io.Reader in, java.lang.String parserClass, java.lang.String baseURI)
          Creates a new instance of DatumReader which uses the custom XML parser class and the base URI to resolve relative URIs in the XML document.
 
Method Summary
 void close()
           
static Datum fromXml(java.lang.String xml)
          Convenience method to convert an XML string directly into a Datum tree.
 boolean markSupported()
           
 int read()
          Reads one character at a time, until the end of the current XML document.
 int read(char[] buf, int offset, int length)
           
 Datum readXml()
          Reads an XML document from the input Reader and converts it into a Datum tree.
 
Methods inherited from class java.io.FilterReader
mark, ready, reset, skip
 
Methods inherited from class java.io.Reader
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatumReader

public DatumReader(java.io.Reader in)
Creates a new instance of DatumReader.

Parameters:
in - Reader instance to wrap

DatumReader

public DatumReader(java.io.Reader in,
                   java.lang.String parserClass)
Creates a new instance of DatumReader which uses the custom XML parser class.

Parameters:
in - Reader instance to wrap
parserClass - the fully qualified XML parser class

DatumReader

public DatumReader(java.io.Reader in,
                   java.lang.String parserClass,
                   java.lang.String baseURI)
Creates a new instance of DatumReader which uses the custom XML parser class and the base URI to resolve relative URIs in the XML document.

Parameters:
in - Reader instance to wrap
parserClass - the fully qualified XML parser class
baseURI - the base path for resolving relative URIs
Method Detail

readXml

public Datum readXml()
              throws UmberClassException,
                     BellowsIOException,
                     BellowsParseException
Reads an XML document from the input Reader and converts it into a Datum tree.

Returns:
a Datum tree
Throws:
UmberClassException - if unable to find any XML parsers
BellowsParseException - if XML parsing errors occur
BellowsIOException - if I/O errors occur

fromXml

public static Datum fromXml(java.lang.String xml)
                     throws UmberClassException,
                            BellowsIOException,
                            BellowsParseException
Convenience method to convert an XML string directly into a Datum tree.

Parameters:
xml - the input XML in String form
Returns:
the XML Datum tree
Throws:
UmberClassException - if unable to find any XML parsers
BellowsParseException - if XML parsing errors occur
BellowsIOException - if I/O errors occur

read

public int read()
         throws java.io.IOException
Reads one character at a time, until the end of the current XML document. If more than one XML document are sent across the same stream, this reader will return a -1 between each document. When read() returns -1 twice in a row, it has reached the end of the available data.

Returns:
the next character, or -1 if end of stream or XML document
Throws:
java.io.IOException - if an I/O error occurs

read

public int read(char[] buf,
                int offset,
                int length)
         throws java.io.IOException
Throws:
java.io.IOException

markSupported

public boolean markSupported()

close

public void close()
           throws java.io.IOException
Throws:
java.io.IOException