net.ponder2.objects
Class P2Boolean

java.lang.Object
  extended by net.ponder2.objects.P2Object
      extended by net.ponder2.objects.P2Boolean
All Implemented Interfaces:
java.io.Serializable, P2Serializable, ManagedObject, Ponder2Message

public class P2Boolean
extends P2Object
implements ManagedObject

A boolean object.

Version:
$Id:$
Author:
Kevin Twidle
See Also:
Serialized Form

Field Summary
static P2Boolean False
           
static P2Boolean True
           
 
Constructor Summary
protected P2Boolean()
          constructor for Ponder2 serialisation
 
Method Summary
protected  boolean and(boolean aBoolean)
          Answers a boolean being the receiver AND aBoolean
protected  boolean and(P2Object source, P2Block aBlock)
          Answers a boolean being the receiver AND the value of aBlock if the receiver is true.
 boolean asBoolean()
          Returns itself as a boolean
static P2Boolean from(java.lang.String string)
           
protected  P2Object ifFalse(P2Object source, P2Block aBlock)
          Executes aBlock if the receiver is false.
protected  P2Object ifFalseifTrue(P2Object source, P2Block aBlockFalse, P2Block aBlockTrue)
          Executes aBlockFalse if the receiver is false otherwise aBlockTrue is executed.
protected  P2Object ifTrue(P2Object source, P2Block aBlock)
          Executes aBlock if the receiver is true.
protected  P2Object ifTrueifFalse(P2Object source, P2Block aBlockTrue, P2Block aBlockFalse)
          Executes aBlockTrue if the receiver is true otherwise aBlockFalse is executed.
protected  boolean not()
          Answers a boolean being the logical NOT operator applied to the receiver
protected  boolean or(boolean aBoolean)
          Answers a boolean being the receiver OR aBoolean
protected  boolean or(P2Object source, P2Block aBlock)
          Answers a boolean being the receiver OR the value of aBlock if the receiver is false.
protected  boolean random()
          Answers with a random boolean value
 P2Object readXml(com.twicom.qdparser.TaggedElement xml, java.util.Map<java.lang.Integer,P2Serializable> read)
           
 java.lang.String toString()
           
 com.twicom.qdparser.TaggedElement writeXml(java.util.Set<P2Object> written)
           
 
Methods inherited from class net.ponder2.objects.P2Object
asArray, asBlock, 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
 

Field Detail

True

public static final P2Boolean True

False

public static final P2Boolean False
Constructor Detail

P2Boolean

protected P2Boolean()
constructor for Ponder2 serialisation

Method Detail

from

public static P2Boolean from(java.lang.String string)
                      throws Ponder2ArgumentException
Throws:
Ponder2ArgumentException

asBoolean

public boolean asBoolean()
                  throws Ponder2ArgumentException
Description copied from class: P2Object
Returns itself as a boolean

Overrides:
asBoolean in class P2Object
Returns:
the boolean value
Throws:
Ponder2ArgumentException

not

protected boolean not()
Answers a boolean being the logical NOT operator applied to the receiver

Returns:
NOT this

and

protected boolean and(boolean aBoolean)
Answers a boolean being the receiver AND aBoolean

Parameters:
aBoolean - the value for the AND operation
Returns:
this and aBoolean

or

protected boolean or(boolean aBoolean)
Answers a boolean being the receiver OR aBoolean

Parameters:
aBoolean - the value for the OR operation
Returns:
this or aBoolean

random

protected boolean random()
Answers with a random boolean value

Returns:
a random boolean value

and

protected boolean and(P2Object source,
                      P2Block aBlock)
               throws Ponder2Exception
Answers a boolean being the receiver AND the value of aBlock if the receiver is true. The block is not evaluated if the receiver is false. The block must return a boolean.

Parameters:
aBlock - the block to be executed if this is true
Returns:
this and aBlock
Throws:
Ponder2Exception

or

protected boolean or(P2Object source,
                     P2Block aBlock)
              throws Ponder2Exception
Answers a boolean being the receiver OR the value of aBlock if the receiver is false. The block is not evaluated if the receiver is true. The block must return a boolean.

Parameters:
aBlock - the block to be executed if this is false
Returns:
this or aBlock
Throws:
Ponder2Exception

ifTrue

protected P2Object ifTrue(P2Object source,
                          P2Block aBlock)
                   throws Ponder2Exception
Executes aBlock if the receiver is true. Answers the value of aBlock or Nil. No arguments are given to the block.

Parameters:
aBlock - the block to be executed if this is true
Returns:
boolean or nil
Throws:
Ponder2Exception

ifFalse

protected P2Object ifFalse(P2Object source,
                           P2Block aBlock)
                    throws Ponder2Exception
Executes aBlock if the receiver is false. Answers the value of aBlock or Nil. No arguments are given to the block.

Parameters:
aBlock - the block to be executed if this is false
Returns:
boolean or nil
Throws:
Ponder2Exception

ifTrueifFalse

protected P2Object ifTrueifFalse(P2Object source,
                                 P2Block aBlockTrue,
                                 P2Block aBlockFalse)
                          throws Ponder2Exception
Executes aBlockTrue if the receiver is true otherwise aBlockFalse is executed. Answers the return value of the block that is executed. No arguments are given to the block to be executed.

Parameters:
aBlockTrue - the block to be executed if this is true
aBlockFalse - the block to be executed if this is false
Returns:
the result of the block executed
Throws:
Ponder2Exception

ifFalseifTrue

protected P2Object ifFalseifTrue(P2Object source,
                                 P2Block aBlockFalse,
                                 P2Block aBlockTrue)
                          throws Ponder2Exception
Executes aBlockFalse if the receiver is false otherwise aBlockTrue is executed. Answers the return value of the block that is executed. No arguments are given to the block to be executed.

Parameters:
aBlockFalse - the block to be executed if this is false
aBlockTrue - the block to be executed if this is true
Returns:
the result of the block executed
Throws:
Ponder2Exception

writeXml

public com.twicom.qdparser.TaggedElement writeXml(java.util.Set<P2Object> written)
                                           throws Ponder2OperationException
Specified by:
writeXml in interface P2Serializable
Overrides:
writeXml in class P2Object
Throws:
Ponder2OperationException

readXml

public P2Object readXml(com.twicom.qdparser.TaggedElement xml,
                        java.util.Map<java.lang.Integer,P2Serializable> read)
                 throws Ponder2OperationException
Specified by:
readXml in interface P2Serializable
Specified by:
readXml in class P2Object
Throws:
Ponder2OperationException

toString

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


Copyright © 2008 Imperial College. All Rights Reserved.