net.sf.xtvdclient.xtvd.parser
Class ParserFactory

java.lang.Object
  extended by net.sf.xtvdclient.xtvd.parser.ParserFactory

public final class ParserFactory
extends java.lang.Object

A factory class that is used to return appropriate instances of Parser.

See Also:
AbstractParser, WriterParser

Method Summary
static Parser getWriterParser(java.io.Reader in, java.io.Writer out)
          Return a Parser that will parse the XTVD XML document from the specified Reader and write the results to the specified Writer.
static Parser getXtvdParser(java.io.Reader in, Xtvd xtvd)
          Return a Parser that will parse the XTVD XML document from the specified Reader and create a Xtvd object that represents all the data contained in the XML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getWriterParser

public static final Parser getWriterParser(java.io.Reader in,
                                           java.io.Writer out)
                                    throws DataDirectException
Return a Parser that will parse the XTVD XML document from the specified Reader and write the results to the specified Writer.

The following code sample shows a way of using this method:

    BufferedReader reader = new BufferedReader( new InputStreamReader( new GZIPInputStream( httpConnection.getInputStream() ), "UTF-8" ) );
    BufferedWriter writer = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( file ), "UTF-8" ) );
    Parser parser = ParserFactory.getWriterParser( reader, writer );
    parser.parseXTVD();
    writer.flush();
    writer.close();
    reader.close();
 

Parameters:
Reader - - The stream from which the XML data is to be read and parsed.
Writer - out - The stream to which the parsed XML data is to be written.
Throws:
net.sf.xtvdclient.gui.DataDirectException - - If errors are encountered while parsing the XML stream, or writing to the output stream.
DataDirectException

getXtvdParser

public static final Parser getXtvdParser(java.io.Reader in,
                                         Xtvd xtvd)
                                  throws DataDirectException
Return a Parser that will parse the XTVD XML document from the specified Reader and create a Xtvd object that represents all the data contained in the XML.

The following code sample shows a way of using this method:

    BufferedReader reader = new BufferedReader( new InputStreamReader( new FileInputStream( file ), "UTF-8" ) );
    Xtvd xtvd = new Xtvd();
    Parser parser = ParserFactory.getXtvdParser( reader, xtvd );
    parser.parseXTVD();
    reader.close();
 

Parameters:
Reader - - The stream from which the XML data is to be read and parsed.
Xtvd - xtvd - The instance of Xtvd that is to be populated with the data from the XTVD document.
Throws:
DataDirectException - - If errors are encountered while parsing the XML stream, or writing to the output stream.
Since:
ddclient version 1.2