|
||||||||||
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 standup.lexicon.Topic
public class Topic
A Topic
represents a collection of Lexeme
s that are related
in some sense, e.g. thematically.
A Topic
also has a list of subtopics, potentially forming a
hierarchical structure of sets of Lexeme
s.
As implemented, a Topic
is essentially a CustomLexicon
with a
list of sub Topic
s.
Field Summary | |
---|---|
private List<String> |
cachedImageFiles
|
private SymbolType[] |
cachedSymbolSet
|
protected String |
conceptCode
An optional field that contains the Widgit 'real' conceptcode that specifies the symbol to be associated with this topic. |
protected Topic |
parent
The parent of this Topic . |
protected Vector<Topic> |
subtopics
A Vector of subtopics, each of which must also be a Topic . |
Fields inherited from class standup.lexicon.CustomLexicon |
---|
active, label |
Fields inherited from class standup.lexicon.LexemeSet |
---|
set |
Constructor Summary | |
---|---|
|
Topic(Element topicElement)
Constructor that loads a root Topic specified in the
given XML Element . |
|
Topic(File file)
Constructor that loads a Topic from an existing File . |
private |
Topic(Topic parent,
Element topicElement)
Constructor that loads a Topic specified in the given XML
Element . |
|
Topic(Topic p,
String l,
String c)
Constructor for creating a new Topic with parent p, label l, and
conceptcode c. |
|
Topic(URL url)
Constructor that loads a Topic from an existing file referenced
by the given URL . |
Method Summary | |
---|---|
void |
addSubtopic(Topic t)
Adds the given Topic to the list of subtopics. |
private static void |
doTopicList(Topic t,
Element topicListElement)
Processes a Topic 's list of subtopics from its XML
Element . |
Topic |
duplicate()
Returns a duplicate of this CustomLexicon . |
boolean |
equals(Object obj)
|
LexemeSet |
getAllKeywords()
Returns a LexemeSet that contains the union of all Lexeme s
associated with this Topic and, recursively, all Lexeme s
associated with all of its subtopics. |
String |
getConceptCode()
Returns the Widgit conceptcode associated with this Topic . |
List<String> |
getImageFile(SymbolType[] symbolSet)
This method returns the path and filename for the symbol representing this Topic , if one has been specified. |
String |
getLabelFromRoot()
Returns a String that shows the path to this Topic from
its root, e.g. |
Topic |
getParentTopic()
Returns the parent of this Topic , or null if it's a root
topic. |
int |
getSubtopicCount()
Returns the number of subtopics this Topic has. |
Iterator<Topic> |
getSubtopics()
Returns an Iterator of all the subtopics of this Topic . |
private static String |
handleConceptCode(Element topicElement)
Reads the 'conceptcode' tag of a Topic from its XML tag. |
int |
hashCode()
|
boolean |
hasNamedSubtopic(String l)
Returns true either if this Topic has label l ,
or has a descendent with label l , and false otherwise. |
private String |
indent(int n)
|
boolean |
isAncestorOf(Topic t)
Returns true if this Topic is an ancestor of the given
Topic , false otherwise. |
boolean |
isDescendantOf(Topic t)
Returns true if this Topic is a descendant of the given
Topic , false otherwise. |
boolean |
isModified()
Returns true if this Topic , or any of its subtopics, has
been modified since the last time it was loaded from/saved to disk,
false otherwise. |
String |
prettyPrint()
Returns a nice tree-structured text output of this Topic . |
private String |
prettyPrint(int n)
|
void |
removeSubtopic(Topic t)
Removes the given Topic from this Topic 's list of
subtopics. |
void |
save(File file)
Implementation of {@link XMLsaveable#save(File). |
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.CustomLexicon |
---|
add, add, getLabel, isActive, remove, remove, removeRandom, rename, setActive |
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 |
---|
protected final Vector<Topic> subtopics
Vector
of subtopics, each of which must also be a Topic
.
protected Topic parent
Topic
. Its value is null
if this
Topic
is a root topic.
protected final String conceptCode
null
there is no image associated with it.
private transient List<String> cachedImageFiles
private transient SymbolType[] cachedSymbolSet
Constructor Detail |
---|
public Topic(Topic p, String l, String c)
Topic
with parent p, label l, and
conceptcode c. It starts with no related Lexeme
s and no
subtopics.
p
- the parent topic -- null
if the Topic
to be
created is a root topicl
- the label for the new Topic
c
- the Widgit conceptcode to be associated with this
Topic
public Topic(URL url)
Topic
from an existing file referenced
by the given URL
.
url
- public Topic(File file)
Topic
from an existing File
.
file
- public Topic(Element topicElement)
Topic
specified in the
given XML Element
.
topicElement
- private Topic(Topic parent, Element topicElement)
Topic
specified in the given XML
Element
. The instantiated Topic
will be a subtopic of
the given parent.
parent
- topicElement
- Method Detail |
---|
private static String handleConceptCode(Element topicElement)
Topic
from its XML tag.
topicElement
-
private static void doTopicList(Topic t, Element topicListElement) throws LexiconException
Topic
's list of subtopics from its XML
Element
.
t
- the parent Topic
of the specified subtopicstopicListElement
- the XML Element
containing the specification of the
subtopics
LexiconException
public int hashCode()
hashCode
in class CustomLexicon
public boolean equals(Object obj)
equals
in class CustomLexicon
public String toString()
toString
in class CustomLexicon
public String getConceptCode()
Topic
.
public Topic duplicate()
CustomLexicon
CustomLexicon
. Sets modified
of the returned CustomLexicon
to true
.
duplicate
in class CustomLexicon
public boolean isModified()
true
if this Topic
, or any of its subtopics, has
been modified since the last time it was loaded from/saved to disk,
false
otherwise.
isModified
in class CustomLexicon
public void setModified(boolean mod)
isModified()
. Additionally, if
mod
is false
, all of its subtopics are
setModified(false)
as well.
setModified
in class CustomLexicon
mod
- the new value of modified
public Topic getParentTopic()
Topic
, or null
if it's a root
topic.
public String getLabelFromRoot()
String
that shows the path to this Topic
from
its root, e.g. "root > animals > farmyard"
.
public boolean hasNamedSubtopic(String l)
true
either if this Topic
has label l
,
or has a descendent with label l
, and false
otherwise.
l
-
public boolean isAncestorOf(Topic t)
true
if this Topic
is an ancestor of the given
Topic
, false
otherwise.
t
-
public boolean isDescendantOf(Topic t)
true
if this Topic
is a descendant of the given
Topic
, false
otherwise.
t
-
public void addSubtopic(Topic t) throws LexiconException
Topic
to the list of subtopics.
This effectively adds the relationship is_a(t,this)
.
Additionally, it sets modified
to true
). Checks for
additions which would result in ill-formed trees (i.e. cycles), and
throws a LexiconException
if detected.
t
-
LexiconException
public void removeSubtopic(Topic t) throws LexiconException
Topic
from this Topic
's list of
subtopics.
This effectively removes the relationship is_a(t,this)
.
Additionally, if the removal was succesful, it sets modified
to
true
).
t
-
LexiconException
public Iterator<Topic> getSubtopics()
Iterator
of all the subtopics of this Topic
.
public int getSubtopicCount()
Topic
has.
public LexemeSet getAllKeywords()
LexemeSet
that contains the union of all Lexeme
s
associated with this Topic
and, recursively, all Lexeme
s
associated with all of its subtopics.
public List<String> getImageFile(SymbolType[] symbolSet) throws SymbolException
Topic
, if one has been specified. The symbol is assumed to
exist in the location that
SymbolManager#getImageFile(String, SymbolType[], boolean)
expects to
find it.
symbolset
- an array indicating the preference of which SymbolType
is to be used
SymbolException
public void writeXML(Writer out, String indent) throws IOException, XMLException
XMLizable.writeXML(Writer, String)
.
writeXML
in interface XMLizable
writeXML
in class CustomLexicon
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)
CustomLexicon
save
in interface XMLsaveable
save
in class CustomLexicon
file
- the file where this CustomLexicon
is to be savedpublic String prettyPrint()
Topic
.
private String prettyPrint(int n)
private String indent(int n)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |