/** * Returns the named feature as an object. If the named feature is not present in the utterance, * then this attempts to retrieve it from the voice. * * @param name the name of the feature * @return the value associated with the name or null if the value is not found */ public Object getObject(String name) { if (!features.isPresent(name)) { return getVoice().getFeatures().getObject(name); } else { return features.getObject(name); } }
/** * Convenience method that returns the named feature as a string. If the named feature is not * present in the utterance, then this attempts to retrieve it from the voice. * * @param name the name of the feature * @return the value associated with the name or null if the value is not found * @throws ClassCastException if the associated value is not a String */ public String getString(String name) { if (!features.isPresent(name)) { return getVoice().getFeatures().getString(name); } else { return features.getString(name); } }
/** * Dumps this utterance in textual form. * * @param output where to send the formatted output * @param pad the initial padding * @param title the title to print when dumping out the utterance * @param justRelations if true don't print voice features */ public void dump(PrintWriter output, int pad, String title, boolean justRelations) { output.println(" ============ " + title + " ========== "); if (!justRelations) { voice.dump(output, pad + 4, "Voice"); features.dump(output, pad + 4, "Features"); } relations.dump(output, pad + 4, "Relations"); output.flush(); }
/** * Determines if the given feature is present. If the feature is not present in the utterance, the * feature set of the voice is checked. * * @param name the name of the feature of interest * @return true if the named feature is present */ public boolean isPresent(String name) { if (!features.isPresent(name)) { return getVoice().getFeatures().isPresent(name); } else { return true; } }
/** * Retrieves a relation from this utterance. * * @param name the name of the Relation * @return the relation or null if the relation is not found */ public Relation getRelation(String name) { return (Relation) relations.getObject(name); }
/** * Creates a new relation with the given name and adds it to this utterance. * * @param name the name of the new relation * @return the newly created relation */ public Relation createRelation(String name) { Relation relation = new Relation(name, this); relations.setObject(name, relation); return relation; }
/** * Sets the named feature. * * @param name the name of the feature * @param value the value of the feature */ public void setObject(String name, Object value) { features.setObject(name, value); }
/** * Convenience method that sets the named feature as a String. * * @param name the name of the feature * @param value the value of the feature */ public void setString(String name, String value) { features.setString(name, value); }
/** * Convenience method that sets the named feature as a float. * * @param name the name of the feature * @param value the value of the feature */ public void setFloat(String name, float value) { features.setFloat(name, value); }
/** * Convenience method that sets the named feature as an int. * * @param name the name of the feature * @param value the value of the feature */ public void setInt(String name, int value) { features.setInt(name, value); }
/** * Removes the named feature from this set of features. * * @param name the name of the feature of interest */ public void remove(String name) { features.remove(name); }
/** * Determines if this utterance contains a relation with the given name. * * @param name the name of the relation of interest. */ public boolean hasRelation(String name) { return relations.isPresent(name); }