|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object standup.profiling.Profile standup.lexicon.ProfileLexicon
public class ProfileLexicon
A Profile
relating to lexical resources.
An instance of ProfileLexicon
is actually a simple wrapper class for
an OptionsLexicon
, as it does not contain any added information
other than its OptionsLexicon
.
Field Summary | |
---|---|
private Hashtable<String,File> |
blacklistFiles
|
private Hashtable<String,CustomLexicon> |
blacklists
|
private Hashtable<String,File> |
customlexiconFiles
|
private Hashtable<String,CustomLexicon> |
customlexicons
|
private Hashtable<String,File> |
roottopicFiles
|
private Hashtable<String,Topic> |
roottopics
|
static String |
XMLTAG
|
Constructor Summary | |
---|---|
ProfileLexicon()
|
|
ProfileLexicon(Element element)
|
|
ProfileLexicon(File profileFile)
|
|
ProfileLexicon(Options options)
|
|
ProfileLexicon(URL profileURL)
|
Method Summary | |
---|---|
void |
addBlacklist(CustomLexicon blacklist)
Adds the given blacklist to this profile, and saves it to a file with the default name of <label>.blacklist (where label is the
given blacklist's label) in the directory returned by
ProfileManager.getLexiconDirectory(String) . |
void |
addBlacklist(CustomLexicon blacklist,
String filename)
Adds the given blacklist to this profile, and saves it to a file with the given filename in the directory returned by ProfileManager.getLexiconDirectory(String) . |
void |
addCustomLexicon(CustomLexicon customLexicon)
Adds the given custom lexicon to this profile, and saves it to a file with the default name of <label>.lexicon (where label is
the given custom lexicon's label) in the directory returned by
ProfileManager.getLexiconDirectory(String) . |
void |
addCustomLexicon(CustomLexicon customLexicon,
String filename)
Adds the given custom lexicon to this profile, and saves it to a file with the given filename in the directory returned by ProfileManager.getLexiconDirectory(String) . |
void |
addTopic(Topic topic)
Adds the given topic to this profile, and saves it to a file with the default name of <label>.topic (where label is the given
topic's root label) in the directory returned by
ProfileManager.getLexiconDirectory(String) . |
void |
addTopic(Topic topic,
String filename)
Adds the given topic to this profile, and saves it to a file with the given filename in the directory returned by ProfileManager.getLexiconDirectory(String) . |
OptionsLexicon |
createDefaultOptions()
Returns an appropriate instance of Options with default values,
i.e. |
CustomLexicon |
getBlacklist(String label)
Returns the blacklist CustomLexicon with the given label. |
Iterator<String> |
getBlacklistLabels()
Returns an iterator of the labels of all the blacklist CustomLexicon s contained within this ProfileLexicon . |
CustomLexicon |
getCustomLexicon(String label)
Returns the CustomLexicon with the given label. |
Iterator<String> |
getCustomLexiconLabels()
Returns an iterator of the labels of all the CustomLexicon s
contained within this ProfileLexicon . |
private File |
getLexicalFile(String filename)
|
OptionsLexicon |
getOptions()
Returns the Options contained within this Profile . |
Topic |
getRootTopic(String label)
Returns the root Topic with the given label. |
Iterator<String> |
getRootTopicLabels()
Returns an iterator of the labels of all the root Topic s
contained within this ProfileLexicon . |
OptionsLexicon |
loadOptions(Element element)
Returns an appropriate instance of Options whose values are taken
from the given XML Element. |
void |
quickSave(File file)
Saves this Profile but not any associated files along with it. |
void |
removeBlacklist(CustomLexicon blacklist,
boolean deleteFileAsWell)
Removes the given blacklist from this profile. |
void |
removeCustomLexicon(CustomLexicon customLexicon,
boolean deleteFileAsWell)
Removes the given custom lexicon from this profile. |
void |
removeTopic(Topic topic,
boolean deleteFileAsWell)
Removes the given topic from this profile. |
void |
save(File file)
This method saves the necessary information contained within an instance to an XML file. |
boolean |
setOptions(Options incomingOptions)
Makes the given Options the one used within this Profile . |
void |
writeXML(Writer out,
String indent)
This method writes the necessary information contained within an instance to an XML file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String XMLTAG
private Hashtable<String,Topic> roottopics
private Hashtable<String,CustomLexicon> customlexicons
private Hashtable<String,CustomLexicon> blacklists
private Hashtable<String,File> roottopicFiles
private Hashtable<String,File> customlexiconFiles
private Hashtable<String,File> blacklistFiles
Constructor Detail |
---|
public ProfileLexicon() throws ProfileException
ProfileException
public ProfileLexicon(Element element)
public ProfileLexicon(File profileFile)
public ProfileLexicon(Options options)
public ProfileLexicon(URL profileURL)
Method Detail |
---|
public OptionsLexicon getOptions()
Profile
Options
contained within this Profile
. It
might be useful to override this method to return the options cast as the
appropriate specific Options
subclass.
getOptions
in class Profile
private File getLexicalFile(String filename) throws ProfileException
ProfileException
public boolean setOptions(Options incomingOptions)
Profile
Options
the one used within this Profile
.
Always returns true
. Override this method to do validation that
the given Options
is indeed appropriate for the particular
subclass of Profile
.
setOptions
in class Profile
public void writeXML(Writer out, String indent) throws IOException, XMLException
XMLizable
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.
IOException
XMLException
public void quickSave(File file) throws XMLException
Profile
Profile
but not any associated files along with it.
This is for profiles which may depend on other files aside from the XML
file created by ProfileManager
. For example, the joke generation
backend ProfileJokeGeneration
contains pointers to XML files that
contain the custom lexicon, topic database, etc. If a Profile
doesn't have any such files, this method behaves the same as
XMLsaveable.save(File)
.
quickSave
in class Profile
file
- the file to which this Profile
should be saved.
XMLException
public void save(File file) throws XMLException
XMLsaveable
file
,XMLizable.writeXML(java.io.Writer, String)
, and
file
- The file to be saved.
XMLException
public OptionsLexicon createDefaultOptions() throws ProfileException
Profile
Options
with default values,
i.e. those contained with the default options package (see
ProfileManager.getDefaultOptionsPackage()
).
createDefaultOptions
in class Profile
ProfileException
public OptionsLexicon loadOptions(Element element)
Profile
Options
whose values are taken
from the given XML Element.
loadOptions
in class Profile
public Iterator<String> getRootTopicLabels()
Topic
s
contained within this ProfileLexicon
.
public Iterator<String> getCustomLexiconLabels()
CustomLexicon
s
contained within this ProfileLexicon
.
public Iterator<String> getBlacklistLabels()
CustomLexicon
s contained within this ProfileLexicon
.
public Topic getRootTopic(String label)
Topic
with the given label.
label
- The label of the root topic to be retrieved.
Topic
that has the given label, or
null
if this ProfileLexicon
does not contain a
root topic with that label.public CustomLexicon getCustomLexicon(String label)
CustomLexicon
with the given label.
label
- The label of the custom lexicon to be retrieved.
CustomLexicon
that has the given label, or
null
if this ProfileLexicon
does not contain a
custom lexicon with that label.public CustomLexicon getBlacklist(String label)
CustomLexicon
with the given label.
label
- The label of the blacklist custom lexicon to be retrieved.
CustomLexicon
that has the given label, or
null
if this ProfileLexicon
does not contain a
blacklist custom lexicon with that label.public void addTopic(Topic topic) throws LexiconException
<label>.topic
(where label
is the given
topic's root label) in the directory returned by
ProfileManager.getLexiconDirectory(String)
.
If the given topic exists, or another one with the same root label exists, or a file with the same default filename exists, it will not add the topic and instead throw a {@link LexiconException}.
topic
-
LexiconException
public void addTopic(Topic topic, String filename) throws LexiconException
ProfileManager.getLexiconDirectory(String)
.
If the given topic exists, or another one with the same root label exists, or a file with the same name exists, it will not add the topic and instead throw a {@link LexiconException}.
To obey the contract of filenaming, the given filename should end with a {@code .topic} extension.
topic
- filename
-
LexiconException
public void addCustomLexicon(CustomLexicon customLexicon) throws LexiconException
<label>.lexicon
(where label
is
the given custom lexicon's label) in the directory returned by
ProfileManager.getLexiconDirectory(String)
.
If the given custom lexicon exists, or another one with the same label exists, or a file with the same default filename exists, it will not add the custom lexicon and instead throw a {@link LexiconException}.
customLexicon
-
LexiconException
public void addCustomLexicon(CustomLexicon customLexicon, String filename) throws LexiconException
ProfileManager.getLexiconDirectory(String)
.
If the given custom lexicon exists, or another one with the same label exists, or a file with the same name exists, it will not add the custom lexicon and instead throw a {@link LexiconException}.
To obey the contract of filenaming, the given filename should end with a {@code .lexicon} extension.
customLexicon
- filename
-
LexiconException
public void addBlacklist(CustomLexicon blacklist) throws LexiconException
<label>.blacklist
(where label
is the
given blacklist's label) in the directory returned by
ProfileManager.getLexiconDirectory(String)
.
If the given blacklist exists, or another one with the same label exists, or a file with the same default filename exists, it will not add the blacklist and instead throw a {@link LexiconException}.
customLexicon
-
LexiconException
public void addBlacklist(CustomLexicon blacklist, String filename) throws LexiconException
ProfileManager.getLexiconDirectory(String)
.
If the given blacklist exists, or another one with the same label exists, or a file with the same name exists, it will not add the custom lexicon and instead throw a {@link LexiconException}.
To obey the contract of filenaming, the given filename should end with a {@code .blacklist} extension.
blacklist
- filename
-
LexiconException
public void removeTopic(Topic topic, boolean deleteFileAsWell) throws LexiconException
true
, it will also delete the corresponding
file under the directory returned by
ProfileManager.getLexiconDirectory(String)
. If it is
false
, it will retain the file.
If the topic didn't previously exist in this profile, it throws a
LexiconException
.
topic
- deleteFileAsWell
-
LexiconException
public void removeCustomLexicon(CustomLexicon customLexicon, boolean deleteFileAsWell) throws LexiconException
true
, it will also delete the corresponding
file under the directory returned by
ProfileManager.getLexiconDirectory(String)
. If it is
false
, it will retain the file.
If the custom lexicon didn't previously exist in this profile, it throws a
LexiconException
.
customLexicon
- deleteFileAsWell
-
LexiconException
public void removeBlacklist(CustomLexicon blacklist, boolean deleteFileAsWell) throws LexiconException
true
, it will also delete the corresponding
file under the directory returned by
ProfileManager.getLexiconDirectory(String)
. If it is
false
, it will retain the file.
If the blacklist didn't previously exist in this profile, it throws a
LexiconException
.
blacklist
- deleteFileAsWell
-
LexiconException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |