net.sf.molae.pipe.cube
Class ProjectionTransformer<E>

java.lang.Object
  extended by net.sf.molae.pipe.cube.ProjectionTransformer<E>
All Implemented Interfaces:
TwoWayTransformer<Collection<E>,Collection<E>>

public class ProjectionTransformer<E>
extends Object
implements TwoWayTransformer<Collection<E>,Collection<E>>

Removes the object at a given index.

Since:
1.1

Constructor Summary
ProjectionTransformer(int index, E pivot)
          Constructs a new ProjectionTransformer.
 
Method Summary
 boolean isRetrievable(Collection<E> input)
          Indicates if the origin of the specified object can be calculated.
 Collection<E> retransform(Collection<E> input)
          Adds the given object at the given index to the input collection.
 Collection<E> transform(Collection<E> input)
          Removes the object at the given index from the input collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProjectionTransformer

public ProjectionTransformer(int index,
                             E pivot)
Constructs a new ProjectionTransformer.

Parameters:
index - index to evaluate
pivot - fixed value at index for retransformation
Method Detail

transform

public Collection<E> transform(Collection<E> input)
Removes the object at the given index from the input collection.

Specified by:
transform in interface TwoWayTransformer<Collection<E>,Collection<E>>
Parameters:
input - a list
Returns:
the modified clone of the input list
Throws:
ClassCastException - if the input is not a Collection
IndexOutOfBoundsException - if the size of the input collection is less or equal to the given index

retransform

public Collection<E> retransform(Collection<E> input)
Adds the given object at the given index to the input collection.

Specified by:
retransform in interface TwoWayTransformer<Collection<E>,Collection<E>>
Parameters:
input - a list
Returns:
the modified clone of the input list
Throws:
ClassCastException - if the input is not a Collection
IndexOutOfBoundsException - if the size of the input collection is less than the given index

isRetrievable

public boolean isRetrievable(Collection<E> input)
Description copied from interface: TwoWayTransformer
Indicates if the origin of the specified object can be calculated. This requires that:
  1. retransform is implemented for this object and does not throw an exception.
  2. The object x returned by retransform is unique, or more formally: transform(o1).equals(transform(o2)) &rArr o1.equals(o2)
This implies that
 retransform(transform(input)).equals(input)
 
for all objects where the retransformation is defined.

Specified by:
isRetrievable in interface TwoWayTransformer<Collection<E>,Collection<E>>
Parameters:
input - the object for which the transformation origin is searched.
Returns:
true if the origin of the specified object can be calculated.