org.mitre.midiki.workshop
Class WorkshopDatabaseFactory

java.lang.Object
  |
  +--org.mitre.midiki.workshop.WorkshopDatabaseFactory

public class WorkshopDatabaseFactory
extends java.lang.Object

Factory class for parsing XML files conforming to the diseasedb.dtd into WorkshopDatabase objects.

Since:
1.0

Constructor Summary
WorkshopDatabaseFactory()
           
 
Method Summary
protected static void extractDiseases(org.w3c.dom.NodeList l, WorkshopDatabase wdb)
          Generates a master list of all disease names in the database.
protected static void extractHistory(org.w3c.dom.NodeList l, WorkshopDatabase wdb)
          Compiles a master list of unique history items.
protected static void extractSymptoms(org.w3c.dom.NodeList l, WorkshopDatabase wdb)
          Compiles a master list of unique symptoms.
protected static void extractSynonyms(org.w3c.dom.NodeList l, WorkshopDatabase wdb)
          Generates Synonym objects from tags in the database.
protected static void extractTests(org.w3c.dom.NodeList l, WorkshopDatabase wdb)
          Compiles a master list of unique tests.
static void main(java.lang.String[] args)
          Reads the file specified by the first program argument and parses it into a WorkshopDatabase by a call to newDatabase().
protected static void mapSymptomsToDiseases(org.w3c.dom.NodeList diseaseNodes, WorkshopDatabase wdb)
          Creates a sparse matrix mapping diseases to thier symptoms.
static WorkshopDatabase newDatabase(java.lang.String databaseFileName)
          Opens the specified database file and interprets it as an XML file conforming to diseasedb.dtd.
protected static void processDocument(org.w3c.dom.Document doc, WorkshopDatabase wdb)
          Parses the expected disease database sections.
protected static java.lang.String textChild(org.w3c.dom.Node node)
          Finds the first "#text" child of the specified node and returns its value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkshopDatabaseFactory

public WorkshopDatabaseFactory()
Method Detail

extractDiseases

protected static void extractDiseases(org.w3c.dom.NodeList l,
                                      WorkshopDatabase wdb)
Generates a master list of all disease names in the database. The details of each disease are filled in later.
Parameters:
l - an org.w3c.dom.NodeList value
wdb - a WorkshopDatabase value

extractSymptoms

protected static void extractSymptoms(org.w3c.dom.NodeList l,
                                      WorkshopDatabase wdb)
Compiles a master list of unique symptoms. Symptoms are assumed to be the same if they have the same name, or if thier names are synonyms.
Parameters:
l - an org.w3c.dom.NodeList value
wdb - a WorkshopDatabase value

extractTests

protected static void extractTests(org.w3c.dom.NodeList l,
                                   WorkshopDatabase wdb)
Compiles a master list of unique tests.
Parameters:
l - an org.w3c.dom.NodeList value
wdb - a WorkshopDatabase value

extractHistory

protected static void extractHistory(org.w3c.dom.NodeList l,
                                     WorkshopDatabase wdb)
Compiles a master list of unique history items.
Parameters:
l - an org.w3c.dom.NodeList value
wdb - a WorkshopDatabase value

extractSynonyms

protected static void extractSynonyms(org.w3c.dom.NodeList l,
                                      WorkshopDatabase wdb)
Generates Synonym objects from tags in the database.
Parameters:
l - an org.w3c.dom.NodeList value
wdb - a WorkshopDatabase value

textChild

protected static java.lang.String textChild(org.w3c.dom.Node node)
Finds the first "#text" child of the specified node and returns its value. Handy utility routine.
Parameters:
node - an org.w3c.dom.Node value
Returns:
a String value

mapSymptomsToDiseases

protected static void mapSymptomsToDiseases(org.w3c.dom.NodeList diseaseNodes,
                                            WorkshopDatabase wdb)
Creates a sparse matrix mapping diseases to thier symptoms. Since each individual disease is examined during this process, the set of disease descriptions are also loaded at this time.
Parameters:
diseaseNodes - an org.w3c.dom.NodeList value
wdb - a WorkshopDatabase value

processDocument

protected static void processDocument(org.w3c.dom.Document doc,
                                      WorkshopDatabase wdb)
Parses the expected disease database sections.
Parameters:
doc - an org.w3c.dom.Document value
wdb - a WorkshopDatabase value

newDatabase

public static WorkshopDatabase newDatabase(java.lang.String databaseFileName)
Opens the specified database file and interprets it as an XML file conforming to diseasedb.dtd. If successful, it returns a WorkshopDatabase object which can be queried. The resulting WorkshopDatabase does not require an XML parser to be present in the system.
Parameters:
databaseFileName - a String value
Returns:
a WorkshopDatabase value

main

public static void main(java.lang.String[] args)
Reads the file specified by the first program argument and parses it into a WorkshopDatabase by a call to newDatabase(). When called with one argument, this routine executes a few simple tests against the database and dumps the results to System.out. When called with at least two arguments, the second argument is interpreted as a filename to which the generated WorkshopDatabase should be serialized.
Parameters:
args - a String[] value