Humboldt Alignment Editor 2.5.0

eu.esdihumboldt.util
Class IdentifiersBase<T>

java.lang.Object
  extended by eu.esdihumboldt.util.IdentifiersBase<T>
Type Parameters:
T - the type of objects that shall be identified
Direct Known Subclasses:
Identifiers

public abstract class IdentifiersBase<T>
extends Object

A base class for identifier handling

Author:
Simon Thum

Field Summary
protected  Map<T,String> ids
          maps objects to identifiers
protected  Map<String,T> objects
          maps identifiers to objects
 
Constructor Summary
protected IdentifiersBase(boolean useEquals)
           
 
Method Summary
 String fetchId(T object)
          Get the id of the given object if it has an Id.
 String getId(T object)
          Get the id of the given object.
 Set<String> getIds()
          Get the ids of all objects
 T getObject(String id)
          Get the object with the given id
 Set<T> getObjects()
          Get the set of objects
protected  void putObjectIdentifier(T object, String id)
          puts a object-identifier pair into the maps, no checks or what.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

objects

protected final Map<String,T> objects
maps identifiers to objects


ids

protected final Map<T,String> ids
maps objects to identifiers

Constructor Detail

IdentifiersBase

protected IdentifiersBase(boolean useEquals)
Parameters:
useEquals - whether to use equality or object identity as identifier scope
Method Detail

putObjectIdentifier

protected void putObjectIdentifier(T object,
                                   String id)
puts a object-identifier pair into the maps, no checks or what.

Parameters:
object - the object
id - the identifier

getId

public String getId(T object)
Get the id of the given object. May generate an Id.

Parameters:
object - the object
Returns:
the id of the object

fetchId

public String fetchId(T object)
Get the id of the given object if it has an Id.

Parameters:
object - the object
Returns:
the id of the object

getObject

public final T getObject(String id)
Get the object with the given id

Parameters:
id - the id
Returns:
the object or null if the id has no associated object

getObjects

public final Set<T> getObjects()
Get the set of objects

Returns:
the set of all objects with an associated identifier

getIds

public final Set<String> getIds()
Get the ids of all objects

Returns:
the set of all ids

Humboldt Alignment Editor 2.5.0

Build 2012-12-03_12-30-59
Revision 9d2dd4b0318cda9f1393b1ddd390f7f792d70a2d