org.mitre.midiki.workshop
Class DiseaseServer
java.lang.Object
|
+--org.mitre.midiki.workshop.NetworkServer
|
+--org.mitre.midiki.workshop.DiseaseServer
- Direct Known Subclasses:
- ThreadedDiseaseServer
- public class DiseaseServer
- extends NetworkServer
Based on a simple HTTP server, generates XML
based on a disease db query in an encoded URL.
The form of the URL is identical to that of the
command line test tool WorkshopDatabaseTest
,
except that arguments are separated by an asterisk (*),
and whitespace is replace by %20 encoding.
Adapted from code that appears in Core Web Programming
from Prentice Hall Publishers, and may be freely used
or adapted. 1997 Marty Hall, hall@apl.jhu.edu.
Method Summary |
static java.lang.String |
containsIgnoreCase(java.util.Collection c,
java.lang.String s)
Checks the container for a copy of this string, ignoring case. |
java.lang.String |
fromUrl(java.lang.String cvt)
Decodes %20 hexadecimal codes into spaces and returns the
converted string. |
void |
handleConnection(java.net.Socket server)
Overrides the NetworkServer handleConnection
to read each line of data received, save it
into an array of strings, then send it
back embedded inside a PRE element in an
HTML page. |
protected static boolean |
loadDatabase(java.lang.String filename)
|
protected static boolean |
loadDTD(java.lang.String filename)
|
static void |
main(java.lang.String[] args)
Supply a port number as a command-line
argument. |
java.lang.String[] |
parseCommand(java.lang.String cmd)
Parses the argument to an HTTP GET into a series of arguments
separated by *. |
static MedicalHistory |
parseHistory(java.lang.String s,
WorkshopDatabase wd)
Parses a symptom specification of the form "symptom"/ into
a MedicalHistory object. |
static Symptom |
parseSymptom(java.lang.String s,
WorkshopDatabase wd)
Parses a symptom specification of the form "symptom"/ into
a Symptom object. |
static DiagnosticTest |
parseTest(java.lang.String s,
WorkshopDatabase wd)
Parses a symptom specification of the form "symptom"/ into
a DiagnosticTest object. |
java.lang.String |
toUrl(java.lang.String cvt)
Encodes spaces in a string into %20 hexadecimal encoding,
so that the string can be passed as part of a URL. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
maxInputLines
protected int maxInputLines
serverName
protected java.lang.String serverName
defaultDTD
protected static java.lang.String defaultDTD
defaultDatabaseName
protected static java.lang.String defaultDatabaseName
wd
protected static WorkshopDatabase wd
dtdData
protected static java.util.LinkedList dtdData
nextId
protected static int nextId
buffer
protected java.lang.StringBuffer buffer
cvtbuf
protected java.lang.StringBuffer cvtbuf
id
protected int id
uc
protected UrlConverter uc
DiseaseServer
public DiseaseServer(int port,
int maxConnections)
loadDatabase
protected static boolean loadDatabase(java.lang.String filename)
loadDTD
protected static boolean loadDTD(java.lang.String filename)
main
public static void main(java.lang.String[] args)
- Supply a port number as a command-line
argument. Otherwise port 5555 will be used.
handleConnection
public void handleConnection(java.net.Socket server)
throws java.io.IOException
- Overrides the NetworkServer handleConnection
to read each line of data received, save it
into an array of strings, then send it
back embedded inside a PRE element in an
HTML page.
- Overrides:
handleConnection
in class NetworkServer
fromUrl
public java.lang.String fromUrl(java.lang.String cvt)
- Decodes %20 hexadecimal codes into spaces and returns the
converted string. Used for decoding query strings passed in URLs.
- Parameters:
cvt
- a String
value- Returns:
- a
String
value
toUrl
public java.lang.String toUrl(java.lang.String cvt)
- Encodes spaces in a string into %20 hexadecimal encoding,
so that the string can be passed as part of a URL.
Uses a UrlConverter to do the job.
- Parameters:
cvt
- a String
value- Returns:
- a
String
value
parseCommand
public java.lang.String[] parseCommand(java.lang.String cmd)
- Parses the argument to an HTTP GET into a series of arguments
separated by *.
- Parameters:
cmd
- a String
value- Returns:
- a
String[]
value
containsIgnoreCase
public static java.lang.String containsIgnoreCase(java.util.Collection c,
java.lang.String s)
- Checks the container for a copy of this string, ignoring case.
If the item is found, the canonical version is returned.
- Parameters:
c
- a Container
values
- a String
value- Returns:
- a
String
value
parseSymptom
public static Symptom parseSymptom(java.lang.String s,
WorkshopDatabase wd)
- Parses a symptom specification of the form "symptom"/ into
a Symptom object. The test component of the symptom is not specified.
If the component is not specified, it is assumed to be "yes".
parseSymptom("headache/yes") yields Symptom(headache,"",yes)
parseSymptom("\"headache\"/no") yields Symptom(headache,"",no)
parseSymptom("headache") yields Symptom(headache,"",yes)
- Parameters:
s
- a String
valuewd
- a WorkshopDatabase
in which to search for the symptom name- Returns:
- a
Symptom
value
parseTest
public static DiagnosticTest parseTest(java.lang.String s,
WorkshopDatabase wd)
- Parses a symptom specification of the form "symptom"/ into
a DiagnosticTest object. The test and result components of the test
are not specified.
If the component is not specified, it is assumed to be "yes".
- Parameters:
s
- a String
valuewd
- a WorkshopDatabase
in which to search for the test name- Returns:
- a
DiagnosticTest
value - See Also:
parseSymptom
parseHistory
public static MedicalHistory parseHistory(java.lang.String s,
WorkshopDatabase wd)
- Parses a symptom specification of the form "symptom"/ into
a MedicalHistory object.
If the component is not specified, it is assumed to be "yes".
- Parameters:
s
- a String
valuewd
- a WorkshopDatabase
in which to search for the history item name- Returns:
- a
MedicalHistory
value - See Also:
parseSymptom