simulations.xml
Class DocumentTracer

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by simulations.xml.DocumentTracer
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.ext.DeclHandler, org.xml.sax.ext.LexicalHandler

public class DocumentTracer
extends org.xml.sax.helpers.DefaultHandler
implements org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.ErrorHandler, org.xml.sax.ext.DeclHandler, org.xml.sax.ext.LexicalHandler

Provides a complete trace of SAX2 events for files parsed. This is useful for making sure that a SAX parser implementation faithfully communicates all information in the document to the SAX handlers.


Field Summary
protected static boolean DEFAULT_NAMESPACES
          Default namespaces support (true).
protected static java.lang.String DEFAULT_PARSER_NAME
          Default parser name.
protected static boolean DEFAULT_SCHEMA_FULL_CHECKING
          Default Schema full checking support (false).
protected static boolean DEFAULT_SCHEMA_VALIDATION
          Default Schema validation support (false).
protected static boolean DEFAULT_VALIDATION
          Default validation support (false).
protected  int fIndent
          Indent level.
protected  java.io.PrintWriter fOut
          Print writer.
protected static java.lang.String LEXICAL_HANDLER_PROPERTY_ID
          Lexical handler property id (http://xml.org/sax/properties/lexical-handler).
protected static java.lang.String NAMESPACES_FEATURE_ID
          Namespaces feature id (http://xml.org/sax/features/namespaces).
protected static java.lang.String SCHEMA_FULL_CHECKING_FEATURE_ID
          Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking).
protected static java.lang.String SCHEMA_VALIDATION_FEATURE_ID
          Schema validation feature id (http://apache.org/xml/features/validation/schema).
protected static java.lang.String VALIDATION_FEATURE_ID
          Validation feature id (http://xml.org/sax/features/validation).
 
Constructor Summary
DocumentTracer(java.lang.String file)
          Default constructor.
 
Method Summary
 void attributeDecl(java.lang.String elementName, java.lang.String attributeName, java.lang.String type, java.lang.String valueDefault, java.lang.String value)
          Attribute declaration.
 void characters(char[] ch, int offset, int length)
          Characters.
 void comment(char[] ch, int offset, int length)
          Comment.
 void elementDecl(java.lang.String name, java.lang.String contentModel)
          Element declaration.
 void endCDATA()
          End CDATA section.
 void endDocument()
          End document.
 void endDTD()
          End DTD.
 void endElement(java.lang.String name)
          End element.
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qname)
          End element.
 void endEntity(java.lang.String name)
          End entity.
 void endPrefixMapping(java.lang.String prefix)
          End prefix mapping.
 void error(org.xml.sax.SAXParseException ex)
          Error.
 void externalEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
          External entity declaration.
 void fatalError(org.xml.sax.SAXParseException ex)
          Fatal error.
 int getCoalitionDefinition()
          Getter for property coalitionDefinition.
 float getCoalitionPoints()
          Getter for property coalitionPoints.
 java.io.File getGraphFile()
          Getter for property graphFile.
 java.io.File getHistoryFile()
          Getter for property historyFile.
 int getLoosingPoints()
          Getter for property loosingPoints.
 java.util.ArrayList getPlayerList()
          Getter for property playerList.
 int getSeed()
          Getter for property seed.
 int getTraceLevel()
          Getter for property trace_level.
 float getWinnerPoints()
          Getter for property winnerPoints.
 void ignorableWhitespace(char[] ch, int offset, int length)
          Ignorable whitespace.
 void init()
          Main.
 void internalEntityDecl(java.lang.String name, java.lang.String text)
          Internal entity declaration.
 boolean isProportional()
          Getter for property proportional.
protected  char normalizeAndPrint(char c)
          Normalize and print.
 void notationDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
          Notation declaration.
protected  void printError(java.lang.String type, org.xml.sax.SAXParseException ex)
          Prints the error message.
protected  void printIndent()
          Prints the indent.
protected  void printQuotedString(char[] ch, int offset, int length)
          Print quoted string.
protected  java.lang.String printQuotedString(java.lang.String s)
          Print quoted string.
 void processingInstruction(java.lang.String target, java.lang.String data)
          Processing instruction.
 void setCoalitionDefinition(int coalitionDefinition)
          Setter for property coalitionDefinition.
 void setCoalitionPoints(float coalitionPoints)
          Setter for property coalitionPoints.
 void setDocumentLocator(org.xml.sax.Locator locator)
          Set document locator.
 void setGraphFile(java.io.File graphFile)
          Setter for property graphFile.
 void setHistoryFile(java.io.File historyFile)
          Setter for property historyFile.
 void setLoosingPoints(int loosingPoints)
          Setter for property loosingPoints.
 void setOutput(java.io.OutputStream stream, java.lang.String encoding)
          Sets the output stream for printing.
 void setOutput(java.io.Writer writer)
          Sets the output writer.
 void setPlayerList(java.util.ArrayList playerList)
          Setter for property playerList.
 void setProportional(boolean proportional)
          Setter for property proportional.
 void setSeed(int seed)
          Setter for property seed.
 void setTraceLevel(int traceLevel)
          Setter for property trace_level.
 void setWinnerPoints(float winnerPoints)
          Setter for property winnerPoints.
 void skippedEntity(java.lang.String name)
          Skipped entity.
 void startCDATA()
          Start CDATA section.
 void startDocument()
          Start document.
 void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
          Start DTD.
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qname, org.xml.sax.Attributes attributes)
          Start element.
 void startEntity(java.lang.String name)
          Start entity.
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
          Start prefix mapping.
 void unparsedEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.lang.String notationName)
          Unparsed entity declaration.
 void warning(org.xml.sax.SAXParseException ex)
          Warning.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
resolveEntity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAMESPACES_FEATURE_ID

protected static final java.lang.String NAMESPACES_FEATURE_ID
Namespaces feature id (http://xml.org/sax/features/namespaces).

See Also:
Constant Field Values

VALIDATION_FEATURE_ID

protected static final java.lang.String VALIDATION_FEATURE_ID
Validation feature id (http://xml.org/sax/features/validation).

See Also:
Constant Field Values

SCHEMA_VALIDATION_FEATURE_ID

protected static final java.lang.String SCHEMA_VALIDATION_FEATURE_ID
Schema validation feature id (http://apache.org/xml/features/validation/schema).

See Also:
Constant Field Values

SCHEMA_FULL_CHECKING_FEATURE_ID

protected static final java.lang.String SCHEMA_FULL_CHECKING_FEATURE_ID
Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking).

See Also:
Constant Field Values

LEXICAL_HANDLER_PROPERTY_ID

protected static final java.lang.String LEXICAL_HANDLER_PROPERTY_ID
Lexical handler property id (http://xml.org/sax/properties/lexical-handler).

See Also:
Constant Field Values

DEFAULT_PARSER_NAME

protected static final java.lang.String DEFAULT_PARSER_NAME
Default parser name.

See Also:
Constant Field Values

DEFAULT_NAMESPACES

protected static final boolean DEFAULT_NAMESPACES
Default namespaces support (true).

See Also:
Constant Field Values

DEFAULT_VALIDATION

protected static final boolean DEFAULT_VALIDATION
Default validation support (false).

See Also:
Constant Field Values

DEFAULT_SCHEMA_VALIDATION

protected static final boolean DEFAULT_SCHEMA_VALIDATION
Default Schema validation support (false).

See Also:
Constant Field Values

DEFAULT_SCHEMA_FULL_CHECKING

protected static final boolean DEFAULT_SCHEMA_FULL_CHECKING
Default Schema full checking support (false).

See Also:
Constant Field Values

fOut

protected java.io.PrintWriter fOut
Print writer.


fIndent

protected int fIndent
Indent level.

Constructor Detail

DocumentTracer

public DocumentTracer(java.lang.String file)
Default constructor.

Parameters:
file - The XML File
Method Detail

setOutput

public void setOutput(java.io.OutputStream stream,
                      java.lang.String encoding)
               throws java.io.UnsupportedEncodingException
Sets the output stream for printing.

Parameters:
stream - The stream
encoding - The encoding
Throws:
java.io.UnsupportedEncodingException - throws if the encoding isn't supported

setOutput

public void setOutput(java.io.Writer writer)
Sets the output writer.

Parameters:
writer - The writer

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
Set document locator.

Specified by:
setDocumentLocator in interface org.xml.sax.ContentHandler
Overrides:
setDocumentLocator in class org.xml.sax.helpers.DefaultHandler
Parameters:
locator - The locator

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Start document.

Specified by:
startDocument in interface org.xml.sax.ContentHandler
Overrides:
startDocument in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
Processing instruction.

Specified by:
processingInstruction in interface org.xml.sax.ContentHandler
Overrides:
processingInstruction in class org.xml.sax.helpers.DefaultHandler
Parameters:
target - The target
data - The data
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

characters

public void characters(char[] ch,
                       int offset,
                       int length)
                throws org.xml.sax.SAXException
Characters.

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Parameters:
ch - the chars
offset - the offset
length - the length
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int offset,
                                int length)
                         throws org.xml.sax.SAXException
Ignorable whitespace.

Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler
Overrides:
ignorableWhitespace in class org.xml.sax.helpers.DefaultHandler
Parameters:
ch - The chars
offset - the offset
length - the length
Throws:
org.xml.sax.SAXException - Exception returns in case of problem

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
End document.

Specified by:
endDocument in interface org.xml.sax.ContentHandler
Overrides:
endDocument in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
                        throws org.xml.sax.SAXException
Start prefix mapping.

Specified by:
startPrefixMapping in interface org.xml.sax.ContentHandler
Overrides:
startPrefixMapping in class org.xml.sax.helpers.DefaultHandler
Parameters:
prefix - the prefix
uri - the URi
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qname,
                         org.xml.sax.Attributes attributes)
                  throws org.xml.sax.SAXException
Start element.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
uri - The URi
localName - The local name
qname - the qname
attributes - The attributes
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qname)
                throws org.xml.sax.SAXException
End element.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
uri - The URI
localName - the local name
qname - The qname
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

endPrefixMapping

public void endPrefixMapping(java.lang.String prefix)
                      throws org.xml.sax.SAXException
End prefix mapping.

Specified by:
endPrefixMapping in interface org.xml.sax.ContentHandler
Overrides:
endPrefixMapping in class org.xml.sax.helpers.DefaultHandler
Parameters:
prefix - The prefix
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

skippedEntity

public void skippedEntity(java.lang.String name)
                   throws org.xml.sax.SAXException
Skipped entity.

Specified by:
skippedEntity in interface org.xml.sax.ContentHandler
Overrides:
skippedEntity in class org.xml.sax.helpers.DefaultHandler
Parameters:
name - The name
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

endElement

public void endElement(java.lang.String name)
                throws org.xml.sax.SAXException
End element.

Parameters:
name - The name
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

notationDecl

public void notationDecl(java.lang.String name,
                         java.lang.String publicId,
                         java.lang.String systemId)
                  throws org.xml.sax.SAXException
Notation declaration.

Specified by:
notationDecl in interface org.xml.sax.DTDHandler
Overrides:
notationDecl in class org.xml.sax.helpers.DefaultHandler
Parameters:
name - The name
publicId - The public Id
systemId - The system Id
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

unparsedEntityDecl

public void unparsedEntityDecl(java.lang.String name,
                               java.lang.String publicId,
                               java.lang.String systemId,
                               java.lang.String notationName)
                        throws org.xml.sax.SAXException
Unparsed entity declaration.

Specified by:
unparsedEntityDecl in interface org.xml.sax.DTDHandler
Overrides:
unparsedEntityDecl in class org.xml.sax.helpers.DefaultHandler
Parameters:
name - The name
publicId - The public ID
systemId - The system ID
notationName - The notation name
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

startDTD

public void startDTD(java.lang.String name,
                     java.lang.String publicId,
                     java.lang.String systemId)
              throws org.xml.sax.SAXException
Start DTD.

Specified by:
startDTD in interface org.xml.sax.ext.LexicalHandler
Parameters:
name - The name
publicId - The public ID
systemId - The System ID
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

startEntity

public void startEntity(java.lang.String name)
                 throws org.xml.sax.SAXException
Start entity.

Specified by:
startEntity in interface org.xml.sax.ext.LexicalHandler
Parameters:
name - The name
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

startCDATA

public void startCDATA()
                throws org.xml.sax.SAXException
Start CDATA section.

Specified by:
startCDATA in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

endCDATA

public void endCDATA()
              throws org.xml.sax.SAXException
End CDATA section.

Specified by:
endCDATA in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

comment

public void comment(char[] ch,
                    int offset,
                    int length)
             throws org.xml.sax.SAXException
Comment.

Specified by:
comment in interface org.xml.sax.ext.LexicalHandler
Parameters:
ch - The chars
offset - The offset
length - The length
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

endEntity

public void endEntity(java.lang.String name)
               throws org.xml.sax.SAXException
End entity.

Specified by:
endEntity in interface org.xml.sax.ext.LexicalHandler
Parameters:
name - The name
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

endDTD

public void endDTD()
            throws org.xml.sax.SAXException
End DTD.

Specified by:
endDTD in interface org.xml.sax.ext.LexicalHandler
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

elementDecl

public void elementDecl(java.lang.String name,
                        java.lang.String contentModel)
                 throws org.xml.sax.SAXException
Element declaration.

Specified by:
elementDecl in interface org.xml.sax.ext.DeclHandler
Parameters:
name - The name
contentModel - The content model
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

attributeDecl

public void attributeDecl(java.lang.String elementName,
                          java.lang.String attributeName,
                          java.lang.String type,
                          java.lang.String valueDefault,
                          java.lang.String value)
                   throws org.xml.sax.SAXException
Attribute declaration.

Specified by:
attributeDecl in interface org.xml.sax.ext.DeclHandler
Parameters:
elementName - The element name
attributeName - The attribute name
type - The type
valueDefault - The default value
value - the value
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

internalEntityDecl

public void internalEntityDecl(java.lang.String name,
                               java.lang.String text)
                        throws org.xml.sax.SAXException
Internal entity declaration.

Specified by:
internalEntityDecl in interface org.xml.sax.ext.DeclHandler
Parameters:
name - The name
text - The text
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

externalEntityDecl

public void externalEntityDecl(java.lang.String name,
                               java.lang.String publicId,
                               java.lang.String systemId)
                        throws org.xml.sax.SAXException
External entity declaration.

Specified by:
externalEntityDecl in interface org.xml.sax.ext.DeclHandler
Parameters:
name - The name
publicId - The public ID
systemId - The system ID
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

warning

public void warning(org.xml.sax.SAXParseException ex)
             throws org.xml.sax.SAXException
Warning.

Specified by:
warning in interface org.xml.sax.ErrorHandler
Overrides:
warning in class org.xml.sax.helpers.DefaultHandler
Parameters:
ex - The exception
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

error

public void error(org.xml.sax.SAXParseException ex)
           throws org.xml.sax.SAXException
Error.

Specified by:
error in interface org.xml.sax.ErrorHandler
Overrides:
error in class org.xml.sax.helpers.DefaultHandler
Parameters:
ex - The exception
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

fatalError

public void fatalError(org.xml.sax.SAXParseException ex)
                throws org.xml.sax.SAXException
Fatal error.

Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Overrides:
fatalError in class org.xml.sax.helpers.DefaultHandler
Parameters:
ex - The exception
Throws:
org.xml.sax.SAXException - throws SAXException in case of problem

printQuotedString

protected java.lang.String printQuotedString(java.lang.String s)
Print quoted string.

Parameters:
s - The string
Returns:
The quoted string

printQuotedString

protected void printQuotedString(char[] ch,
                                 int offset,
                                 int length)
Print quoted string.

Parameters:
ch - The chars
offset - The offset
length - The length

normalizeAndPrint

protected char normalizeAndPrint(char c)
Normalize and print.

Parameters:
c - The char
Returns:
The char

printError

protected void printError(java.lang.String type,
                          org.xml.sax.SAXParseException ex)
Prints the error message.

Parameters:
type - The type
ex - The exception

printIndent

protected void printIndent()
Prints the indent.


init

public void init()
          throws java.lang.Exception
Main.

Throws:
java.lang.Exception - throws Exception in case of problem

getSeed

public int getSeed()
Getter for property seed.

Returns:
Value of property seed.

setSeed

public void setSeed(int seed)
Setter for property seed.

Parameters:
seed - New value of property seed.

getPlayerList

public java.util.ArrayList getPlayerList()
Getter for property playerList.

Returns:
Value of property playerList.

setPlayerList

public void setPlayerList(java.util.ArrayList playerList)
Setter for property playerList.

Parameters:
playerList - New value of property playerList.

getWinnerPoints

public float getWinnerPoints()
Getter for property winnerPoints.

Returns:
Value of property winnerPoints.

setWinnerPoints

public void setWinnerPoints(float winnerPoints)
Setter for property winnerPoints.

Parameters:
winnerPoints - New value of property winnerPoints.

isProportional

public boolean isProportional()
Getter for property proportional.

Returns:
Value of property proportional.

setProportional

public void setProportional(boolean proportional)
Setter for property proportional.

Parameters:
proportional - New value of property proportional.

getLoosingPoints

public int getLoosingPoints()
Getter for property loosingPoints.

Returns:
Value of property loosingPoints.

setLoosingPoints

public void setLoosingPoints(int loosingPoints)
Setter for property loosingPoints.

Parameters:
loosingPoints - New value of property loosingPoints.

getCoalitionPoints

public float getCoalitionPoints()
Getter for property coalitionPoints.

Returns:
Value of property coalitionPoints.

setCoalitionPoints

public void setCoalitionPoints(float coalitionPoints)
Setter for property coalitionPoints.

Parameters:
coalitionPoints - New value of property coalitionPoints.

getTraceLevel

public int getTraceLevel()
Getter for property trace_level.

Returns:
Value of property trace_level.

setTraceLevel

public void setTraceLevel(int traceLevel)
Setter for property trace_level.

Parameters:
traceLevel - The trace level

getHistoryFile

public java.io.File getHistoryFile()
Getter for property historyFile.

Returns:
Value of property historyFile.

setHistoryFile

public void setHistoryFile(java.io.File historyFile)
Setter for property historyFile.

Parameters:
historyFile - New value of property historyFile.

getCoalitionDefinition

public int getCoalitionDefinition()
Getter for property coalitionDefinition.

Returns:
Value of property coalitionDefinition.

setCoalitionDefinition

public void setCoalitionDefinition(int coalitionDefinition)
Setter for property coalitionDefinition.

Parameters:
coalitionDefinition - New value of property coalitionDefinition.

getGraphFile

public java.io.File getGraphFile()
Getter for property graphFile.

Returns:
Value of property graphFile.

setGraphFile

public void setGraphFile(java.io.File graphFile)
Setter for property graphFile.

Parameters:
graphFile - New value of property graphFile.