next up previous contents
Next: Use Consistant Value Types Up: Possible Pitfalls and Safety Previous: Possible Pitfalls and Safety

Use only String objects as keys.

Since you can use the Hashtable method put to load data into a Metadata object, it is possible to save a value using a key that is not of type String. If you did so, it would not be accessible via the getMetadatum method since this takes only a String as an argument. Of course, there is nothing stopping you from using the Hashtable method get to extract the data, regardless of the key type. Nevertheless, using non-String keys is not recommended as it is not in keeping with the conceptual design of the Metadata object; use a Hashtable instead. Objects that use Metadata objects will expect them to only contain data accessible via String keys; data saved with non-String keys will probably never get used and could lead to ClassCastExceptions.



Ray Plante
Mon Aug 25 15:16:12 CDT 1997