com.SecurePlay
Class SPAbstractTransactionClass

java.lang.Object
  extended bycom.SecurePlay.SPRootTransactionClass
      extended bycom.SecurePlay.SPAbstractTransactionClass
All Implemented Interfaces:
SPAbstractTransactionInterface
Direct Known Subclasses:
SPTBlastClass, SPTMultiPartSecretClass, SPTMultiPartSimultaneousClass, SPTMultistepTurnClass, SPTRandomClass, SPTSecretClass, SPTShipClass, SPTSimultaneousClass, SPTStrobeClass

public class SPAbstractTransactionClass
extends SPRootTransactionClass
implements SPAbstractTransactionInterface

This is the common abstract transaction class for all transactions in the SecurePlay library

Author:
IT GlobalSecure Inc.
See Also:
SecurePlay License Information
 

Field Summary
protected  SPAbstractTransactionAPIInterface classAPI
          This is the api verion of this class
protected  java.lang.String[] configuration
          This property holds the configuration of the Transaction Instance.
protected  java.lang.String gameblock
          GameBlock or code associated with this transaction
protected  SPGameInterface gameinstance
          This is the object handler for the Game Instance Object with which the transaction is associated.
protected  java.lang.String transactionstatus
          This is a string that describes the current state of the transaction.
protected  java.lang.String transtype
          Type of Transaction
 
Fields inherited from class com.SecurePlay.SPRootTransactionClass
EventListenerList, gameID, master, playerIDList, transactionID
 
Constructor Summary
SPAbstractTransactionClass()
           
SPAbstractTransactionClass(SPGameInterface gameobj, java.lang.String master, java.lang.String[] playerIDList, boolean privateflag, java.lang.String transactionID)
          Constructor.
 
Method Summary
 boolean APIbeginTransaction(java.lang.String pid)
          This action can only be initiated by the Transaction master.
 boolean APIcompleteTransaction(java.lang.String pid)
          This method allows the Transaction Master ONLY to complete the transaction.
 boolean APIconfigureTransaction(java.lang.String pid, java.lang.String[] args)
          This method allows the Transaction Master ONLY to configure the transactions unique parameters.
 java.lang.String APIgetGameBlock()
          Gets the gameblock of this transaction.
 boolean APIrequestbeginTransaction(java.lang.String pid)
          This method allows any transaction participant excluding the Transaction master to request that the transaction be begun.
 boolean APIrequestCompleteTransaction(java.lang.String pid)
          This method allows any player, excluding the Transaction master to request that the transactoin be completed.
 boolean APIrequestconfigureTransaction(java.lang.String pid, java.lang.String[] args)
          This method allows any player, excluding the Transaction master, to request that the transaction be configured as described in the configuration array.
 boolean APIsetGameBlock(java.lang.String pid, java.lang.String newgameblock)
          This method allows the Transaction Master ONLY to set the game block.
 java.lang.String APISPawn(java.lang.String pid)
          This method creates a new transaction with the identical participants and configuration as the spawning transaction.
protected  SPAbstractTransactionInterface buildSPawn()
          This method builds the spawned transaction object
 SPAbstractTransactionInterface createTransaction(SPGameAPIInterface gameapiobj, java.lang.String master, java.lang.String[] playerIDList, boolean privateflag, java.lang.String transactionID)
          Creates a new instance of an Abstract Transaction class.
 SPAbstractTransactionAPIInterface getClassAPI()
          Gets this class's API
 java.lang.String[] getConfiguration()
          Getter function that returns the property: configuration
 SPGameInterface getGameinstance()
          Getter function that returns the property: gameinstance
 java.lang.String getLasterror()
          Getter function that returns the property: lasterror
 boolean getPrivacyFlag()
          Gets the privacy flag of this class.
 java.lang.String getTransactionstatus()
          Getter function that returns the property: transactionstatus
 java.lang.String getTransactionType()
          This method returns a String of the transactiontype.
static java.lang.String gettranstype()
          This method gets the transaction type.
 boolean isPlayerInternal(java.lang.String pid)
          Checks to see if the playr is internal
 boolean isPrivateflag()
          Getter function that returns the property: privateflag
 void logError()
          This is a shell method for future use.
protected  boolean onbeginTransaction(java.lang.String sourceID)
          This method safely updates the state of the Transaction into the "ready" state, if possible.
protected  boolean onconfigureTransaction(SPMessageClass incoming)
          This method safely configures a transaction.
protected  boolean onconfigureTransaction(java.lang.String sourceID, java.lang.String[] configarr)
          This method safely configures a transaction.
 boolean onincomingTransaction(SPMessageClass incoming)
          This method handles the various incoming messages and passes them to the appropriate message type handler.
 void onrequestbeginTransaction(SPMessageClass incoming)
          This method safely handles requests to begin the transaction.
 void onrequestcompleteTransaction(SPMessageClass incoming)
          This method safely handles requests to complete a Transaction by a player that is not the Transaction master.
protected  void onrequestconfigureTransaction(SPMessageClass incoming)
          This method safely handles a request from a player who is not the Transaction master to configure the transaction.
protected  boolean onSpawn(SPMessageClass incoming)
          This method handles incoming spawn messages.
protected  boolean pronincomingTransaction(SPMessageClass incoming)
          this is a shell for unique incoming transactions
protected  void pruniqueinit()
          shell to allow unique initialization of transactions
 boolean sendMessage(java.lang.String sender, java.lang.String[] receivers, boolean encryptflag, boolean privateflag, java.lang.String messagetype, java.lang.String[] messagebody, java.lang.String[] altmessage)
          This method sends a message.
protected  boolean setGameBlock(java.lang.String sourceID, java.lang.String newgameblock)
          This method safely sets the game bock of a transaction.
 void setTransactionID(java.lang.String tid)
          Sets the transaction id to a specified id.
protected  boolean spawnConfigure(SPAbstractTransactionInterface a)
          This method configures the spawned transaction object
 boolean transComplete()
          This method returns a flag for whether the transaction is currently in the "complete" state.
 boolean transError()
          This method returns a flag for whether the status of the transaction is in error or not.
 
Methods inherited from class com.SecurePlay.SPRootTransactionClass
APIAddListener, APIClearListeners, APIGetListenerCount, APIGetListeners, APIRemoveListener, getGameID, getMaster, getPlayerIDList, getTransactionID, isPlayerIncluded, SPnotify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.SecurePlay.SPAbstractTransactionInterface
getGameID, getMaster, getPlayerIDList, getTransactionID
 

Field Detail

gameinstance

protected SPGameInterface gameinstance
This is the object handler for the Game Instance Object with which the transaction is associated.


transactionstatus

protected java.lang.String transactionstatus
This is a string that describes the current state of the transaction. The common states are "new" - a newly created transaction, "configured" - a custom configured transaction, "ready" - a transaction ready to be begun, "complete" - a successfully completed transaction, and "error" - a transaction that has failed for some reason.


configuration

protected java.lang.String[] configuration
This property holds the configuration of the Transaction Instance.


classAPI

protected SPAbstractTransactionAPIInterface classAPI
This is the api verion of this class


gameblock

protected java.lang.String gameblock
GameBlock or code associated with this transaction


transtype

protected java.lang.String transtype
Type of Transaction

Constructor Detail

SPAbstractTransactionClass

public SPAbstractTransactionClass()

SPAbstractTransactionClass

public SPAbstractTransactionClass(SPGameInterface gameobj,
                                  java.lang.String master,
                                  java.lang.String[] playerIDList,
                                  boolean privateflag,
                                  java.lang.String transactionID)
Constructor.

Parameters:
gameobj - SPGameInterface - game associated with this transaction.
master - String - master of this transaction.
playerIDList - String[] - player id list associated with this transaction.
privateflag - boolean - privacy flag.
transactionID - String - ID associated with this transaction.
Method Detail

pruniqueinit

protected void pruniqueinit()
shell to allow unique initialization of transactions


APIbeginTransaction

public boolean APIbeginTransaction(java.lang.String pid)
This action can only be initiated by the Transaction master. It sends a "beginTransaction" message to all of the transaction participants. A Transaction can only be begun if it has been successfully configured.

Parameters:
pid - String - id of the transaction beginner, must be the master and internal.
Returns:
result - Boolean: TRUE, if successful, FALSE, if not

APIcompleteTransaction

public boolean APIcompleteTransaction(java.lang.String pid)
This method allows the Transaction Master ONLY to complete the transaction. Transactions that are in an error state cannot be cleared by completion.

Parameters:
pid - String - id of the player who is completing the transaction, must be the master and internal.
Returns:
result - Boolean: TRUE, if successful, FALSE, if not.

APIrequestCompleteTransaction

public boolean APIrequestCompleteTransaction(java.lang.String pid)
This method allows any player, excluding the Transaction master to request that the transactoin be completed.

Parameters:
pid - String - id of the requestor, can not be the master, must be internal.
Returns:
result - Boolean: TRUE, if successful, FALSE, if not

APIconfigureTransaction

public boolean APIconfigureTransaction(java.lang.String pid,
                                       java.lang.String[] args)
This method allows the Transaction Master ONLY to configure the transactions unique parameters. NOTE, this method will be overridden for individual transaction types.

Parameters:
pid - String - id of the configurer, must be internal.
args - String[] - the configuration array, with configuration details inside.
Returns:
result - Boolean: TRUE if successful, FALSE, if unsuccessful

APIrequestconfigureTransaction

public boolean APIrequestconfigureTransaction(java.lang.String pid,
                                              java.lang.String[] args)
This method allows any player, excluding the Transaction master, to request that the transaction be configured as described in the configuration array.

Parameters:
pid - String - the configure requestor, can not be the master, must be internal.
args - String[] - the configuration array, with configuration details.
Returns:
result - Boolean: TRUE, if successful, FALSE, if not

APIrequestbeginTransaction

public boolean APIrequestbeginTransaction(java.lang.String pid)
This method allows any transaction participant excluding the Transaction master to request that the transaction be begun. This can only be done after the transaction has been configured.

Parameters:
pid - String - the id of the requestor, can not be master, must be internal
Returns:
result - Boolean: TRUE, if successful, FALSE, if not

onconfigureTransaction

protected boolean onconfigureTransaction(java.lang.String sourceID,
                                         java.lang.String[] configarr)
This method safely configures a transaction. NOTE: This can only be done by the Transaction master. This method will likely be replaced by any unique transaction class implementation.

Parameters:
sourceID - String - id of the source.
configarr - String[] - configuration array
Returns:
result - Boolean: TRUE, if successful, FALSE, if not.

onbeginTransaction

protected boolean onbeginTransaction(java.lang.String sourceID)
This method safely updates the state of the Transaction into the "ready" state, if possible. This can only be initiated by the Transaction Master

Parameters:
sourceID - String - source id
Returns:
result - Boolean: TRUE, if successful, FALSE, if not

onincomingTransaction

public boolean onincomingTransaction(SPMessageClass incoming)
Description copied from interface: SPAbstractTransactionInterface
This method handles the various incoming messages and passes them to the appropriate message type handler.

Specified by:
onincomingTransaction in interface SPAbstractTransactionInterface
Parameters:
incoming - SPMessageClass - incomng message
Returns:
result - Boolean: TRUE if successful, FALSE, if unsuccessful

transComplete

public boolean transComplete()
Description copied from interface: SPAbstractTransactionInterface
This method returns a flag for whether the transaction is currently in the "complete" state.

Specified by:
transComplete in interface SPAbstractTransactionInterface
Returns:
result - Boolean: TRUE, if transaction complete, FALSE, if not.

transError

public boolean transError()
This method returns a flag for whether the status of the transaction is in error or not.

Returns:
result - Boolean: TRUE if transaction in error state, FALSE, if not.

pronincomingTransaction

protected boolean pronincomingTransaction(SPMessageClass incoming)
this is a shell for unique incoming transactions

Parameters:
incoming - SPMessageClass - incoming message
Returns:
Boolean - TRUE if successful, FALSE, if unsuccessful

onrequestcompleteTransaction

public void onrequestcompleteTransaction(SPMessageClass incoming)
This method safely handles requests to complete a Transaction by a player that is not the Transaction master.

Parameters:
incoming - SPMessageClass - incomng message

onrequestconfigureTransaction

protected void onrequestconfigureTransaction(SPMessageClass incoming)
This method safely handles a request from a player who is not the Transaction master to configure the transaction.

Parameters:
incoming - SPMessageClass - incomng message

onrequestbeginTransaction

public void onrequestbeginTransaction(SPMessageClass incoming)
This method safely handles requests to begin the transaction. Note, only the Transaction master can begin the transaction.

Parameters:
incoming - SPMessageClass - incomng message

isPlayerInternal

public boolean isPlayerInternal(java.lang.String pid)
Checks to see if the playr is internal

Parameters:
pid - String - id of the player to be checked.
Returns:
result - Boolean: TRUE if player is internal, FALSE if not

sendMessage

public boolean sendMessage(java.lang.String sender,
                           java.lang.String[] receivers,
                           boolean encryptflag,
                           boolean privateflag,
                           java.lang.String messagetype,
                           java.lang.String[] messagebody,
                           java.lang.String[] altmessage)
Description copied from interface: SPAbstractTransactionInterface
This method sends a message. It hands the configured message off to the appropriate comms service. Also, for private messages, it sends an alternate message to the parties not recieving the main message.

Specified by:
sendMessage in interface SPAbstractTransactionInterface
Parameters:
sender - String - player id of the sender.
receivers - String[] - player ids of recievers.
encryptflag - boolean - enrypted flag
privateflag - boolean - private flag
messagetype - String - message type
messagebody - String[] - the message body as a string
altmessage - String[] - alternative message.
Returns:
result - Boolean: TRUE, if successful, FALSE, if not

logError

public void logError()
This is a shell method for future use.


getClassAPI

public SPAbstractTransactionAPIInterface getClassAPI()
Description copied from interface: SPAbstractTransactionInterface
Gets this class's API

Specified by:
getClassAPI in interface SPAbstractTransactionInterface
Returns:
classAPI - SPAbstractTransactionAPIClass

getPrivacyFlag

public boolean getPrivacyFlag()
Description copied from interface: SPAbstractTransactionInterface
Gets the privacy flag of this class.

Specified by:
getPrivacyFlag in interface SPAbstractTransactionInterface
Returns:
privateflag - boolean

setTransactionID

public void setTransactionID(java.lang.String tid)
Description copied from interface: SPAbstractTransactionInterface
Sets the transaction id to a specified id.

Specified by:
setTransactionID in interface SPAbstractTransactionInterface
Parameters:
tid - String - the id of the transaction.

APISPawn

public java.lang.String APISPawn(java.lang.String pid)
This method creates a new transaction with the identical participants and configuration as the spawning transaction.

Parameters:
pid - String - player id must be master of the transaction
Returns:
tid - String - transaction id of the new spawned transaction.

onSpawn

protected boolean onSpawn(SPMessageClass incoming)
This method handles incoming spawn messages.

Parameters:
incoming - SPMessageClass - spawn message
Returns:
result - Boolean: TRUE, if successful, FALSE, if not

buildSPawn

protected SPAbstractTransactionInterface buildSPawn()
This method builds the spawned transaction object

Returns:
tran - SPAbstractTransactionInterface - spawned transaction

spawnConfigure

protected boolean spawnConfigure(SPAbstractTransactionInterface a)
This method configures the spawned transaction object

Parameters:
a - SPAbstractTransactionInterface - the transaction to be spawned
Returns:
result - Boolean: TRUE, if successful, FALSE, if not

onconfigureTransaction

protected boolean onconfigureTransaction(SPMessageClass incoming)
This method safely configures a transaction. NOTE: This can only be done by the Transaction master. This method will likely be replaced by any unique transaction class implementation.

Parameters:
incoming - SPMessageClass - incomng message
Returns:
result - Boolean: TRUE, if successful, FALSE, if not.

APIsetGameBlock

public boolean APIsetGameBlock(java.lang.String pid,
                               java.lang.String newgameblock)
This method allows the Transaction Master ONLY to set the game block.

Parameters:
pid - String - id of the player attempting to set the game block, must be internal.
newgameblock - String - the game block for this transaction.
Returns:
result - Boolean: TRUE if successful, FALSE, if unsuccessful

setGameBlock

protected boolean setGameBlock(java.lang.String sourceID,
                               java.lang.String newgameblock)
This method safely sets the game bock of a transaction. NOTE: This can only be done by the Transaction master.

Parameters:
sourceID - String - id of the source.
newgameblock - String - candidate game block
Returns:
result - Boolean: TRUE, if successful, FALSE, if not.

APIgetGameBlock

public java.lang.String APIgetGameBlock()
Description copied from interface: SPAbstractTransactionInterface
Gets the gameblock of this transaction.

Specified by:
APIgetGameBlock in interface SPAbstractTransactionInterface
Returns:
gameblock - String

getConfiguration

public java.lang.String[] getConfiguration()
Description copied from interface: SPAbstractTransactionInterface
Getter function that returns the property: configuration

Specified by:
getConfiguration in interface SPAbstractTransactionInterface
Returns:
configuration - String[]

getGameinstance

public SPGameInterface getGameinstance()
Getter function that returns the property: gameinstance

Returns:
gameinstance - SPGameInterface

getLasterror

public java.lang.String getLasterror()
Getter function that returns the property: lasterror

Returns:
lasterror - String

isPrivateflag

public boolean isPrivateflag()
Getter function that returns the property: privateflag

Specified by:
isPrivateflag in interface SPAbstractTransactionInterface
Returns:
privateflag - boolean

getTransactionstatus

public java.lang.String getTransactionstatus()
Description copied from interface: SPAbstractTransactionInterface
Getter function that returns the property: transactionstatus

Specified by:
getTransactionstatus in interface SPAbstractTransactionInterface
Returns:
transactionstatus - String

getTransactionType

public java.lang.String getTransactionType()
Description copied from interface: SPAbstractTransactionInterface
This method returns a String of the transactiontype.

Specified by:
getTransactionType in interface SPAbstractTransactionInterface
Returns:
this.transtype - String - name of transaction type

gettranstype

public static java.lang.String gettranstype()
This method gets the transaction type.

Returns:
String

createTransaction

public SPAbstractTransactionInterface createTransaction(SPGameAPIInterface gameapiobj,
                                                        java.lang.String master,
                                                        java.lang.String[] playerIDList,
                                                        boolean privateflag,
                                                        java.lang.String transactionID)
Creates a new instance of an Abstract Transaction class.

Specified by:
createTransaction in interface SPAbstractTransactionInterface
Parameters:
gameapiobj - SPGameInterface - game associated with this transaction.
master - String - master of this transaction.
playerIDList - String[] - player id list associated with this transaction.
privateflag - boolean - privacy flag.
transactionID - String - ID associated with this transaction.
Returns:
SPAbstractTransactionInterface