standup.lexicon
Class OptionsLexicon

java.lang.Object
  extended by standup.profiling.Options
      extended by standup.lexicon.OptionsLexicon
All Implemented Interfaces:
XMLizable

public class OptionsLexicon
extends Options

A subclass of Options that stores user-specific settings for a ProfileLexicon. It contains filenames of the custom lexicons, blacklists, and topics. The filenames are assumed relative to the path returned by ProfileManager.getLexiconDirectory(String).

Note that the custom lexicons, topics and blacklists are not instantiated -- they are assumed to exist in the referenced files. If the files do not exist, or are ill-formed, it will probably be found out when LexicalComponents.setProfile(standup.profiling.Profile, boolean) is called.

Author:
Ruli Manurung

Field Summary
private  Set<String> blacklistFilenames
           
private  Set<String> customLexiconFilenames
           
private static String TAG_BLACKLISTS
           
private static String TAG_CUSTOMLEXICONS
           
static String TAG_ROOT
           
private static String TAG_TOPICS
           
private  Set<String> topicFilenames
           
 
Constructor Summary
OptionsLexicon()
          Constructor that uses the values in the default options package.
OptionsLexicon(Element rootElement)
          Constructor that uses the values specified by the given XML Element.
OptionsLexicon(Set<String> customLexiconFilenames, Set<String> blacklistFilenames, Set<String> topicFilenames)
          Constructor that provides all filenames of the custom lexicons, blacklists, and topics.
 
Method Summary
 boolean addBlacklistFilename(String filename)
          Adds the given filename to the list of blacklist filenames stored within this OptionsLexicon.
 boolean addCustomLexiconFilename(String filename)
          Adds the given filename to the list of custom lexicon filenames stored within this OptionsLexicon.
 boolean addTopicFilename(String filename)
          Adds the given filename to the list of topic filenames stored within this OptionsLexicon.
 Set<String> getBlacklistFilenames()
          Returns a List<String> containing the filenames of blacklists in this OptionsLexicon.
 Set<String> getCustomLexiconFilenames()
          Returns a List<String> containing the filenames of custom lexicons in this OptionsLexicon.
 String getDiffString(Options options)
          Returns a String that reports the difference between this instance and the given Options.
 OptionsGUI getGUI(Dimension size)
          For now, simply returns null -- we haven't properly implemented OptionsGUILexicon yet.
 Set<String> getTopicFilenames()
          Returns a List<String> containing the filenames of topics in this OptionsLexicon.
 String getXMLTag()
          Returns the XML tag associated with this implementation of Options.
private static Set<String> parseFilenames(Element filenamesElement)
           
 boolean removeBlacklistFilename(String filename)
          Removes the given filename from the list of blacklist filenames stored within this OptionsLexicon.
 boolean removeCustomLexiconFilename(String filename)
          Removes the given filename from the list of custom lexicon filenames stored within this OptionsLexicon.
 boolean removeTopicFilename(String filename)
          Removes the given filename from the list of topic filenames stored within this OptionsLexicon.
 void writeXML(Writer out, String indent)
          This method writes the necessary information contained within an instance to an XML file.
 
Methods inherited from class standup.profiling.Options
isModified, setModified
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAG_ROOT

public static final String TAG_ROOT
See Also:
Constant Field Values

TAG_CUSTOMLEXICONS

private static final String TAG_CUSTOMLEXICONS
See Also:
Constant Field Values

TAG_BLACKLISTS

private static final String TAG_BLACKLISTS
See Also:
Constant Field Values

TAG_TOPICS

private static final String TAG_TOPICS
See Also:
Constant Field Values

customLexiconFilenames

private Set<String> customLexiconFilenames

blacklistFilenames

private Set<String> blacklistFilenames

topicFilenames

private Set<String> topicFilenames
Constructor Detail

OptionsLexicon

public OptionsLexicon(Set<String> customLexiconFilenames,
                      Set<String> blacklistFilenames,
                      Set<String> topicFilenames)
Constructor that provides all filenames of the custom lexicons, blacklists, and topics. The filenames are assumed relative to the directory returned by ProfileManager#getLexiconDirectory().

Parameters:
customLexiconFilenames -
blacklistFilenames -
topicFilenames -

OptionsLexicon

public OptionsLexicon(Element rootElement)
Constructor that uses the values specified by the given XML Element.

Parameters:
rootElement -

OptionsLexicon

public OptionsLexicon()
               throws ProfileException
Constructor that uses the values in the default options package.

Throws:
ProfileException
See Also:
ProfileManager.getDefaultOptionsPackage()
Method Detail

getGUI

public OptionsGUI getGUI(Dimension size)
For now, simply returns null -- we haven't properly implemented OptionsGUILexicon yet.

Specified by:
getGUI in class Options
Returns:

getCustomLexiconFilenames

public Set<String> getCustomLexiconFilenames()
Returns a List<String> containing the filenames of custom lexicons in this OptionsLexicon.

Returns:

getBlacklistFilenames

public Set<String> getBlacklistFilenames()
Returns a List<String> containing the filenames of blacklists in this OptionsLexicon.

Returns:

getTopicFilenames

public Set<String> getTopicFilenames()
Returns a List<String> containing the filenames of topics in this OptionsLexicon.

Returns:

addCustomLexiconFilename

public boolean addCustomLexiconFilename(String filename)
Adds the given filename to the list of custom lexicon filenames stored within this OptionsLexicon. The filename is assumed to be relative to the directory returned by ProfileManager.getLexiconDirectory(String) for the current user. The custom lexicon itself is not handled at all.

Parameters:
filename -
Returns:
true if the filename did not previously exist in the list of custom lexicon filenames, false otherwise

addBlacklistFilename

public boolean addBlacklistFilename(String filename)
Adds the given filename to the list of blacklist filenames stored within this OptionsLexicon. The filename is assumed to be relative to the directory returned by ProfileManager.getLexiconDirectory(String) for the current user. The blacklist itself is not handled at all.

Parameters:
filename -
Returns:
true if the filename did not previously exist in the list of blacklist filenames, false otherwise

addTopicFilename

public boolean addTopicFilename(String filename)
Adds the given filename to the list of topic filenames stored within this OptionsLexicon. The filename is assumed to be relative to the directory returned by ProfileManager.getLexiconDirectory(String) for the current user. The topic itself is not handled at all.

Parameters:
filename -
Returns:
true if the filename did not previously exist in the list of topic filenames, false otherwise

removeCustomLexiconFilename

public boolean removeCustomLexiconFilename(String filename)
Removes the given filename from the list of custom lexicon filenames stored within this OptionsLexicon. The filename is assumed to be relative to the directory returned by ProfileManager.getLexiconDirectory(String) for the current user. The custom lexicon itself is not handled at all.

Parameters:
filename -
Returns:
true if the filename previously existed in the list of custom lexicon filenames, false otherwise

removeBlacklistFilename

public boolean removeBlacklistFilename(String filename)
Removes the given filename from the list of blacklist filenames stored within this OptionsLexicon. The filename is assumed to be relative to the directory returned by ProfileManager.getLexiconDirectory(String) for the current user. The blacklist itself is not handled at all.

Parameters:
filename -
Returns:
true if the filename previously existed in the list of blacklist filenames, false otherwise

removeTopicFilename

public boolean removeTopicFilename(String filename)
Removes the given filename from the list of topic filenames stored within this OptionsLexicon. The filename is assumed to be relative to the directory returned by ProfileManager.getLexiconDirectory(String) for the current user. The topic itself is not handled at all.

Parameters:
filename -
Returns:
true if the filename previously existed in the list of topic filenames, false otherwise

parseFilenames

private static Set<String> parseFilenames(Element filenamesElement)

getXMLTag

public String getXMLTag()
Description copied from class: Options
Returns the XML tag associated with this implementation of Options.

Specified by:
getXMLTag in class Options
Returns:

writeXML

public void writeXML(Writer out,
                     String indent)
              throws IOException,
                     XMLException
Description copied from interface: XMLizable
This method writes the necessary information contained within an instance to an XML file.

Parameters:
out - The output stream for the XML file, which is assumed to be already opened and writable.
indent - A string to be prepended before every line written by this method. If passed appropriate white space, e.g. XMLUtils.xmlIndent, it can be used to control indentation.
Throws:
IOException
XMLException

getDiffString

public String getDiffString(Options options)
Returns a String that reports the difference between this instance and the given Options. Currently used by the Playback tool.

Specified by:
getDiffString in class Options
Parameters:
options - The Options to be compared against this instance.
Returns:
A String detailing the difference between the two instances.