Webster Specification
Classes : Webster Transformer
Tagger Texter DefResult Dictionary Output Update
doGet()
- open DB connection
- (Transformer sequence)
- Create Transformer
- Call Transformer.transform()
- close DB connection
doPost()
- open DB connection
- (Update sequence)
- Create Update
- close DB connection
void transform(String TargetURL, Output out, String ServletURL, String Category,
Connection conn)
- Create Output and Texter classes
- Call getPage() and get an Page object
- Call walktree(Page.getRootElement(), null)
Page getPage(String TargetURL)
- Retrieve page from TargetURL
- Run LinkTransform on a page
- Return a Page object
void walkTree(Element thisNode, String LinkURL)
- Create Tagger object from start tag
- Check status code
- Call output.endPage()
void Tagger()
int checkTag(tag)
- set newTag to tag
- If tag is link, frame, or area; modify and set newTag to the modified tag
- If tag is anchor, set LinkURL to HREF attribute
- Set status code according to tag type
- COMMENT - applet, script, <!--, pre
- LINK - anchor tag with HREF attribute
- MODIFIED - frame or area
- OTHER - anything else, including anchor tags without HREF
- Return status code
String getModifiedTag()
String getLinkURL()
Texter(String Category, Connection conn, String ServletURL)
String transform(String Text, String LinkURL)
DefResult(int NumMatches, String Definition, String DefURL)
- Set internal storage variables
int getNumMatches()
String getDefinition()
String getDefURL()
DefResult lookup(Connection conn, String Text, String Category, boolean ExactMatch)
- Do SQL SELECT on "Text*" if ExactMatch = false, or on "Text" if
exact match = true
- Create and return DefResult object with number of records in resultset, first matching
definition, and its URL
Vector listCategories(Connection conn)
- Do SQL SELECT on table Categories and return the result as a Vector
int addCategory(Connection conn, String Category)
- Check if category exists
- Add category to category table
- Return 0 if successful, greater than 0 if not
int deleteCategory(Connection conn, String Category)
- Check if category exists
- Add category to category table
- Return 0 if successful, greater than 0 if not
int addWord(Connection conn, String Word, String DefURL, String Category)
- Check if category exists
- Add word and definition to category in definition table
- Return 0 if successful, greater than 0 if not
int addManyWords(Connection conn, Vector wordlinkPairs, String Category)
- Check if category exists
- Add many words and definitions to the category in definition table
- If word and definition already exist, delete the current definition, insert the new
definition
- Return 0 if successful, greater than 0 if not
int deleteWord(Connection conn, String Word, String Category)
- Check if category exists
- Delete word from definition table
- Return 0 if successful, greater than 0 if not
int deleteManyWords(Connection conn, Vector Words, String Category)
- Check if category exists
- Delete words of the Category from definition table
- Return 0 if successful, greater than 0 if not
Connection openDB()
- Open a connection to the mSQL database
- Return the new connection
void closeDB(Connection conn)
- Close the database connection
int addManyWords(Connection conn, Vector wordLinkPairs, String thisCategory)
- Add words in wordLinkPairs to the database at one time
Output(PrintWriter out)
- Sets private out variable to out
void println(String Text)
void endPage(String PageURL)
- out.println("<A HREF=\"" + PageURL + "\">Click here to
view the original page.</A>");
void errorFull(String ErrorMsg)
- out.println("<HTML><BODY>" + ErrorMsg +
"</BODY></HTML>");
void errorHalf(String ErrorMsg)
- out.println(ErrorMsg + "</BODY></HTML>");
void mainPage(Vector cat)
- print the main WEBster page
- includes a pull-down category list supplied in Vector cat
update(HttpServletRequest request, Output output, Connection conn)
addWords(HttpServletRequest request)
(Step 1)
- Call Dictionary.listCategories()
- Output categories in Vector
- Ouput 10 pairs of boxes for words and links to definitions
- "Add" button on bottom of page
(Step 2)
- Get category from request
- Look in request object for fields
- Check URL syntax (and warn if link doesn't exist?)
- Check for duplicates by inserting word and link and looking for errors
- For every word and link, output status : success / fail
- If fields filled = 10, goto step 1
- Otherwise, link to the main screen
deleteWords(HttpServletRequest request)
(Step 1)
- Display list of categories
- Put select button on bottom
(Step 2)
- Display a bunch of checkboxes across the top of the screen and a Post button (A-Z, 0-9)
- Check for checkboxes checked
- Call Dictionary.listWords with checked letters
- Output words, links, and checkboxes
- Put a delete button on the bottom of the page
(Step 3)
- Loop through each word
- Delete word
- Output status of each word
- Display A-Z list with link to the main menu
addCategory(HttpServletRequest request)
(Step 1)
- Display text box
- Display Add Category button
(Step 2)
- Add category to list using Dictionary.addCategory
- Return status
- Link to the main menu
deleteCategory(HttpServletRequest request)
(Step 1)
- Display list of categories using Dictionary.listCategories()
- Display Delete Category button
(Step 2)
- Prompt "Are you sure you want to delete this category?"
- Display Yes/No buttons
- Put category in hidden field
(Step 3)
- Get and check the user's response
- If no, display the main menu by calling mainMenu
- If yes, call Dictionary.deleteCategory() and display the status with a link to the main
menu
mainMenu(HttpServletRequest request)
(Step 1)
- display administrator's menu of options