[all packages]
[package BR.unicamp.Guarana]
[class hierarchy]
[index]
public class BR.unicamp.Guarana.SequentialComposer
(source file: /home/phd/oliva/src/guarana/kaffe/libraries/extensions/guarana/javalib/BR/unicamp/Guarana/SequentialComposer.java)
java.lang.Object
|
+----BR.unicamp.Guarana.MetaObject
|
+----BR.unicamp.Guarana.Composer
|
+----BR.unicamp.Guarana.SequentialComposer
public class SequentialComposer
extends Composer
- Implements a Composer that sequentially requests MetaObjects to
handle Operations.

SequentialComposer(MetaObject[])
- Creates a Composer that will sequentially delegate operations
and messages to the

configure(Object, Object, MetaObject[], int, int, int)
- Asks each MetaObject to provide a MetaObject to occupy its place
in a new Object's
configure(Object, Object)
- Provides a MetaObject for newObject, to be used at the point the
current Composer is in
getMetaObjects()
- Obtains the MetaObjects this composer delegates to, ordered as
they receive Operations.
getMetaObjectsArray()
- Obtains a copy of the array of MetaObjects this Composer
delegates to.
getOperationFactoryFor(MetaObject, Object)
- Obtain an OperationFactory to be given to the specified
MetaObject to create Operations
handle(Result, Object, MetaObject[], int, int, int)
- Asks MetaObject in the given array to handle the Result
handle(Message, Object)
- Delegates the Message to all MetaObjects.
handle(Result, Object)
- Asks each MetaObject in the metaObjects array, from last to
first, to handle the Result
handle(Operation, Object, MetaObject[], int, int, int)
- Asks MetaObjects in the given array to handle the Operation.
The first MetaObject that
handle(Operation, Object)
- Asks each MetaObject in the metaObjects array to handle the
Operation
initialize(OperationFactory, Object)
- Delegates the initialization to all MetaObjects obtained with
getMetaObjects().
makeMetaObjectsFor(Object, Object, MetaObject[])
- Deprecated!
reconfigure(Object, MetaObject, MetaObject)
- Delegates reconfiguration requests to component MetaObjects.
This method always returns
release(Object)
- Delegates the release information to all MetaObjects obtained
with getMetaObjects().
setMetaObjectsArray(MetaObject[])
- Establishes a new set of MetaObjects for this Composer to
delegate to.
The caller

SequentialComposer
public SequentialComposer(MetaObject[] metaObjects);
- Creates a Composer that will sequentially delegate operations
and messages to the elements of a clone of metaObjects.
- Parameters:
- metaObjects - the set of MetaObjects the Composer should
delegate to.

getMetaObjects
public Enumeration getMetaObjects();
- Obtains the MetaObjects this composer delegates to, ordered as
they receive Operations.
- Returns:
- an Enumeration whose elements correspond to the elements
of the array of metaObjects.
- Overrides:
- getMetaObjects in class Composer
getMetaObjectsArray
public synchronized MetaObject[] getMetaObjectsArray();
- Obtains a copy of the array of MetaObjects this Composer
delegates to.
- Returns:
- a copy of the array of MetaObjects this Composer
delegates to.
- Overrides:
- getMetaObjectsArray in class Composer
setMetaObjectsArray
public synchronized void setMetaObjectsArray(MetaObject[] metaObjects);
- Establishes a new set of MetaObjects for this Composer to
delegate to.
The caller must Initialize all the elements of the new Array
before invoking this method, and must Release all the elements
of the original array after this method returns.
- Parameters:
- metaObjects - the new array of MetaObjects.
handle
public Result handle(Operation operation,
Object object);
- Asks each MetaObject in the metaObjects array to handle the
Operation. If any MetaObject provides a Result for the
Operation, it is presented to the remaining MetaObjects as
Handle(Result) does. If any replacement Operation is provided,
the last one is returned.
If a MetaObject provides a Result for an Operation, the
previous MetaObjects are asked to handle the Result (even the
ones that asked for no further notice). If any of these
provides another Result, this Result replaces any previously
returned one. The last Result produced is finally returned.
- Parameters:
- operation - the Operation to be delegated to MetaObjects.
- object - the target Object of the Operation.
- 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.
- Overrides:
- handle in class MetaObject
handle
public static Result handle(Operation op,
Object object,
MetaObject[] metaObjects,
int begin,
int increment,
int end);
- Asks MetaObjects in the given array to handle the Operation.
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.
If a MetaObject provides a Result for an Operation, the
previous MetaObjects are asked to handle the Result (even the
ones that asked for no further notice). If any of these
provides another Result, this Result replaces any previously
returned one. The last Result produced is finally 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 that
should be presented the Operation. This is usually 0.
- increment - the value added to an index to compute the
index of the next element that will be presented an Operation.
This is usually 1.
- end - the index of the first element of the array that will
not be presented the Operation. 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.
handle
public Result handle(Result res,
Object object);
- Asks each MetaObject in the metaObjects array, from last to
first, to handle the Result. If any of them returns a 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.
- Returns:
- the last Result returned by a MetaObject, or the original
Result, if every MetaObject returned null.
- Overrides:
- handle in class MetaObject
handle
public static Result handle(Result res,
Object object,
MetaObject[] metaObjects,
int begin,
int increment,
int end);
- Asks MetaObject in the given array to handle the Result. The
first MetaObject that gets the Result 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.
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 that
should be presented the Operation. This is usually
metaObjects.length-1.
- increment - the value added to an index to compute the
index of the next element that will be presented an Operation.
This is usually -1.
- end - the index of the first element of the array that will
not be presented the Operation. This is usually -1.
- Returns:
- the last Result returned by a MetaObject, or the original
Result, if every MetaObject returned null.
handle
public void handle(Message message,
Object object);
- Delegates the Message to all MetaObjects.
- Parameters:
- message - the Message to be broadcasted.
- object - the Object the Message refers to.
- Overrides:
- handle in class MetaObject
configure
public MetaObject configure(Object newObject,
Object object);
- Provides a MetaObject for newObject, to be used at the point the
current Composer is in object's meta-configuration.
Subclasses should specialize this method so that, instead of
creating a new SequentialComposer, a specialized instance is
created too, if this is intended.
- Parameters:
- newObject - the Object a new Composer should be provided
for.
- object - the Object whose meta-configuration is begin
requested to create the newObject's meta-configuration.
- Returns:
- if the static configure returns null, so does this
method. If the returned array has length 1, the only element of
the array is returned. Otherwise, a new SequentialComposer is
created to delegate to the returned array of MetaObjects.
- Overrides:
- configure in class MetaObject
makeMetaObjectsFor
protected MetaObject[] makeMetaObjectsFor(Object newObject,
Object object,
MetaObject[] metaObjects);
- Note: deprecated!
Asks each MetaObject to provide a MetaObject to occupy its place
in a new Object's meta-configuration. By default, it just calls
the static version of method configure.
This method is maintained primarily for backward
compatibility.
-
- 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 - the list of MetaObjects to be requested to
create MetaObjects for the new Object's meta-configuration.
- Returns:
- a packed array of MetaObjects to be associated with the
given Object, or null, if no MetaObjects are needed.
- See also:
- configure
configure
public static MetaObject[] configure(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. The returned array is
ensured not to contain any null element, since it is packed, and
the array length is determined after each MetaObject is
consulted. MetaObjects that return null have their positions
removed. If no MetaObject is created, a null array (not an empty
one) is returned.
This operation is intended to be used by subclasses, so that
they can override Config without having to reimplement the array
construction funcionality.
- 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 - the list of MetaObjects to be requested to
create MetaObjects for the new Object's meta-configuration.
- begin - the index of the first element of the array that
should be asked to configure the new Object. This is usually 0.
- increment - the value added to an index to compute the
index of the next element that will be asked to configure the
new Object. This is usually 1.
- end - the index of the first element of the array that will
not be asked to configure the new Object. This is usually
metaObjects.length.
- Returns:
- a packed array of MetaObjects to be associated with the
given Object, or null, if no MetaObjects are needed.
getOperationFactoryFor
protected OperationFactory getOperationFactoryFor(MetaObject metaObject,
Object object);
- Obtain an OperationFactory to be given to the specified
MetaObject to create Operations for the given Object.
This method just returns the last OperationFactory it was
initialized with. If this Composer is to be associated with
multiple Objects, or more restrictive OperationFactories should
be given to MetaObjects, this method must be overridden.
A subclass might prefer, for security reasons, to check whether
the MetaObject is actually in the MetaObject array, but this
method is usually called to initialize the MetaObject
before it is inserted in the array. In this case, it may
return null or a very restricted OperationFactory. This should
usually work, whenever Guarana.reconfigure is invoked, it will
distribute new OperationFactories. However, if reconfigure is
called internally, instead of from Guarana.reconfigure, or if
some MetaObject above the current Composer in the MetaObject
hierarchy decides not to distribute the new OperationFactory,
the newly associated MetaObject may remain with a restricted
OperationFactory.
- Parameters:
- metaObject - the MetaObject an OperationFactory should be
provided for.
- object - the base-level Object that should be the target of
Operations created by the returned OperationFactory.
- Returns:
- the OperationFactory from the last invocation of
initialize. This must be specialized for multi-object
MetaObjects.
reconfigure
public synchronized MetaObject reconfigure(Object object,
MetaObject oldMetaObject,
MetaObject newMetaObject);
- Delegates reconfiguration requests to component MetaObjects.
This method always returns itself (unless the array becomes
empty or contains a single element), which means it will not
accept to be replaced. Subclasses may change this behavior.
It delegates the reconfigure request to each component
MetaObject. If the oldMetaObject is any of them, replace it
with the value it returns. If the returned value is different
from the MetaObject itself, the returned MetaObject is
initialized before it is stored in the array of MetaObjects, and
the original one is released after that. If the returned
MetaObject was null, the array is shrinked, so that it does not
contain null elements. If the array ever becomes empty, this
method returns null. If the array every contains a single
element, this method returns that element.
If an Operation is being currently handled, this method should
try to avoid modifying the set of MetaObjects the Operation
would be delegated to, but it doesn't; this is left for
subclasses to implement.
- Parameters:
- object - the Object whose meta-configuration should be
affected.
- oldMetaObject - that MetaObject that may be replaced.
- newMetaObject - the candidate MetaObject to replace it.
- Returns:
- this, unless the reconfiguration resulted an empty
array.
- Overrides:
- reconfigure in class MetaObject
initialize
public synchronized void initialize(OperationFactory factory,
Object object);
- Delegates the initialization to all MetaObjects obtained with
getMetaObjects().
- Parameters:
- factory - the Operation Factory to be used to create
Operations for that Object.
- object - the Object MetaObjects should become able to handle.
- Overrides:
- initialize in class MetaObject
release
public synchronized void release(Object object);
- Delegates the release information to all MetaObjects obtained
with getMetaObjects().
- Parameters:
- object - the Object that should no longer be handled.
- Overrides:
- release in class MetaObject
[all packages]
[package BR.unicamp.Guarana]
[class hierarchy]
[index]
BR.unicamp.Guarana.SequentialComposer.html