public class DefaultSemanticIdentifierMap extends AbstractCloneableSerializable implements SemanticIdentifierMap
| Constructor and Description |
|---|
DefaultSemanticIdentifierMap()
Creates a new instance of DefaultSemanticIdentifierMap.
|
| Modifier and Type | Method and Description |
|---|---|
SemanticIdentifier |
addLabel(SemanticLabel label)
Adds a SemanticLabel to the map, or returns an existing
SemanticIdentifier if already in the map
|
java.util.ArrayList<SemanticIdentifier> |
addLabels(java.util.Collection<SemanticLabel> labels)
Adds a list of SemanticLabels to the map, returning the list of
the corresponding SemanticIdentifiers for the given SemanticLabels.
|
void |
addSemanticIdentifierMapListener(SemanticIdentifierMapListener listener)
Adds a listener to this semantic identifier map.
|
DefaultSemanticIdentifierMap |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
SemanticIdentifier |
findIdentifier(SemanticLabel label)
Queries into the map to find a SemanticLabel
|
protected void |
fireSemanticIdentifierAddedEvent(SemanticIdentifier identifier)
Fires off a SemanticIdentifierMapEvent of type SemanticIdentifierAdded
for the given identifier.
|
protected int |
getIdentifierCounter()
Getter for identifierCounter.
|
java.util.Collection<SemanticIdentifier> |
getIdentifiers()
Gets all the SemanticIdentifiers in the map.
|
protected java.util.LinkedList<SemanticIdentifierMapListener> |
getListeners()
Getter for listeners.
|
protected java.util.LinkedHashMap<SemanticLabel,SemanticIdentifier> |
getMapping()
Getter for mapping.
|
protected int |
getNewIdentifier()
Gets a new identifier for a new label.
|
void |
removeSemanticIdentifierMapListener(SemanticIdentifierMapListener listener)
Removes a listener from this semantic identifier map.
|
protected void |
setIdentifierCounter(int identifierCounter)
Setter for identifier Counter.
|
protected void |
setMapping(java.util.LinkedHashMap<SemanticLabel,SemanticIdentifier> mapping)
Sets the mapping used by the object.
|
public DefaultSemanticIdentifierMap()
public DefaultSemanticIdentifierMap clone()
AbstractCloneableSerializableObject class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone() to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone() as the basis for your implementation.clone in interface CloneableSerializableclone in class AbstractCloneableSerializablepublic SemanticIdentifier findIdentifier(SemanticLabel label)
findIdentifier in interface SemanticIdentifierMaplabel - SemanticLabel to query into the map.public SemanticIdentifier addLabel(SemanticLabel label)
addLabel in interface SemanticIdentifierMaplabel - SemanticLabel to add to or retrieve from the map.java.lang.IllegalArgumentException - if label is null.public java.util.ArrayList<SemanticIdentifier> addLabels(java.util.Collection<SemanticLabel> labels)
addLabels in interface SemanticIdentifierMaplabels - The SemanticLabels to add.java.lang.IllegalArgumentException - If one of the labels is null.public java.util.Collection<SemanticIdentifier> getIdentifiers()
getIdentifiers in interface SemanticIdentifierMapprotected int getNewIdentifier()
public void addSemanticIdentifierMapListener(SemanticIdentifierMapListener listener)
addSemanticIdentifierMapListener in interface SemanticIdentifierMaplistener - The listener to add.public void removeSemanticIdentifierMapListener(SemanticIdentifierMapListener listener)
removeSemanticIdentifierMapListener in interface SemanticIdentifierMaplistener - The listener to remove.protected void fireSemanticIdentifierAddedEvent(SemanticIdentifier identifier)
identifier - The identifier that was added.protected void setMapping(java.util.LinkedHashMap<SemanticLabel,SemanticIdentifier> mapping)
mapping - The new mapping.protected int getIdentifierCounter()
protected void setIdentifierCounter(int identifierCounter)
identifierCounter - The counter of identifiers, which ensures that each one is unique.protected java.util.LinkedHashMap<SemanticLabel,SemanticIdentifier> getMapping()
protected java.util.LinkedList<SemanticIdentifierMapListener> getListeners()