|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.ponder2.objects.P2Object
net.ponder2.objects.P2Block
public class P2Block
Acts as a closure encompassing PonderTalk statements. Any variables used by the statements within the block are untouched once the block is created. Blocks may have arguments that are handed in when they are executed. When a block is executed it returns returns the value of the last statement executed within the block. c.f. function calls.
Constructor Summary | |
---|---|
protected |
P2Block()
constructor for Ponder2 serialisation |
|
P2Block(java.util.Map<java.lang.String,P2Object> variables,
com.twicom.qdparser.TaggedElement block)
|
Method Summary | |
---|---|
P2Block |
asBlock()
Returns itself as a Ponder2 block |
protected P2Object |
execute(P2Object source,
P2Object... args)
Executes the block with anArray of arguments. |
P2Object |
getVariable(java.lang.String var)
Used for testing. |
protected P2Object |
onError(P2Block anErrorBlock)
associates anErrorBlock with the receiver. |
P2Object |
operation_array(P2Object source,
P2Array anArray)
Executes the block with anArray of arguments. |
P2Object |
operation_array(P2Object source,
P2Hash vars,
P2Array anArray)
Executes the block with anArray of arguments. |
protected boolean |
operation_hasArgs(P2Object source,
P2Object aHash)
Returns true if aHash contains entries that match all the names of the arguments that the block requires. |
P2Object |
operation_value0(P2Object source)
executes the block with no arguments. |
P2Object |
operation_value1(P2Object source,
P2Object arg0)
Executes the block with one argument: arg0. |
P2Object |
operation_value2(P2Object source,
P2Object arg0,
P2Object arg1)
Executes the block with two arguments: arg0 and arg1. |
P2Object |
operation_value3(P2Object source,
P2Object arg0,
P2Object arg1,
P2Object arg2)
Executes the block with three arguments: arg0, arg1 and arg2. |
P2Object |
operation_valueHash(P2Object source,
P2Object aHash)
The block is executed with the values of its arguments being taken by name from aHash. |
P2Object |
operation_valueVars(P2Object source,
P2Object aHash)
The block is executed with the values in aHash being added to the block's environment variables. |
P2Object |
readXml(com.twicom.qdparser.TaggedElement xml,
java.util.Map<java.lang.Integer,P2Serializable> read)
|
java.lang.String |
toString()
|
protected void |
whileFalse(P2Object source,
P2Object aBlock)
While the receiver is false, keep executing aBlock with no arguments |
protected void |
whileTrue(P2Object source,
P2Object aBlock)
While the receiver is true, keep executing aBlock with no arguments |
com.twicom.qdparser.TaggedElement |
writeXml(java.util.Set<P2Object> written)
|
Methods inherited from class net.ponder2.objects.P2Object |
---|
asArray, asBoolean, asClass, asDouble, asFloat, asHash, asInteger, asLong, asNumber, asP2Array, asString, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, fromXml, getManagedObject, getOID, getSMC, operation, operation, setSMC |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected P2Block()
public P2Block(java.util.Map<java.lang.String,P2Object> variables, com.twicom.qdparser.TaggedElement block)
Method Detail |
---|
public P2Block asBlock() throws Ponder2ArgumentException
P2Object
asBlock
in class P2Object
Ponder2ArgumentException
protected boolean operation_hasArgs(P2Object source, P2Object aHash) throws Ponder2Exception
aHash
- the named arguments for the block
Ponder2ArgumentException
Ponder2Exception
public P2Object operation_valueHash(P2Object source, P2Object aHash) throws Ponder2Exception
aHash
- the named arguments for the block
Ponder2Exception
public P2Object operation_valueVars(P2Object source, P2Object aHash) throws Ponder2Exception
aHash
- the named arguments for the block
Ponder2Exception
public P2Object operation_value0(P2Object source) throws Ponder2Exception
source
- the originator of the command
Ponder2Exception
public P2Object operation_value1(P2Object source, P2Object arg0) throws Ponder2Exception
source
- the originator of the commandarg0
- the first argument
Ponder2Exception
public P2Object operation_value2(P2Object source, P2Object arg0, P2Object arg1) throws Ponder2Exception
source
- the originator of the commandarg0
- the first argumentarg1
- the second argument
Ponder2Exception
public P2Object operation_value3(P2Object source, P2Object arg0, P2Object arg1, P2Object arg2) throws Ponder2Exception
source
- the originator of the commandarg0
- the first argumentarg1
- the second argumentarg2
- the third argument
Ponder2Exception
public P2Object operation_array(P2Object source, P2Array anArray) throws Ponder2Exception
source
- the originator of the commandanArray
- the Ponder2 array of arguments to be used
Ponder2Exception
public P2Object operation_array(P2Object source, P2Hash vars, P2Array anArray) throws Ponder2Exception
source
- the originator of the commandvars
- extra vars to be added to the environmentanArray
- the Ponder2 array of arguments to be used
Ponder2Exception
protected void whileTrue(P2Object source, P2Object aBlock) throws Ponder2Exception
source
- the originator of the commandaBlock
- the block to be executed
Ponder2Exception
protected void whileFalse(P2Object source, P2Object aBlock) throws Ponder2Exception
source
- the originator of the commandaBlock
- the block to be executed
Ponder2Exception
protected P2Object execute(P2Object source, P2Object... args) throws Ponder2Exception
source
- the originator of the commandargs
- the array of arguments to be used
Ponder2Exception
protected P2Object onError(P2Block anErrorBlock)
anErrorBlock
- public com.twicom.qdparser.TaggedElement writeXml(java.util.Set<P2Object> written) throws Ponder2OperationException
writeXml
in interface P2Serializable
writeXml
in class P2Object
Ponder2OperationException
public P2Object readXml(com.twicom.qdparser.TaggedElement xml, java.util.Map<java.lang.Integer,P2Serializable> read) throws Ponder2OperationException, Ponder2ArgumentException
readXml
in interface P2Serializable
readXml
in class P2Object
Ponder2OperationException
Ponder2ArgumentException
public P2Object getVariable(java.lang.String var)
var
- the name of the variable
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |