walker
Class StaxParser

java.lang.Object
  extended by walker.StaxParser
All Implemented Interfaces:
javax.xml.stream.XMLStreamConstants

public class StaxParser
extends java.lang.Object
implements javax.xml.stream.XMLStreamConstants

Created by IntelliJ IDEA. User: andy Date: Mar 23, 2010


Field Summary
static boolean initialized
           
static long jumpLineOffset
           
static long jumpOffset
           
static boolean MONITOR
           
static boolean RELATIVE_TIMESTAMPS
           
 
Fields inherited from interface javax.xml.stream.XMLStreamConstants
ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT
 
Constructor Summary
StaxParser(java.lang.String fileName, ExperimentState state, double timestamp)
          Default Constructor.
 
Method Summary
 void createReader(double timestamp)
          Creates a new extended xml stream reader starting from the supplied position.
 void createReaderOld(long position)
          Creates a new extended xml stream reader starting from the supplied position.
 java.lang.String getFileName()
           
 ExtendedXMLStreamReader getReader()
           
 ExperimentState getState()
           
protected  void link(boolean defaultMode)
          Reads a single Link element and moves the stream to the following element.
protected  void node(boolean defaultMode)
          Reads a single node element and moves the stream to the following element.
 boolean walk(ExtendedXMLStreamReader reader, ExperimentState state, double speed, double fps)
          Main method for 'walking' a trace.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

initialized

public static boolean initialized

jumpLineOffset

public static long jumpLineOffset

jumpOffset

public static long jumpOffset

MONITOR

public static final boolean MONITOR
See Also:
Constant Field Values

RELATIVE_TIMESTAMPS

public static final boolean RELATIVE_TIMESTAMPS
See Also:
Constant Field Values
Constructor Detail

StaxParser

public StaxParser(java.lang.String fileName,
                  ExperimentState state,
                  double timestamp)
           throws java.io.IOException
Default Constructor. Creates a new experiment state and parses the document.

Parameters:
fileName - the file name of the wiseml file.
state - the Experiment state that is going to be associated with this parser.
timestamp - the position of the file to start parsing. -1 means parse from the beginning.
Throws:
java.io.IOException - if there is no such file.
Method Detail

createReader

public void createReader(double timestamp)
                  throws javax.xml.stream.XMLStreamException,
                         java.io.IOException,
                         badSyntaxException,
                         endDocumentException
Creates a new extended xml stream reader starting from the supplied position. Also handles gziped files.

Parameters:
timestamp - where to position the stream in the wiseml file. -1 means the beginning of the file.
Throws:
javax.xml.stream.XMLStreamException - if the ExtendedXMLStreamReader encounters a problem while created or preparsing.
java.io.IOException - if there is no such file.
badSyntaxException - is case of a wiseml bad syntax.
endDocumentException - if it encounters the end of the file.

createReaderOld

public void createReaderOld(long position)
                     throws javax.xml.stream.XMLStreamException,
                            java.io.IOException,
                            badSyntaxException
Creates a new extended xml stream reader starting from the supplied position. Also handles gziped files.

Parameters:
position - where to position the stream in the wiseml file. -1 means the beginning of the file.
Throws:
javax.xml.stream.XMLStreamException - if the ExtendedXMLStreamReader encounters a problem while created or preparsing.
java.io.IOException - if there is no such file.
badSyntaxException - is case of a wiseml bad syntax.

getFileName

public java.lang.String getFileName()
Returns:
the wiseml fileName

getReader

public ExtendedXMLStreamReader getReader()
Returns:
the ExtendedXMLStreamReader that is associated with StaxParser.

getState

public ExperimentState getState()
Returns:
StaxParser's experiment State.

link

protected void link(boolean defaultMode)
             throws badSyntaxException,
                    javax.xml.stream.XMLStreamException,
                    badSetupException,
                    endDocumentException
Reads a single Link element and moves the stream to the following element.

Parameters:
defaultMode - true only for parsing the defaultNode, false for parsing topology
Throws:
badSyntaxException - if the wiseml file has bad syntax
javax.xml.stream.XMLStreamException - if there is a problem with xml syntax.
badSetupException - in case of a misconfirguration in the experiment.
endDocumentException - if it encounters the end of the file.

node

protected void node(boolean defaultMode)
             throws badSyntaxException,
                    javax.xml.stream.XMLStreamException,
                    endDocumentException
Reads a single node element and moves the stream to the following element.

Parameters:
defaultMode - true only for parsing the defaultNode, false for parsing topology
Throws:
badSyntaxException - if the wiseml file has bad syntax
javax.xml.stream.XMLStreamException - if there is a problem with xml syntax.
endDocumentException - if it encounters the end of the file.

walk

public boolean walk(ExtendedXMLStreamReader reader,
                    ExperimentState state,
                    double speed,
                    double fps)
             throws badSyntaxException,
                    javax.xml.stream.XMLStreamException,
                    badSetupException,
                    endDocumentException
Main method for 'walking' a trace. It facilitate's trace parsing by mediating between the crawler and the parseTrace() method. It handles positioning and range details. To avoid los of information, the ExtendedXMLStreamReader should either point at a timestamp's CDATA or at a new trace element.

Parameters:
reader - the extended xml reader that keeps the stream position.
state - the state to update.
speed - is the number of experiment seconds per one experiment second.
fps - is the number of frames per second of visualization.
Returns:
true if the walker succeeded.
Throws:
badSyntaxException - when a found element either not exists or it doesn't match the expectedElement.
javax.xml.stream.XMLStreamException - in case of a problem with xml syntax.
badSetupException - in case of a misconfirguration in the experiment
endDocumentException - if it encounters the end of the file.