Package com.sun.speech.freetts
Class Item
java.lang.Object
com.sun.speech.freetts.Item
- All Implemented Interfaces:
Dumpable
Represents a node in a Relation. Items can have shared contents but
each item has its own set of Daughters. The shared contents of an
item (represented by ItemContents) includes the feature set for the
item and the set of all relations that this item is contained in.
An item can be contained in a number of relations and as daughters
to other items. This class is used to keep track of all of these
relationships. There may be many instances of item that reference
the same shared ItemContents.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddDaughter
(Item item) Adds the given item as a daughter to this item.appendItem
(Item originalItem) Appends an item in this list after this item.Creates a new Item, adds it as a daughter to this item and returns the new item.void
dump
(PrintWriter out, int pad, String title) Dumps out this item to the given output stream.boolean
equalsShared
(Item otherItem) Determines if the shared contents of the two items are the same.findFeature
(String pathAndFeature) Finds the feature by following the given path.Finds the item specified by the given path.Retrieves the first daughter of this item.Returns the feature set of this item.Finds the item in the given relation that has the same shared contents.Retrieves the last daughter of this item.getNext()
Gets the next item in this list.getNthDaughter
(int which) Retrieves the Nth daughter of this item.Retrieves the owning Relation.Returns the parent of this item.Gets the previous item in this list.Retrieves the shared contents for this item.Returns the utterance associated with this item.boolean
Determines if this item has daughters.prependItem
(Item originalItem) Prepends an item in this list before this item.toString()
-
Constructor Details
-
Item
Creates an item. The item is coupled to a particular Relation. If shared contents is null a new sharedContents is created.- Parameters:
relation
- the relation that owns this itemsharedContents
- the contents that is shared with others. If null, a new sharedContents is created.
-
-
Method Details
-
getItemAs
Finds the item in the given relation that has the same shared contents.- Parameters:
relationName
- the relation of interest- Returns:
- the item as found in the given relation or null if not found
-
getOwnerRelation
Retrieves the owning Relation.- Returns:
- the relation that owns this item
-
hasDaughters
public boolean hasDaughters()Determines if this item has daughters.- Returns:
- true if this item has daughters
-
getDaughter
Retrieves the first daughter of this item.- Returns:
- the first daughter or null if none
-
getNthDaughter
Retrieves the Nth daughter of this item.- Parameters:
which
- the index of the daughter to return- Returns:
- the Nth daughter or null if none at the given index
-
getLastDaughter
Retrieves the last daughter of this item.- Returns:
- the last daughter or null if none at the given index
-
addDaughter
Adds the given item as a daughter to this item.- Parameters:
item
- the new daughter
-
createDaughter
Creates a new Item, adds it as a daughter to this item and returns the new item.- Returns:
- the newly created item that was added as a daughter
-
getParent
Returns the parent of this item.- Returns:
- the parent of this item
-
getUtterance
Returns the utterance associated with this item.- Returns:
- the utterance that contains this item
-
getFeatures
Returns the feature set of this item.- Returns:
- the feature set of this item
-
dump
Dumps out this item to the given output stream. -
findFeature
Finds the feature by following the given path. Path is a string of ":" or "." separated strings with the following interpretations:- n - next item
- p - previous item
- parent - the parent
- daughter - the daughter
- daughter1 - same as daughter
- daughtern - the last daughter
- R:relname - the item as found in the given relation 'relname'
- Parameters:
pathAndFeature
- the path to follow
-
findItem
Finds the item specified by the given path. Path is a string of ":" or "." separated strings with the following interpretations:- n - next item
- p - previous item
- parent - the parent
- daughter - the daughter
- daughter1 - same as daughter
- daughtern - the last daughter
- R:relname - the item as found in the given relation 'relname'
- Parameters:
path
- the path to follow- Returns:
- the item at the given path
-
getNext
Gets the next item in this list.- Returns:
- the next item or null
-
getPrevious
Gets the previous item in this list.- Returns:
- the previous item or null
-
appendItem
Appends an item in this list after this item.- Parameters:
originalItem
- new item has shared contents with this item (or * null)- Returns:
- the newly appended item
-
prependItem
Prepends an item in this list before this item.- Parameters:
originalItem
- new item has shared contents with this item (or * null)- Returns:
- the newly appended item
-
toString
-