|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object standup.lexicon.LexemeSet standup.lexicon.CustomLexicon
public class CustomLexicon
A CustomLexicon
is a LexemeSet
that has a label and is
XMLsaveable
. The accessor functions of adding and removing
Lexeme
s also update modified
, a boolean
field
which can be used to determine whether this CustomLexicon
is
consistent with its XML copy on disk. Also has a boolean
field
active
which indicates whether or not it is active within its
containing LexicalComponents
.
Field Summary | |
---|---|
(package private) boolean |
active
Signifies whether this custom lexicon is currently activated in the working lexicon. |
protected String |
label
An identifier for this CustomLexicon . |
private boolean |
modified
Signifies whether this custom lexicon has been changed with respect to the local copy on disk. |
Fields inherited from class standup.lexicon.LexemeSet |
---|
set |
Constructor Summary | |
---|---|
CustomLexicon(Element doc)
Constructor method for loading an existing CustomLexicon from the
given XML Element . |
|
CustomLexicon(File file)
Constructor method for loading an existing CustomLexicon from the
given File . |
|
CustomLexicon(String l)
Constructor method for the creation of a new, empty, CustomLexicon . |
|
CustomLexicon(String l,
Collection<Lexeme> lexemes)
Constructor method for the creation of an existing collection of Lexeme s, e.g. |
|
CustomLexicon(URL url)
Constructor method for loading an existing CustomLexicon from the
file pointed to by the given URL . |
Method Summary | |
---|---|
boolean |
add(Lexeme l)
Tries to add the given Lexeme to this CustomLexicon . |
boolean |
add(LexemeSet ls)
Tries to add the Lexeme s contained within the given
LexemeSet to this CustomLexicon , effectively making this
CustomLexicon the union of the two. |
CustomLexicon |
duplicate()
Returns a duplicate of this CustomLexicon . |
boolean |
equals(Object obj)
|
String |
getLabel()
Returns the label of this CustomLexicon . |
int |
hashCode()
|
boolean |
isActive()
Returns true if this CustomLexicon is to be considered
active within a {@link LexicalComponents}, {@code false}
otherwise. |
boolean |
isModified()
Returns true if this CustomLexicon has been modified
since the last time it was loaded from/saved to disk, false
otherwise. |
boolean |
remove(Lexeme l)
Tries to remove the given Lexeme from this CustomLexicon . |
boolean |
remove(LexemeSet ls)
Tries to remove the Lexeme s contained within the given
LexemeSet from this CustomLexicon . |
Lexeme |
removeRandom()
Tries to remove a random Lexeme from this CustomLexicon
and return it. |
void |
rename(String newLabel)
Renames the label of this CustomLexicon . |
void |
save(File file)
Implementation of {@link XMLsaveable#save(File). |
boolean |
setActive(boolean newValue)
Sets the value to be returned by isActive() . |
void |
setModified(boolean mod)
Sets the value to be returned by isModified() . |
String |
toString()
|
void |
writeXML(Writer out,
String indent)
Implementation of XMLizable.writeXML(Writer, String) . |
Methods inherited from class standup.lexicon.LexemeSet |
---|
addLexemesFromXML, contains, getLexemeCount, getLexemes, getLexemesIterator, getRandom, getSpelledClusters, getSpelledLexemes, getSpelledLexemes, isEmpty |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private boolean modified
protected String label
CustomLexicon
. It must be unique within
its containing LexicalComponents
. Note that this label is saved
to disk, so there are potential naming conflicts when
CustomLexicon
s are loaded and saved to/from different
LexicalComponents
.
boolean active
Constructor Detail |
---|
public CustomLexicon(String l)
CustomLexicon
. Sets both modified
and active
to
true
.
l
- the label for the newly created CustomLexicon
public CustomLexicon(String l, Collection<Lexeme> lexemes)
Lexeme
s, e.g. by reading it from disk. Sets both
modified
and active
to true
.
l
- the label for the newly created CustomLexicon
lexemes
- a Collection
of Lexeme
s to be added to the
newly created CustomLexicon
public CustomLexicon(URL url)
CustomLexicon
from the
file pointed to by the given URL
. Sets modified
of the
resulting instance to false
and active
to true
.
url
- public CustomLexicon(File file)
CustomLexicon
from the
given File
. Sets modified
of the resulting instance to
false
and active
to true
.
file
- public CustomLexicon(Element doc)
CustomLexicon
from the
given XML Element
. Sets modified
of the resulting
instance to false
and active
to true
.
doc
- the XML Element
containing the CustomLexicon
details. It should have been the output of
writeXML(Writer, String)
.Method Detail |
---|
public int hashCode()
hashCode
in class LexemeSet
public boolean equals(Object obj)
equals
in class LexemeSet
public String toString()
toString
in class LexemeSet
public CustomLexicon duplicate()
CustomLexicon
. Sets modified
of the returned CustomLexicon
to true
.
duplicate
in class LexemeSet
public boolean add(Lexeme l)
Lexeme
to this CustomLexicon
.
Additionally, if this CustomLexicon
changed as a result of the
addition, sets modified
to true
.
add
in class LexemeSet
l
- the Lexeme
to be added to this object
true
if this object changed as a result, or false
if the Lexeme
already exists in this objectpublic boolean add(LexemeSet ls)
Lexeme
s contained within the given
LexemeSet
to this CustomLexicon
, effectively making this
CustomLexicon
the union of the two. Additionally, if this
CustomLexicon
changed as a result of the addition, sets
modified
to true
.
add
in class LexemeSet
ls
- the LexemeSet
to be added to this object
true
if this object changed as a result, or false
if all the Lexeme
s in the given LexemeSet
already exist in this objectpublic boolean remove(Lexeme l)
Lexeme
from this CustomLexicon
.
Additionally, if this CustomLexicon
changed as a result of the
removal, sets modified
to true
.
remove
in class LexemeSet
l
- the Lexeme
to be removed from this object
true
if this object changed as a result, or false
if the Lexeme
did not previously exist in this objectpublic boolean remove(LexemeSet ls)
Lexeme
s contained within the given
LexemeSet
from this CustomLexicon
. Additionally, if this
CustomLexicon
changed as a result of the removal, sets
modified
to true
.
remove
in class LexemeSet
ls
- the LexemeSet
to be removed from this object
true
if this object changed as a result, or false
if all the Lexeme
s in the given LexemeSet
did
not previously exist in this objectpublic Lexeme removeRandom()
Lexeme
from this CustomLexicon
and return it. Additionally, if this CustomLexicon
changed as a
result, sets modified
to true
.
removeRandom
in class LexemeSet
Lexeme
public boolean isModified()
true
if this CustomLexicon
has been modified
since the last time it was loaded from/saved to disk, false
otherwise.
public void setModified(boolean mod)
isModified()
.
mod
- the new value of modified
public String getLabel()
CustomLexicon
.
public void rename(String newLabel)
CustomLexicon
.
newLabel
- the new label for this CustomLexicon
public boolean isActive()
true
if this CustomLexicon
is to be considered
active within a {@link LexicalComponents}, {@code false}
otherwise.
public boolean setActive(boolean newValue)
isActive()
.
newValue
- the new value of active
active
public void writeXML(Writer out, String indent) throws IOException, XMLException
XMLizable.writeXML(Writer, String)
.
writeXML
in interface XMLizable
writeXML
in class LexemeSet
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 save(File file)
save
in interface XMLsaveable
file
- the file where this CustomLexicon
is to be saved
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |