*/
package jalview.datamodel;
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Vector;
/**
public String description;
- public Hashtable otherDetails;
+ public Map<String, Object> otherDetails;
public Vector<String> links;
}
/**
- * Constructs a duplicate feature. Note: Uses clone on the otherDetails so
- * only shallow copies are made of additional properties and method will
- * silently fail if unclonable objects are found in the hash.
+ * Constructs a duplicate feature. Note: Uses makes a shallow copy of the
+ * otherDetails map, so the new and original SequenceFeature may reference the
+ * same objects in the map.
*
* @param cpy
*/
{
try
{
- otherDetails = (Hashtable) cpy.otherDetails.clone();
+ otherDetails = (Map<String, Object>) ((HashMap<String, Object>) cpy.otherDetails)
+ .clone();
} catch (Exception e)
{
- // Uncloneable objects in the otherDetails - don't complain
+ // ignore
}
}
if (cpy.links != null && cpy.links.size() > 0)
}
/**
+ * Returns a property value for the given key if known, else the specified
+ * default value
+ *
+ * @param key
+ * @param defaultValue
+ * @return
+ */
+ public Object getValue(String key, Object defaultValue)
+ {
+ Object value = getValue(key);
+ return value == null ? defaultValue : value;
+ }
+
+ /**
* Used for setting values which are not in the basic set. eg STRAND, FRAME
* for GFF file
*
{
if (otherDetails == null)
{
- otherDetails = new Hashtable();
+ otherDetails = new HashMap<String, Object>();
}
otherDetails.put(key, value);