Humboldt Alignment Editor 2.5.0

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

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

public class FilteredInstanceCollection
extends Object
implements InstanceCollection

Instance collection that wraps an instance collection and represents a selection that contains the instances matching a given Filter.

Author:
Simon Templer

Nested Class Summary
 class FilteredInstanceCollection.FilteredIterator
          Filtered resource iterator.
 
Field Summary
 
Fields inherited from interface eu.esdihumboldt.hale.common.instance.model.InstanceCollection
UNKNOWN_SIZE
 
Constructor Summary
FilteredInstanceCollection(InstanceCollection decoratee, Filter filter)
          Create a filtered instance collection.
 
Method Summary
 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

FilteredInstanceCollection

public FilteredInstanceCollection(InstanceCollection decoratee,
                                  Filter filter)
Create a filtered instance collection.

Parameters:
decoratee - the instance collection to perform the selection on
filter - the filter representing the selection
Method Detail

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

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

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.hasSize()

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

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

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

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

Humboldt Alignment Editor 2.5.0

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