Devsphere.com


com.devsphere.xml.benchmark
Class MainBase

java.lang.Object
  |
  +--com.devsphere.xml.benchmark.MainBase
Direct Known Subclasses:
Main1, Main2

public abstract class MainBase
extends java.lang.Object

This is the base class for Main1 and Main2 and provides most of the functionality of the XML parsing benchmark.

See Also:
Main1, Main2

Field Summary
protected  java.lang.String command
          The valid commands are: "create", "sax", "saxdomix" and "dom"
protected  java.util.Vector garbage
          A container for the garbage that must not be collected
protected  boolean namespaces
          Flag for enabling the namespace support
protected  int recordCount
          The number of records of the XML database
protected static java.lang.Runtime RUNTIME
          A reusable java.lang.Runtime instance
protected  int threadCount
          The number of concurrent threads that parse the database
protected  boolean validation
          Flag for enabling the validation support
 
Constructor Summary
protected MainBase(java.lang.String[] args)
          Does the initialization
 
Method Summary
protected  void cacheFile(java.io.File file)
          Caches a file into the operating system's memory by simply reading its content.
protected  void createDatabase(java.io.File dbFile)
          Creates an XML database.
protected  void done()
          Prints the time spent to perform the main task and the size of the used memory.
protected  javax.xml.parsers.DocumentBuilder getDocumentBuilder()
          Returns a new DOM parser.
protected  javax.xml.parsers.SAXParser getSAXParser()
          Returns a new SAX parser.
protected  void main()
          Forwards the main task to the appropriate method
protected  void parseDatabase(java.io.File dbFile)
          Forwards the parsing task to the appropriate method
protected  void parseDatabase(java.io.InputStream in)
          Forwards the parsing task to the appropriate method
protected  void parseDatabaseMultithreading(java.io.File dbFile)
          Creates multiple threads that parse the same database.
protected abstract  void parseWithDOM(java.io.InputStream in)
          Parses an XML database with DOM
protected abstract  void parseWithSAX(java.io.InputStream in)
          Parses an XML database with SAX
protected abstract  void parseWithSAXDOMIX(java.io.InputStream in)
          Parses an XML database with SAXDOMIX
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RUNTIME

protected static final java.lang.Runtime RUNTIME
A reusable java.lang.Runtime instance


command

protected java.lang.String command
The valid commands are: "create", "sax", "saxdomix" and "dom"


recordCount

protected int recordCount
The number of records of the XML database


threadCount

protected int threadCount
The number of concurrent threads that parse the database


namespaces

protected boolean namespaces
Flag for enabling the namespace support


validation

protected boolean validation
Flag for enabling the validation support


garbage

protected java.util.Vector garbage
A container for the garbage that must not be collected

Constructor Detail

MainBase

protected MainBase(java.lang.String[] args)
Does the initialization

Method Detail

main

protected void main()
             throws java.lang.Exception
Forwards the main task to the appropriate method

java.lang.Exception

done

protected void done()
Prints the time spent to perform the main task and the size of the used memory.


createDatabase

protected void createDatabase(java.io.File dbFile)
                       throws java.io.IOException
Creates an XML database.

java.io.IOException

parseWithSAX

protected abstract void parseWithSAX(java.io.InputStream in)
                              throws java.io.IOException,
                                     org.xml.sax.SAXException,
                                     javax.xml.parsers.ParserConfigurationException
Parses an XML database with SAX

java.io.IOException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException

parseWithSAXDOMIX

protected abstract void parseWithSAXDOMIX(java.io.InputStream in)
                                   throws java.io.IOException,
                                          org.xml.sax.SAXException,
                                          javax.xml.parsers.ParserConfigurationException
Parses an XML database with SAXDOMIX

java.io.IOException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException

parseWithDOM

protected abstract void parseWithDOM(java.io.InputStream in)
                              throws java.io.IOException,
                                     org.xml.sax.SAXException,
                                     javax.xml.parsers.ParserConfigurationException
Parses an XML database with DOM

java.io.IOException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException

parseDatabase

protected void parseDatabase(java.io.InputStream in)
                      throws java.io.IOException,
                             org.xml.sax.SAXException,
                             javax.xml.parsers.ParserConfigurationException
Forwards the parsing task to the appropriate method

java.io.IOException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException

parseDatabase

protected void parseDatabase(java.io.File dbFile)
                      throws java.io.IOException,
                             org.xml.sax.SAXException,
                             javax.xml.parsers.ParserConfigurationException
Forwards the parsing task to the appropriate method

java.io.IOException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException

parseDatabaseMultithreading

protected void parseDatabaseMultithreading(java.io.File dbFile)
                                    throws java.io.IOException,
                                           org.xml.sax.SAXException,
                                           javax.xml.parsers.ParserConfigurationException
Creates multiple threads that parse the same database. All threads are put in a wait state after creation. The last thread will notify all to start the parsing at the same time.

java.io.IOException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException

getSAXParser

protected javax.xml.parsers.SAXParser getSAXParser()
                                            throws org.xml.sax.SAXException,
                                                   javax.xml.parsers.ParserConfigurationException
Returns a new SAX parser.

org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException

getDocumentBuilder

protected javax.xml.parsers.DocumentBuilder getDocumentBuilder()
                                                        throws javax.xml.parsers.ParserConfigurationException
Returns a new DOM parser.

javax.xml.parsers.ParserConfigurationException

cacheFile

protected void cacheFile(java.io.File file)
                  throws java.io.IOException
Caches a file into the operating system's memory by simply reading its content.

java.io.IOException

 Devsphere.com