Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

gnu.java.beans.decoder
Class ConstructorContext  view ConstructorContext download ConstructorContext.java

java.lang.Object
  extended bygnu.java.beans.decoder.AbstractContext
      extended bygnu.java.beans.decoder.AbstractObjectContext
          extended bygnu.java.beans.decoder.AbstractCreatableObjectContext
              extended bygnu.java.beans.decoder.ConstructorContext
All Implemented Interfaces:
Context

class ConstructorContext
extends AbstractCreatableObjectContext

A ConstructorContext is a Context implementation which collects the parameters for a constructor call and instantiates the result object using that constructor. After that sub-contexts can invoke methods on the result object.

The constructor is invoked when a sub-context is a statement or the Context ends.


Field Summary
private  java.util.ArrayList arguments
           
private  java.lang.Class klass
           
protected  java.lang.Object object
           
 
Constructor Summary
(package private) ConstructorContext(java.lang.String id, java.lang.Class newClass)
           
 
Method Summary
 void addParameterObject(java.lang.Object o)
          Adds a parameter object to this Context if the result object has not been created yet.
protected  void addParameterObjectImpl(java.lang.Object o)
          Adds a parameter object to this Context.
protected  java.lang.Object createObject(Context outerContext)
          Creates the result object.
 java.lang.Object endContext(Context outerContext)
          Notifies that the context ends and the returns the appropriate result object.
 java.lang.Object get(int index)
          Calls an appropriate indexed get method if it is available or throws an AssemblerException if that is not allowed on this Context.
 java.lang.String getId()
          Returns this Context's unique id or null if does not have such an id.
 java.lang.Object getResult()
          Returns the result which was calculated by calling endContext() or reportStatement().
 boolean isStatement()
          Returns whether this Context is a statement (not returning result back to parent handler's Context) or not (= expression).
 void notifyStatement(Context outerContext)
          Creates the result object if it does not exist already.
 void set(int index, java.lang.Object o)
          Calls an appropriate indexed set method if it is available or throws an AssemblerException if that is not allowed on this Context.
 void setId(java.lang.String newId)
          Gives this Context a unique id.
protected  void setObject(java.lang.Object obj)
          Sets the result object of the Context.
 void setStatement(boolean b)
          Sets whether this Context is a statement or not.
 boolean subContextFailed()
          Notifies that the assembly of a subcontext failed and returns whether this Context is affected in a way that it fails too.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

arguments

private java.util.ArrayList arguments

klass

private java.lang.Class klass

object

protected java.lang.Object object
Constructor Detail

ConstructorContext

ConstructorContext(java.lang.String id,
                   java.lang.Class newClass)
Method Detail

addParameterObjectImpl

protected void addParameterObjectImpl(java.lang.Object o)
Description copied from class: AbstractCreatableObjectContext
Adds a parameter object to this Context. Implement this without caring for illegal states because this has been done already.

Specified by:
addParameterObjectImpl in class AbstractCreatableObjectContext

createObject

protected java.lang.Object createObject(Context outerContext)
                                 throws AssemblyException
Description copied from class: AbstractCreatableObjectContext
Creates the result object. This method is called only once. Implement this without checking for double invocations as this is already being prevented.

Specified by:
createObject in class AbstractCreatableObjectContext

addParameterObject

public final void addParameterObject(java.lang.Object o)
                              throws AssemblyException
Adds a parameter object to this Context if the result object has not been created yet. Otherwise an AssemblyException is thrown that indicates a wrong behavior of the decoder.


notifyStatement

public final void notifyStatement(Context outerContext)
                           throws AssemblyException
Creates the result object if it does not exist already.


endContext

public final java.lang.Object endContext(Context outerContext)
                                  throws AssemblyException
Description copied from interface: Context
Notifies that the context ends and the returns the appropriate result object.


subContextFailed

public boolean subContextFailed()
Description copied from interface: Context
Notifies that the assembly of a subcontext failed and returns whether this Context is affected in a way that it fails too.


setObject

protected final void setObject(java.lang.Object obj)
Sets the result object of the Context.


set

public final void set(int index,
                      java.lang.Object o)
               throws AssemblyException
Description copied from interface: Context
Calls an appropriate indexed set method if it is available or throws an AssemblerException if that is not allowed on this Context. The behaviour of this method is equal to List.set(int, Object).


get

public final java.lang.Object get(int index)
                           throws AssemblyException
Description copied from interface: Context
Calls an appropriate indexed get method if it is available or throws an AssemblerException if that is not allowed on this Context. The behaviour of this method is equal to List.get(int).


getResult

public final java.lang.Object getResult()
Description copied from interface: Context
Returns the result which was calculated by calling endContext() or reportStatement(). Its the handler's responsibility to care that any of these two methods was called. This is used by sub-Contexts to access this Context's result.


getId

public java.lang.String getId()
Description copied from interface: Context
Returns this Context's unique id or null if does not have such an id.

Specified by:
getId in interface Context

setId

public void setId(java.lang.String newId)
Description copied from interface: Context
Gives this Context a unique id. For convenience the id may be null which means that no id exists at all.

Specified by:
setId in interface Context

isStatement

public boolean isStatement()
Description copied from interface: Context
Returns whether this Context is a statement (not returning result back to parent handler's Context) or not (= expression).

Specified by:
isStatement in interface Context

setStatement

public void setStatement(boolean b)
Description copied from interface: Context
Sets whether this Context is a statement or not.

Specified by:
setStatement in interface Context