[all packages] [package BR.unicamp.Guarana.SequentialComposerAlgorithms] [class hierarchy] [index]

public abstract class BR.unicamp.Guarana.SequentialComposerAlgorithms.WithArrayAndRange

(source file: /home/lsd/oliva/src/java/guarana/kaffe/libraries/extensions/guarana/javalib/BR/unicamp/Guarana/SequentialComposerAlgorithms/WithArrayAndRange.java)
java.lang.Object
   |
   +----BR.unicamp.Guarana.MetaObject
           |
           +----BR.unicamp.Guarana.Composer
                   |
                   +----BR.unicamp.Guarana.SequentialComposerAlgorithms.WithArrayAndRange

The pure class interface.
public abstract class WithArrayAndRange
  extends Composer
Implements algorithms for Composers like SequentialComposer, that sequentially request a fixed set of MetaObjects to handle Operations, Results and Messages, as well as reconfiguration, configuration, initialize and release requests. It assumes the array of metaObjects given to each of its Operations is constant.

For each method of MetaObject, this class implements a method that takes the additional arguments metaObjects, begin, increment and end. The first is the array of MetaObjects to which it should delegate the requests. The first MetaObject that gets the Operation is the one whose index is begin. Then, increment is added to begin to compute the index of the next element of the array, and so on, until the computed index is exactly equal to end. The element whose index is end is not processed, but the one whose index is begin is, unless it is equal to end, in which case no element is processed.

All algorithms are final, to avoid exposing the metaObjects array of its main subclass, SequentialComposer. This could have been avoided differently (with final implementations of these methods in class SequentialComposer itself), but it probably wasn't worth the trouble, since there's little point in specializing these methods. They used to be static within SequentialComposer, after all.

See also:
SequentialComposer.

Constuctor Index

O WithArrayAndRange()

Methods

O configureArray(Object, Object, MetaObject[], int, int, int)
Asks each MetaObject to provide a MetaObject to occupy its place in a new Object's
O getMetaObjects(MetaObject[], int, int, int)
Creates an Enumeration that iterates on the selected MetaObjects of the given array.
O handleMessage(Message, Object, MetaObject[], int, int, int)
Delegates the Message to the selected metaObjects of the array. The first MetaObject
O handleOperation(Operation, Object, MetaObject[], int, int, int)
Asks MetaObjects in the given array to handle the Operation
O handleResult(Result, Object, MetaObject[], int, int, int)
Asks MetaObject in the given array to handle the Result
O initialize(OperationFactory, Object, MetaObject[], int, int, int)
Delegates the initialization to all metaObjects.
O reconfigureArray(Object, MetaObject, MetaObject, MetaObject[], int, int, int)
Delegates reconfiguration requests to all metaObjects
O release(Object, MetaObject[], int, int, int)
Delegates the release information to all metaObjects.

Constructors

O WithArrayAndRange
public WithArrayAndRange();

Methods

O getMetaObjects
protected final Enumeration getMetaObjects(MetaObject[] metaObjects,
                                           int begin,
                                           int increment,
                                           int end);
Creates an Enumeration that iterates on the selected MetaObjects of the given array.

Parameters:
metaObjects - an array of MetaObjects.
begin - the index of the first element of the array to be processed. This is usually 0.
increment - the value added to an index to compute the index of the next element to be processed. This is usually 1.
end - the index of the first element of the array that should not be processed. This is usually metaObjects.length.
Returns:
the Enumeration.

O handleOperation

protected final Result handleOperation(Operation operation,
                                       Object object,
                                       MetaObject[] metaObjects,
                                       int begin,
                                       int increment,
                                       int end);
Asks MetaObjects in the given array to handle the Operation. If a MetaObject provides a Result for the Operation (as opposed to a request to be presented a Result or null), the previous MetaObjects are asked to handle the Result, through the invocation of the method to handle results (so even the ones that asked for no further notice will get the Result). The last produced Result is returned.

Parameters:
operation - the Operation to be delegated to MetaObjects.
object - the target Object of the Operation.
metaObjects - an array of MetaObjects.
begin - the index of the first element of the array to be processed. This is usually 0.
increment - the value added to an index to compute the index of the next element to be processed. This is usually 1.
end - the index of the first element of the array that should not be processed. This is usually metaObjects.length.
Returns:
a Result for the Operation, if one was produced by any MetaObject, or a replacement Operation, if one was produced by any MetaObject, or a Result request, if any MetaObject asked to read or modify the Result. If both read and modify requests were made, a modify request is returned.
See also:
handleResult

O handleResult

protected final Result handleResult(Result res,
                                    Object object,
                                    MetaObject[] metaObjects,
                                    int begin,
                                    int increment,
                                    int end);
Asks MetaObject in the given array to handle the Result. If any of the MetaObjects returns a valid non-null Result, the returned Result replaces the one provided, even if the MetaObject had not requested to modify it.

Parameters:
res - the Result to be presented to the MetaObjects.
object - the target Object of the Operation the Result refers to.
metaObjects - an array of MetaObjects.
begin - the index of the first element of the array to be processed. This is usually metaObjects.length-1.
increment - the value added to an index to compute the index of the next element to be processed. This is usually -1.
end - the index of the first element of the array that should not be processed. This is usually -1.
Returns:
the last Result returned by a MetaObject, or the original Result, if every MetaObject returned null.

O handleMessage

protected final void handleMessage(Message message,
                                   Object object,
                                   MetaObject[] metaObjects,
                                   int begin,
                                   int increment,
                                   int end);
Delegates the Message to the selected metaObjects of the array. The first MetaObject that gets the Operation is the one whose index is begin. Then, increment is added to begin to compute the index of the next element of the array, and so on, until the computed index is exactly equal to end.

Parameters:
message - the Message to be broadcasted.
object - the Object the Message refers to.
metaObjects - an array of MetaObjects.
begin - the index of the first element of the array to be processed. This is usually 0.
increment - the value added to an index to compute the index of the next element to be processed. This is usually 1.
end - the index of the first element of the array that should not be processed. This is usually metaObjects.length.

O configureArray

protected final MetaObject[] configureArray(Object newObject,
                                            Object object,
                                            MetaObject[] metaObjects,
                                            int begin,
                                            int increment,
                                            int end);
Asks each MetaObject to provide a MetaObject to occupy its place in a new Object's meta-configuration. If all of them return themselves, the metaObjects argument is returned. If all of them return null, return null too. In any other case, a new, packed array is created, containing the non-null MetaObjects returned by the elements of the metaObjects array, and this new array is returned.

Parameters:
newObject - the Object MetaObjects should be created for.
object - the Object whose meta-configuration is being asked to create the newObject's configuration.
metaObjects - an array of MetaObjects.
begin - the index of the first element of the array to be processed. This is usually 0.
increment - the value added to an index to compute the index of the next element to be processed. This is usually 1.
end - the index of the first element of the array that should not be processed. This is usually metaObjects.length.
Returns:
a packed array of MetaObjects with the MetaObjects returned by the ones in the metaObjects array, or null, if all of them returned null.

O reconfigureArray

protected final MetaObject[] reconfigureArray(Object object,
                                              MetaObject oldMetaObject,
                                              MetaObject newMetaObject,
                                              MetaObject[] metaObjects,
                                              int begin,
                                              int increment,
                                              int end);
Delegates reconfiguration requests to all metaObjects. If all of them return themselves, the metaObjects argument is returned. If all of them return null, return null too. In any other case, a new, packed array is created, containing the non-null MetaObjects returned by the elements of the metaObjects array, and this new array is returned.

Parameters:
object - the Object whose meta-configuration should be affected.
oldMetaObject - that MetaObject that may be replaced.
newMetaObject - the candidate MetaObject to replace it.
metaObjects - an array of MetaObjects.
begin - the index of the first element of the array to be processed. This is usually 0.
increment - the value added to an index to compute the index of the next element to be processed. This is usually 1.
end - the index of the first element of the array that should not be processed. This is usually metaObjects.length.
Returns:
the given array of metaObjects, if no changes were performed, or a new, packed array, if reconfiguration is to take place.

O initialize

protected final void initialize(OperationFactory factory,
                                Object object,
                                MetaObject[] metaObjects,
                                int begin,
                                int increment,
                                int end);
Delegates the initialization to all metaObjects.

Parameters:
factory - the Operation Factory to be used to create Operations for that Object.
object - the Object MetaObjects should become able to handle.
metaObjects - an array of MetaObjects.
begin - the index of the first element of the array to be processed. This is usually 0.
increment - the value added to an index to compute the index of the next element to be processed. This is usually 1.
end - the index of the first element of the array that should not be processed. This is usually metaObjects.length.

O release

protected final void release(Object object,
                             MetaObject[] metaObjects,
                             int begin,
                             int increment,
                             int end);
Delegates the release information to all metaObjects.

Parameters:
object - the Object that should no longer be handled.
metaObjects - an array of MetaObjects.
begin - the index of the first element of the array to be processed. This is usually metaObjects.length-1.
increment - the value added to an index to compute the index of the next element to be processed. This is usually -1.
end - the index of the first element of the array that should not be processed. This is usually -1.


[all packages] [package BR.unicamp.Guarana.SequentialComposerAlgorithms] [class hierarchy] [index]
BR.unicamp.Guarana.SequentialComposerAlgorithms.WithArrayAndRange.html