2 * Portions Copyright 2001 Sun Microsystems, Inc.
3 * Portions Copyright 1999-2001 Language Technologies Institute,
4 * Carnegie Mellon University.
5 * All Rights Reserved. Use is subject to license terms.
7 * See the file "license.terms" for information on usage and
8 * redistribution of this file, and for a DISCLAIMER OF ALL
11 package com.sun.speech.freetts;
12 import java.io.PrintWriter;
15 * Contains the information that is shared between multiple items.
17 public class ItemContents {
18 private FeatureSetImpl features;
19 private FeatureSetImpl relations;
24 public ItemContents() {
25 features = new FeatureSetImpl();
26 relations = new FeatureSetImpl();
30 * Adds the given item to the set of relations. Whenever an item
31 * is added to a relation, it should add the name and the Item reference
32 * to this set of name/item mappings. This allows an item to find
33 * out the set of all relations that it is contained in.
35 * @param relationName the name of the relation
36 * @param item the item reference in the relation
38 public void addItemRelation(String relationName, Item item) {
39 // System.out.println("AddItemRelation: " + relationName
40 // + " item: " + item);
41 relations.setObject(relationName, item);
45 * Removes the relation/item mapping from this ItemContents.
47 * @param relationName the name of the relation/item to remove
49 public void removeItemRelation(String relationName) {
50 relations.remove(relationName);
54 public void showRelations() {
55 PrintWriter pw = new PrintWriter(System.out);
56 relations.dump(pw, 0, "Contents relations", true);
61 * Given the name of a relation, returns the item the shares the
64 * @param relationName the name of the relation of interest
66 * @return the item associated with this ItemContents in the named
67 * relation, or null if it does not exist
69 public Item getItemRelation(String relationName) {
70 return (Item) relations.getObject(relationName);
74 * Returns the feature set for this item contents.
76 * @return the FeatureSet for this contents
78 public FeatureSet getFeatures() {