standup.lexicon
Class Keyword

java.lang.Object
  extended by standup.lexicon.StructElement
      extended by standup.lexicon.Keyword
All Implemented Interfaces:
SQLSelectElement, Unifiable, XMLizable
Direct Known Subclasses:
Lexeme, WordForm, WordString

public abstract class Keyword
extends StructElement
implements Unifiable, SQLSelectElement

A Keyword is an object appearing in a WordStruct that is not 'canned' or 'filler' text. Although defined in the standup.lexicon package, its significance relates primarily to the joke generation functionality in the standup.joke package, where Keywords are obtained through Schema or Clause instantiation and thus must be handled separately from canned text.

Author:
Ruli Manurung

Field Summary
private static String LEXEME_SQL_PREFIX
           
private static String WORDFORM_SQL_PREFIX
           
 
Constructor Summary
Keyword()
           
 
Method Summary
static Keyword createKeyword(String sqlResult)
          Returns an appropriate Keyword given a String returned by an SQL query for Schema or Clause instantiations.
 Unifiable duplicate()
          An implementation of Unifiable.duplicate().
private static boolean isSQLLexemeID(String id)
          Returns true if the given String, returned by an SQL query, represents a Lexeme ID, and false otherwise.
private static boolean isSQLWordFormID(String id)
          Returns true if the given String, returned by an SQL query, represents a WordForm ID, and false otherwise.
static Keyword readXML(Element keywordParentElement)
          Looks for a single XML tag representing a Keyword under the given XML Element and returns an appropriate instance.
static List<Keyword> readXMLList(Element keywordListElement)
          Looks for all XML tags representing a keyword under the given XML Element and returns an appropriate list of instantiated Keywords.
 
Methods inherited from class standup.lexicon.StructElement
getSpelling
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface standup.sql.SQLSelectElement
getSQLSelectString
 
Methods inherited from interface standup.xml.XMLizable
writeXML
 

Field Detail

WORDFORM_SQL_PREFIX

private static String WORDFORM_SQL_PREFIX

LEXEME_SQL_PREFIX

private static String LEXEME_SQL_PREFIX
Constructor Detail

Keyword

public Keyword()
Method Detail

isSQLWordFormID

private static boolean isSQLWordFormID(String id)
Returns true if the given String, returned by an SQL query, represents a WordForm ID, and false otherwise.

Parameters:
id -
Returns:

isSQLLexemeID

private static boolean isSQLLexemeID(String id)
Returns true if the given String, returned by an SQL query, represents a Lexeme ID, and false otherwise.

Parameters:
id -
Returns:

createKeyword

public static Keyword createKeyword(String sqlResult)
Returns an appropriate Keyword given a String returned by an SQL query for Schema or Clause instantiations.

Parameters:
sqlResult -
Returns:
if sqlResult represents a lexeme ID, it returns the referenced Lexeme. If sqlResult represents a wordform ID, it returns the referenced WordForm. Otherwise, it returns a WordString.

duplicate

public Unifiable duplicate()
An implementation of Unifiable.duplicate().

Specified by:
duplicate in interface Unifiable

readXML

public static Keyword readXML(Element keywordParentElement)
                       throws XMLException
Looks for a single XML tag representing a Keyword under the given XML Element and returns an appropriate instance.

Parameters:
keywordParentElement -
Returns:
if keywordElement contains an lx123456 tag, it will return Dictionary.getLexeme("lx123456"). If keywordElement contains a wf123456 tag, it will return Dictionary.getWordForm("wf123456"). If keywordElement contains a xyz tag, it will return new WordString("xyz").
Throws:
XMLException

readXMLList

public static List<Keyword> readXMLList(Element keywordListElement)
                                 throws XMLException
Looks for all XML tags representing a keyword under the given XML Element and returns an appropriate list of instantiated Keywords.

Parameters:
keywordListElement -
Returns:
if keywordListElement contains an lx123456 tag, it will add Dictionary.getLexeme("lx123456") to the returned list. If it contains a wf123456 tag, it will add Dictionary.getWordForm("wf123456"). Finally, if it contains a xyz tag, it will add new WordString("xyz").
Throws:
XMLException