001/** 002 * Portions Copyright 2001 Sun Microsystems, Inc. 003 * Portions Copyright 1999-2001 Language Technologies Institute, 004 * Carnegie Mellon University. 005 * All Rights Reserved. Use is subject to license terms. 006 * 007 * See the file "license.terms" for information on usage and 008 * redistribution of this file, and for a DISCLAIMER OF ALL 009 * WARRANTIES. 010 */ 011package com.sun.speech.freetts; 012 013import java.io.PrintWriter; 014 015/** 016 * Represents the abstract interface to an entity that has 017 * a set of features. Provides interfaces to set and get the name/value 018 * pairs as well as providing a set of convenience methods for 019 * setting and retrieving values of a particular type. 020 */ 021 022public interface FeatureSet extends Dumpable { 023 024 025 /** 026 * Determines if the given feature is present. 027 * 028 * @param name the name of the feature of interest 029 * 030 * @return true if the named feature is present 031 */ 032 boolean isPresent(String name); 033 034 035 /** 036 * Removes the named feature from this set of features. 037 * 038 * @param name the name of the feature of interest 039 */ 040 void remove(String name); 041 042 /** 043 * Convenience method that returns the named feature as a string. 044 * 045 * @param name the name of the feature 046 * 047 * @return the value associated with the name or null if the value 048 * is not found 049 * 050 * @throws ClassCastException if the associated value is not a 051 * String 052 */ 053 String getString(String name); 054 055 /** 056 * Convenience method that returns the named feature as an int. 057 * 058 * @param name the name of the feature 059 * 060 * @return the value associated with the name or null if the value 061 * is not found 062 * 063 * @throws ClassCastException if the associated value is not an 064 * int 065 */ 066 int getInt(String name); 067 068 /** 069 * Convenience method that returns the named feature as a float. 070 * 071 * @param name the name of the feature 072 * 073 * @return the value associated with the name or null if the value 074 * is not found 075 * 076 * @throws ClassCastException if the associated value is not a 077 * float. 078 */ 079 float getFloat(String name); 080 081 /** 082 * Returns the named feature as an object. 083 * 084 * @param name the name of the feature 085 * 086 * @return the value associated with the name or null if the value 087 * is not found 088 */ 089 Object getObject(String name); 090 091 /** 092 * Convenience method that sets the named feature as an int. 093 * 094 * @param name the name of the feature 095 * @param value the value of the feature 096 */ 097 void setInt(String name, int value); 098 099 /** 100 * Convenience method that sets the named feature as a float 101 * 102 * @param name the name of the feature 103 * @param value the value of the feature 104 */ 105 void setFloat(String name, float value); 106 107 /** 108 * Convenience method that sets the named feature as a String. 109 * 110 * @param name the name of the feature 111 * @param value the value of the feature 112 */ 113 void setString(String name, String value); 114 115 /** 116 * Sets the named feature . 117 * 118 * @param name the name of the feature 119 * @param value the value of the feature 120 */ 121 void setObject(String name, Object value); 122 123 /** 124 * Dumps the FeatureSet in textual form. 125 * 126 * @param output where to send the formatted output 127 * @param pad the padding 128 * @param title the title 129 */ 130 void dump(PrintWriter output, int pad, String title); 131}