org.garret.perst
Class Projection

java.lang.Object
  extended byorg.garret.perst.Projection

public class Projection
extends java.lang.Object

Class use to project selected objects using relation field. For all selected objects (specified by array or iterator), value of specified field (of IPersistent, array of IPersistent, Link or Relation type) is inspected and all referenced object for projection (duplicate values are eliminated)


Constructor Summary
Projection()
          Default constructor of projection.
Projection(java.lang.Class type, java.lang.String fieldName)
          Constructor of projection specified by class and field name of projected objects
 
Method Summary
 java.util.Iterator iterator()
          Get iterator for result of preceding project and join operations
 void join(Projection prj)
          Join this projection with another projection.
 void project(IPersistent obj)
          Project specified object
 void project(IPersistent[] selection)
          Project specified selection
 void project(java.util.Iterator selection)
          Project specified selection
 void reset()
          Reset projection - clear result of prceding project and join operations
 void setProjectionField(java.lang.Class type, java.lang.String fieldName)
          Specify class of the projected objects and projection field name
 int size()
          Get number of objets in the result
 IPersistent[] toArray()
          Get result of preceding project and join operations
 IPersistent[] toArray(IPersistent[] arr)
          Get result of preceding project and join operations The runtime type of the returned array is that of the specified array.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Projection

public Projection()
Default constructor of projection. This constructor should be used only when you are going to derive your class from Projection and redefine map method in it or sepcify type and fieldName later using setProjectionField method


Projection

public Projection(java.lang.Class type,
                  java.lang.String fieldName)
Constructor of projection specified by class and field name of projected objects

Parameters:
type - base class for selected objects
fieldName - field name used to perform projection
Method Detail

iterator

public java.util.Iterator iterator()
Get iterator for result of preceding project and join operations

Returns:
iterator

join

public void join(Projection prj)
Join this projection with another projection. Result of this join is set of objects present in both projections.


project

public void project(IPersistent obj)
Project specified object

Parameters:
obj - selected object

project

public void project(IPersistent[] selection)
Project specified selection

Parameters:
selection - array with selected object

project

public void project(java.util.Iterator selection)
Project specified selection

Parameters:
selection - iterator specifying seleceted objects

reset

public void reset()
Reset projection - clear result of prceding project and join operations


setProjectionField

public void setProjectionField(java.lang.Class type,
                               java.lang.String fieldName)
Specify class of the projected objects and projection field name

Parameters:
type - base class for selected objects
fieldName - field name used to perform projection

size

public int size()
Get number of objets in the result


toArray

public IPersistent[] toArray()
Get result of preceding project and join operations

Returns:
array of objects

toArray

public IPersistent[] toArray(IPersistent[] arr)
Get result of preceding project and join operations The runtime type of the returned array is that of the specified array. If the index fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this index.

If this index fits in the specified array with room to spare (i.e., the array has more elements than this index), the element in the array immediately following the end of the index is set to null. This is useful in determining the length of this index only if the caller knows that this index does not contain any null elements.)

Parameters:
arr - destination array
Returns:
array of objects