solar.service.dan.lang
Class XmlSpecParser

java.lang.Object
  |
  +--org.xml.sax.helpers.DefaultHandler
        |
        +--solar.service.dan.lang.XmlSpecParser
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, FapConstants, SpecParser

public class XmlSpecParser
extends org.xml.sax.helpers.DefaultHandler
implements SpecParser, FapConstants

An XML parser for FAP graph specification.

Version:
$Id: XmlSpecParser.java,v 1.1 2003/09/25 15:38:53 glchen Exp $
Author:
Guanling Chen

Field Summary
private static javax.xml.parsers.SAXParserFactory _factory
           
private  FilterSpec _filter
           
private  GraphSpec _graph
           
private  PipeSpec _pipe
           
private  int _pipeNum
           
private static java.lang.String ADDRESS
           
private static java.lang.String ARGUMENT
           
private static java.lang.String CLASSNAME
           
private static java.lang.String CODEBASE
           
private static java.lang.String FILTER
           
private static java.lang.String FLOW
           
private static java.lang.String GRAPH
           
private static java.lang.String INPORT
           
private static java.lang.String MIXED
           
private static java.lang.String NAME
           
private static java.lang.String OUTPORT
           
private static java.lang.String PIPE
           
private static java.lang.String PULL
           
private static java.lang.String PUSH
           
private static java.lang.String SINK
           
private static java.lang.String SOURCE
           
private static java.lang.String TYPE
           
private static java.lang.String VALUE
           
 
Fields inherited from interface solar.service.fap.FapConstants
FAP_DATA, FAP_MIXED, FAP_PID, FAP_PULL, FAP_PUSH
 
Constructor Summary
XmlSpecParser()
           
 
Method Summary
private  void assertEquals(java.lang.String s1, java.lang.String s2)
           
 void endDocument()
           
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String name)
           
private  void endFilter()
           
 GraphSpec getGraphSpec()
          Return recent parsed graph spec.
static void main(java.lang.String[] args)
           
 GraphSpec parse(java.io.File file)
          Parse the graph spec from a file.
static GraphSpec parse(org.xml.sax.InputSource in)
           
 GraphSpec parse(java.io.InputStream in)
          Parse the graph spec from an input stream.
 GraphSpec parse(java.io.Reader reader)
          Parse the graph spec from a reader.
 GraphSpec parse(java.lang.String xml)
          Parse the graph spec from a string.
private  void startArgument(org.xml.sax.Attributes attrs)
           
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String name, org.xml.sax.Attributes attrs)
           
private  void startFilter(org.xml.sax.Attributes attrs)
           
private  void startGraph(org.xml.sax.Attributes attrs)
           
private  void startInport(org.xml.sax.Attributes attrs)
           
private  void startOutport(org.xml.sax.Attributes attrs)
           
private  void startPipe(org.xml.sax.Attributes attrs)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GRAPH

private static final java.lang.String GRAPH
See Also:
Constant Field Values

FILTER

private static final java.lang.String FILTER
See Also:
Constant Field Values

NAME

private static final java.lang.String NAME
See Also:
Constant Field Values

CLASSNAME

private static final java.lang.String CLASSNAME
See Also:
Constant Field Values

CODEBASE

private static final java.lang.String CODEBASE
See Also:
Constant Field Values

ADDRESS

private static final java.lang.String ADDRESS
See Also:
Constant Field Values

ARGUMENT

private static final java.lang.String ARGUMENT
See Also:
Constant Field Values

VALUE

private static final java.lang.String VALUE
See Also:
Constant Field Values

PIPE

private static final java.lang.String PIPE
See Also:
Constant Field Values

TYPE

private static final java.lang.String TYPE
See Also:
Constant Field Values

PUSH

private static final java.lang.String PUSH
See Also:
Constant Field Values

PULL

private static final java.lang.String PULL
See Also:
Constant Field Values

MIXED

private static final java.lang.String MIXED
See Also:
Constant Field Values

SOURCE

private static final java.lang.String SOURCE
See Also:
Constant Field Values

SINK

private static final java.lang.String SINK
See Also:
Constant Field Values

INPORT

private static final java.lang.String INPORT
See Also:
Constant Field Values

OUTPORT

private static final java.lang.String OUTPORT
See Also:
Constant Field Values

FLOW

private static final java.lang.String FLOW
See Also:
Constant Field Values

_factory

private static final javax.xml.parsers.SAXParserFactory _factory

_graph

private GraphSpec _graph

_filter

private FilterSpec _filter

_pipe

private PipeSpec _pipe

_pipeNum

private int _pipeNum
Constructor Detail

XmlSpecParser

public XmlSpecParser()
Method Detail

parse

public GraphSpec parse(java.io.File file)
                throws ParsingException
Description copied from interface: SpecParser
Parse the graph spec from a file.

Specified by:
parse in interface SpecParser
ParsingException

parse

public GraphSpec parse(java.io.InputStream in)
                throws ParsingException
Description copied from interface: SpecParser
Parse the graph spec from an input stream.

Specified by:
parse in interface SpecParser
ParsingException

parse

public GraphSpec parse(java.io.Reader reader)
                throws ParsingException
Description copied from interface: SpecParser
Parse the graph spec from a reader.

Specified by:
parse in interface SpecParser
ParsingException

parse

public GraphSpec parse(java.lang.String xml)
                throws ParsingException
Description copied from interface: SpecParser
Parse the graph spec from a string.

Specified by:
parse in interface SpecParser
ParsingException

parse

public static GraphSpec parse(org.xml.sax.InputSource in)
                       throws ParsingException
ParsingException

getGraphSpec

public GraphSpec getGraphSpec()
Return recent parsed graph spec.


endDocument

public void endDocument()
Specified by:
endDocument in interface org.xml.sax.ContentHandler
Overrides:
endDocument in class org.xml.sax.helpers.DefaultHandler

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String name,
                         org.xml.sax.Attributes attrs)
                  throws org.xml.sax.SAXException
Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String name)
                throws org.xml.sax.SAXException
Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

startGraph

private void startGraph(org.xml.sax.Attributes attrs)

startFilter

private void startFilter(org.xml.sax.Attributes attrs)
                  throws org.xml.sax.SAXException
org.xml.sax.SAXException

endFilter

private void endFilter()

startArgument

private void startArgument(org.xml.sax.Attributes attrs)

startInport

private void startInport(org.xml.sax.Attributes attrs)

startOutport

private void startOutport(org.xml.sax.Attributes attrs)

startPipe

private void startPipe(org.xml.sax.Attributes attrs)
                throws org.xml.sax.SAXException
org.xml.sax.SAXException

assertEquals

private void assertEquals(java.lang.String s1,
                          java.lang.String s2)
                   throws org.xml.sax.SAXException
org.xml.sax.SAXException

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
java.lang.Exception