gate.util
Class SimpleFeatureMapImpl

java.lang.Object
  extended by gate.util.SimpleFeatureMapImpl
All Implemented Interfaces:
ANNIEConstants, FeatureMap, SimpleFeatureMap, Serializable, Cloneable, Map<Object,Object>

public class SimpleFeatureMapImpl
extends Object
implements FeatureMap, Serializable, Cloneable, ANNIEConstants

Simple case of features.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
static ConcurrentHashMap theKeysHere
          the static 'all keys' collection
 
Fields inherited from interface gate.creole.ANNIEConstants
ANNOTATION_COREF_FEATURE_NAME, DATE_ANNOTATION_TYPE, DATE_POSTED_ANNOTATION_TYPE, DEFAULT_FILE, DOCUMENT_COREF_FEATURE_NAME, JOB_ID_ANNOTATION_TYPE, LOCATION_ANNOTATION_TYPE, LOOKUP_ANNOTATION_TYPE, LOOKUP_CLASS_FEATURE_NAME, LOOKUP_INSTANCE_FEATURE_NAME, LOOKUP_LANGUAGE_FEATURE_NAME, LOOKUP_MAJOR_TYPE_FEATURE_NAME, LOOKUP_MINOR_TYPE_FEATURE_NAME, LOOKUP_ONTOLOGY_FEATURE_NAME, MONEY_ANNOTATION_TYPE, ORGANIZATION_ANNOTATION_TYPE, PERSON_ANNOTATION_TYPE, PERSON_GENDER_FEATURE_NAME, PLUGIN_DIR, PR_NAMES, SENTENCE_ANNOTATION_TYPE, SPACE_TOKEN_ANNOTATION_TYPE, TOKEN_ANNOTATION_TYPE, TOKEN_CATEGORY_FEATURE_NAME, TOKEN_KIND_FEATURE_NAME, TOKEN_LENGTH_FEATURE_NAME, TOKEN_ORTH_FEATURE_NAME, TOKEN_STRING_FEATURE_NAME
 
Constructor Summary
SimpleFeatureMapImpl()
           
 
Method Summary
 void addFeatureMapListener(FeatureMapListener l)
          Adds a gate listener
 void clear()
          clear the map
 Object clone()
          Create a copy of the map including the data.
 boolean containsKey(Object key)
          return true if the key is in the map
 boolean containsValue(Object value)
          return true if the map contains that value
 Set entrySet()
           
 boolean equals(Object o)
           
protected  void fireMapUpdatedEvent()
           
 Object get(Object key)
          return the value associated with the key.
protected  OClass getClassForURIOrName(Ontology ontologyLR, String name)
          Look up the given name in the given ontology.
protected  int getSubsumeKey(Object key)
          return the index of the key in the map comparing them by reference only.
 int hashCode()
          return the hashCode for the map
 boolean isEmpty()
          return true if there are no elements in the map
 Set keySet()
          return the set of the keys in the map.
 Object put(Object key, Object value)
          Overriden to fire events, so that the persistent objects can keep track of what's updated
 void putAll(Map t)
          put all the elements from a map
 Object remove(Object key)
          Overriden to fire events, so that the persistent objects can keep track of what's updated
 void removeFeatureMapListener(FeatureMapListener l)
          Removes a gate listener
 int size()
          return the number of elements in the map
 boolean subsumes(FeatureMap aFeatureMap)
          Test if this featureMap includes all features from aFeatureMap However, if aFeatureMap contains a feature whose value is equal to gate.creole.ANNIEConstants.LOOKUP_CLASS_FEATURE_NAME (which is normally "class"), then GATE will attempt to match that feature using an ontology which it will try to retreive from a feature in both the feature map through which this method is called and in aFeatureMap.
 boolean subsumes(FeatureMap aFeatureMap, Set aFeatureNamesSet)
          Tests if this featureMap object includes aFeatureMap but only for the those features present in the aFeatureNamesSet.
 boolean subsumes(Ontology ontologyLR, FeatureMap aFeatureMap)
          Tests if this featureMap object includes aFeatureMap features.
 String toString()
           
 Collection values()
          Not supported.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
containsKey, containsValue, entrySet, get, hashCode, isEmpty, keySet, putAll, size, values
 

Field Detail

theKeysHere

public static transient ConcurrentHashMap theKeysHere
the static 'all keys' collection

Constructor Detail

SimpleFeatureMapImpl

public SimpleFeatureMapImpl()
Method Detail

subsumes

public boolean subsumes(FeatureMap aFeatureMap)
Test if this featureMap includes all features from aFeatureMap However, if aFeatureMap contains a feature whose value is equal to gate.creole.ANNIEConstants.LOOKUP_CLASS_FEATURE_NAME (which is normally "class"), then GATE will attempt to match that feature using an ontology which it will try to retreive from a feature in both the feature map through which this method is called and in aFeatureMap. If these do not return identical ontologies, or if either feature map does not contain an ontology, then matching will fail, and this method will return false. In summary, this method will not work normally when aFeatureMap contains a feature with the name "class".

Specified by:
subsumes in interface FeatureMap
Parameters:
aFeatureMap - object which will be included or not in this FeatureMap obj.If this param is null then it will return true.
Returns:
true if aFeatureMap is incuded in this obj. and false if not.

subsumes

public boolean subsumes(Ontology ontologyLR,
                        FeatureMap aFeatureMap)
Tests if this featureMap object includes aFeatureMap features.
If the feature map contains class and (optionally) ontology features:
then the ontologyLR is used to provide ontology based subsume with respect to the subClassOf relations.

Specified by:
subsumes in interface FeatureMap
Parameters:
ontologyLR - an ontology to be used for the subsume
aFeatureMap - object which will be included or not in this FeatureMap obj.
Returns:
true if this includes aFeatureMap and false if not.

getClassForURIOrName

protected OClass getClassForURIOrName(Ontology ontologyLR,
                                      String name)
Look up the given name in the given ontology. First we try treating the name as a complete URI and attempt to find the matching OClass. If this fails (either the name is not a URI or there is no class by that URI) then we try again, treating the name as local to the default namespace of the ontology.

Parameters:
ontologyLR - the ontology
name - the URI or local resource name to look up
Returns:
the corresponding OClass, or null if no suitable class could be found.

subsumes

public boolean subsumes(FeatureMap aFeatureMap,
                        Set aFeatureNamesSet)
Tests if this featureMap object includes aFeatureMap but only for the those features present in the aFeatureNamesSet. However, if aFeatureMap contains a feature whose value is equal to gate.creole.ANNIEConstants.LOOKUP_CLASS_FEATURE_NAME (which is normally "class"), then GATE will attempt to match that feature using an ontology which it will try to retreive from a feature in both the feature map through which this method is called and in aFeatureMap. If these do not return identical ontologies, or if either feature map does not contain an ontology, then matching will fail, and this method will return false. In summary, this method will not work normally when aFeatureMap contains a feature with the name "class" if that feature is also in aFeatureNamesSet.

Specified by:
subsumes in interface FeatureMap
Parameters:
aFeatureMap - which will be included or not in this FeatureMap obj.If this param is null then it will return true.
aFeatureNamesSet - is a set of strings representing the names of the features that would be considered for subsumes. If aFeatureNamesSet is null then subsumes(FeatureMap) will be called.
Returns:
true if all features present in the aFeaturesNameSet from aFeatureMap are included in this obj, or false otherwise.

put

public Object put(Object key,
                  Object value)
Overriden to fire events, so that the persistent objects can keep track of what's updated

Specified by:
put in interface Map<Object,Object>

remove

public Object remove(Object key)
Overriden to fire events, so that the persistent objects can keep track of what's updated

Specified by:
remove in interface Map<Object,Object>

clear

public void clear()
clear the map

Specified by:
clear in interface Map<Object,Object>

clone

public Object clone()
Create a copy of the map including the data.


equals

public boolean equals(Object o)
Specified by:
equals in interface Map<Object,Object>

removeFeatureMapListener

public void removeFeatureMapListener(FeatureMapListener l)
Removes a gate listener

Specified by:
removeFeatureMapListener in interface FeatureMap

addFeatureMapListener

public void addFeatureMapListener(FeatureMapListener l)
Adds a gate listener

Specified by:
addFeatureMapListener in interface FeatureMap

fireMapUpdatedEvent

protected void fireMapUpdatedEvent()

size

public int size()
return the number of elements in the map

Specified by:
size in interface Map<Object,Object>

isEmpty

public boolean isEmpty()
return true if there are no elements in the map

Specified by:
isEmpty in interface Map<Object,Object>

values

public Collection values()
Not supported. This method is here only to conform the Map interface

Specified by:
values in interface Map<Object,Object>

keySet

public Set keySet()
return the set of the keys in the map. The changes in the set DO NOT affect the map.

Specified by:
keySet in interface Map<Object,Object>

containsKey

public boolean containsKey(Object key)
return true if the key is in the map

Specified by:
containsKey in interface Map<Object,Object>

containsValue

public boolean containsValue(Object value)
return true if the map contains that value

Specified by:
containsValue in interface Map<Object,Object>

get

public Object get(Object key)
return the value associated with the key. If the key is not in the map returns null.

Specified by:
get in interface Map<Object,Object>

putAll

public void putAll(Map t)
put all the elements from a map

Specified by:
putAll in interface Map<Object,Object>

getSubsumeKey

protected int getSubsumeKey(Object key)
return the index of the key in the map comparing them by reference only. This method is used in subsume check to speed it up.


entrySet

public Set entrySet()
Specified by:
entrySet in interface Map<Object,Object>

hashCode

public int hashCode()
return the hashCode for the map

Specified by:
hashCode in interface Map<Object,Object>
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object