com.myjavatools.xml
Class XmlReader

java.lang.Object
  extended by com.myjavatools.xml.XmlReader

public class XmlReader
extends java.lang.Object


Nested Class Summary
protected  class XmlReader.Handler
           
protected static interface XmlReader.ParserFactory
           
protected static class XmlReader.SAX1ParserFactory
           
protected static class XmlReader.SAX2ParserFactory
           
 
Field Summary
protected  BasicXmlData curElement
           
protected static XmlReader.ParserFactory factory
           
protected  XmlReader.Handler handler
           
protected  BasicXmlData lastElement
           
protected static XmlReader.ParserFactory[] parserPlant
           
protected static org.xml.sax.Parser SAX_parser
           
protected  org.xml.sax.InputSource src
           
 
Constructor Summary
XmlReader(java.io.File file)
          Creates an XmlReader to read from a file.
XmlReader(java.io.InputStream in)
          Creates an XmlReader from an input stream.
XmlReader(java.io.Reader in)
          Creates an XmlReader from a Reader
XmlReader(java.lang.String filename)
          Creates an XmlReader to read from a file.
 
Method Summary
 BasicXmlData read()
          Reads the whole XML contents into XmlData
static BasicXmlData read(java.io.File in)
          Reads the whole XML contents into XmlData
static BasicXmlData read(java.io.InputStream in)
          Reads the whole XML contents into XmlData
static BasicXmlData read(java.io.Reader in)
          Reads the whole XML contents into XmlData
static BasicXmlData readFromString(java.lang.String s)
          Reads the whole XML contents into XmlData
 boolean ready()
          Tells whether input is ready to be read.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parserPlant

protected static XmlReader.ParserFactory[] parserPlant

factory

protected static XmlReader.ParserFactory factory

src

protected org.xml.sax.InputSource src

SAX_parser

protected static org.xml.sax.Parser SAX_parser

curElement

protected BasicXmlData curElement

lastElement

protected BasicXmlData lastElement

handler

protected XmlReader.Handler handler
Constructor Detail

XmlReader

public XmlReader(java.io.Reader in)
          throws java.io.IOException,
                 java.lang.InstantiationException
Creates an XmlReader from a Reader

Parameters:
in - the reader to read data from
Throws:
java.io.IOException
java.lang.InstantiationException

XmlReader

public XmlReader(java.io.InputStream in)
          throws java.io.UnsupportedEncodingException,
                 java.io.IOException,
                 java.lang.InstantiationException
Creates an XmlReader from an input stream. Encoding defaults to UTF-8.

Parameters:
in - the stream to read data from
Throws:
java.io.UnsupportedEncodingException
java.io.IOException
java.lang.InstantiationException

XmlReader

public XmlReader(java.io.File file)
          throws java.io.UnsupportedEncodingException,
                 java.io.IOException,
                 java.lang.InstantiationException
Creates an XmlReader to read from a file. Encoding defaults to UTF-8.

Parameters:
file - the file to read data from
Throws:
java.io.UnsupportedEncodingException
java.io.IOException
java.lang.InstantiationException

XmlReader

public XmlReader(java.lang.String filename)
          throws java.io.UnsupportedEncodingException,
                 java.io.IOException,
                 java.lang.InstantiationException
Creates an XmlReader to read from a file. Encoding defaults to UTF-8.

Parameters:
filename - the name of the file to read data from
Throws:
java.io.UnsupportedEncodingException
java.io.IOException
java.lang.InstantiationException
Method Detail

ready

public boolean ready()
              throws java.io.IOException
Tells whether input is ready to be read.

Returns:
true if the next read() is guaranteed not to block for input, false otherwise. Note that returning false does not guarantee that the next read will block.
Throws:
java.io.IOException - if an I/O error occurs.

read

public BasicXmlData read()
                  throws java.io.IOException
Reads the whole XML contents into XmlData

Returns:
XmlData obtained from input source.
Throws:
java.io.IOException - if an I/O error occurs.

read

public static BasicXmlData read(java.io.InputStream in)
                         throws java.io.IOException,
                                java.lang.InstantiationException
Reads the whole XML contents into XmlData

Parameters:
in - the stream to read data from
Returns:
XmlData obtained from input source.
Throws:
java.io.IOException - if an I/O error occurs.
java.lang.InstantiationException - if there are problems instantiating XmlData

read

public static BasicXmlData read(java.io.File in)
                         throws java.io.IOException,
                                java.lang.InstantiationException
Reads the whole XML contents into XmlData

Parameters:
in - the file to read data from
Returns:
XmlData obtained from input source.
Throws:
java.io.IOException - if an I/O error occurs.
java.lang.InstantiationException - if there are problems instantiating XmlData

read

public static BasicXmlData read(java.io.Reader in)
                         throws java.io.IOException,
                                java.lang.InstantiationException
Reads the whole XML contents into XmlData

Parameters:
in - the reader to read data from
Returns:
XmlData obtained from input source.
Throws:
java.io.IOException - if an I/O error occurs.
java.lang.InstantiationException - if there are problems instantiating XmlData

readFromString

public static BasicXmlData readFromString(java.lang.String s)
                                   throws java.io.IOException,
                                          java.lang.InstantiationException
Reads the whole XML contents into XmlData

Parameters:
s - the string containing the XmlData as text
Returns:
XmlData obtained from input source.
Throws:
java.io.IOException - if an I/O error occurs.
java.lang.InstantiationException - if there are problems instantiating XmlData