jfun.yan
Class StoreBinder<T,L>

java.lang.Object
  extended by jfun.yan.StoreBinder<T,L>
All Implemented Interfaces:
java.io.Serializable, Binder<L,L>, ComponentBinder<L,L>, ElementChecker

public abstract class StoreBinder<T,L>
extends java.lang.Object
implements ComponentBinder<L,L>, ElementChecker

This implementation executes an array of components sequentially and collect the results into an ElementStore object created by the toStore(Object) method.

Author:
Ben Yu Nov 12, 2005 2:13:47 PM
See Also:
Serialized Form

Constructor Summary
StoreBinder(Creator<T>[] steps)
          Create a StoreBinder object.
 
Method Summary
 Creator<L> bind(L v)
          Creates a Creator object according to a value.
 java.lang.Class bindType(java.lang.Class type)
          Get the type of the component being bound.
 void checkElement(int i, java.lang.Class type)
          Subclasses may choose to override this method to provide additional checking for the element types and indexes.
 boolean equals(java.lang.Object obj)
           
 Creator<T>[] getProducers()
           
 int hashCode()
           
abstract  ElementStore<T> toStore(L v)
          Subclasses need to override this method to create the ElementStore object needed to collect the component instances.
 java.lang.String toString()
           
 Verifiable verify(java.lang.Class type)
          Get a Verifiable object that's responsible for verifying the component being bound.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StoreBinder

public StoreBinder(Creator<T>[] steps)
Create a StoreBinder object.

Parameters:
steps - the components to be executed sequentially.
Method Detail

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

verify

public Verifiable verify(java.lang.Class type)
Description copied from interface: ComponentBinder
Get a Verifiable object that's responsible for verifying the component being bound.

Specified by:
verify in interface ComponentBinder<L,L>
Parameters:
type - the type of the previous component. It cannot be null.
Returns:
the Verifiable object.

bindType

public java.lang.Class bindType(java.lang.Class type)
Description copied from interface: ComponentBinder
Get the type of the component being bound.

Specified by:
bindType in interface ComponentBinder<L,L>
Parameters:
type - the type of the previous component, it can be null.
Returns:
the type.

bind

public Creator<L> bind(L v)
                throws java.lang.Throwable
Description copied from interface: Binder
Creates a Creator object according to a value. This value is typically a component instance created from another Component object.

Specified by:
bind in interface Binder<L,L>
Parameters:
v - the value.
Returns:
the Creator object.
Throws:
java.lang.Throwable - if any error happens in the bind.

toStore

public abstract ElementStore<T> toStore(L v)
Subclasses need to override this method to create the ElementStore object needed to collect the component instances.

Parameters:
v - this is the same value received from the bind(Object) method. It is normally a collection object. Based on its type, a proper ElementStore object can be created to populate the instances into it.
Returns:
the ElementStore object.

checkElement

public void checkElement(int i,
                         java.lang.Class type)
Subclasses may choose to override this method to provide additional checking for the element types and indexes.

Specified by:
checkElement in interface ElementChecker
Parameters:
i - the index of the element.
type - the element type.

getProducers

public Creator<T>[] getProducers()