Humboldt Alignment Editor 2.5.0

eu.esdihumboldt.hale.common.instance.model.impl
Class DefaultInstanceCollection

java.lang.Object
  extended by eu.esdihumboldt.hale.common.instance.model.impl.DefaultInstanceCollection
All Implemented Interfaces:
InstanceCollection, InstanceResolver

public class DefaultInstanceCollection
extends Object
implements InstanceCollection

Default instance collection implementation backed by a collection.

Author:
Simon Templer

Field Summary
 
Fields inherited from interface eu.esdihumboldt.hale.common.instance.model.InstanceCollection
UNKNOWN_SIZE
 
Constructor Summary
DefaultInstanceCollection(Collection<? extends Instance> collection)
          Create an instance collection backed
 
Method Summary
 void add(Instance instance)
          Adds an instance to the collection
 Instance getInstance(InstanceReference reference)
          Get the instance referenced by the given reference.
 InstanceReference getReference(Instance instance)
          Get a reference to an instance that can be used to retrieve the given instance using InstanceResolver.getInstance(InstanceReference).
 boolean hasSize()
          States if the collection has a known size.
 boolean isEmpty()
          States if the collection has no instances.
 ResourceIterator<Instance> iterator()
          Get an iterator over all instances contained in the collection.
 InstanceCollection select(Filter filter)
          Select the instances in the collection, matching the given filter.
 int size()
          Get the collection size if known.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultInstanceCollection

public DefaultInstanceCollection(Collection<? extends Instance> collection)
Create an instance collection backed

Parameters:
collection - the instance collection
Method Detail

add

public void add(Instance instance)
Adds an instance to the collection

Parameters:
instance - the instance to add

iterator

public ResourceIterator<Instance> iterator()
Description copied from interface: InstanceCollection
Get an iterator over all instances contained in the collection. The iterator must be disposed after use (using ResourceIterator.close()).

Specified by:
iterator in interface InstanceCollection
Returns:
an iterator over the instances
See Also:
InstanceCollection.iterator()

hasSize

public boolean hasSize()
Description copied from interface: InstanceCollection
States if the collection has a known size.

Specified by:
hasSize in interface InstanceCollection
Returns:
if the collection size is known
See Also:
InstanceCollection.hasSize()

size

public int size()
Description copied from interface: InstanceCollection
Get the collection size if known.

Specified by:
size in interface InstanceCollection
Returns:
the collection size or InstanceCollection.UNKNOWN_SIZE
See Also:
InstanceCollection.size()

isEmpty

public boolean isEmpty()
Description copied from interface: InstanceCollection
States if the collection has no instances. This must return a valid value even if InstanceCollection.hasSize() returns false.

Specified by:
isEmpty in interface InstanceCollection
Returns:
if the collection is empty
See Also:
InstanceCollection.isEmpty()

select

public InstanceCollection select(Filter filter)
Description copied from interface: InstanceCollection
Select the instances in the collection, matching the given filter.

Specified by:
select in interface InstanceCollection
Parameters:
filter - the instance filter
Returns:
the instance collection representing the selection
See Also:
InstanceCollection.select(Filter)

getReference

public InstanceReference getReference(Instance instance)
Description copied from interface: InstanceResolver
Get a reference to an instance that can be used to retrieve the given instance using InstanceResolver.getInstance(InstanceReference).

Specified by:
getReference in interface InstanceResolver
Parameters:
instance - the instance, must have originated from this resolver
Returns:
the reference
See Also:
InstanceResolver.getReference(Instance)

getInstance

public Instance getInstance(InstanceReference reference)
Description copied from interface: InstanceResolver
Get the instance referenced by the given reference.

Specified by:
getInstance in interface InstanceResolver
Parameters:
reference - the instance reference
Returns:
the referenced instance or null if it does not exist or the reference is invalid
See Also:
InstanceResolver.getInstance(InstanceReference)

Humboldt Alignment Editor 2.5.0

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