pstypes
Interface PSOperator

All Superinterfaces:
PSObject
All Known Subinterfaces:
PSArithmeticOperator, PSConsoleOperator, PSEqualityOperator, PSFlowOperator, PSPathOperator, PSStackOperator, PSStringOperator
All Known Implementing Classes:
PSAbs, PSAdd, PSArc, PSArct, PSClear, PSClosepath, PSCurrentpoint, PSDeq, PSDiv, PSDup, PSEq, PSExch, PSExit, PSFor, PSGe, PSGet, PSGt, PSIdiv, PSIf, PSIfelse, PSIndex, PSLe, PSLength, PSLineto, PSLoop, PSLt, PSMod, PSMoveto, PSMul, PSNe, PSNewpath, PSPop, PSPstack, PSRlineto, PSRmoveto, PSShow, PSShowpage, PSString, PSStroke, PSSub

public interface PSOperator
extends PSObject

Parent interface of all operator objects in Postscript.

The parent interface of all the operator objects that are found in Postscript programming language.  It is a subtype of PSObject,defining a new group of classes. It is used to group a set of classes which implement this interface to define specific types of operators.

It has a great number of subinterfaces,which specialize PSOperator's in different teams, with each interface having different semantics.


Method Summary
 java.lang.String getOperatorToken()
          Returns the token identifying this operator.
 boolean isValid(PSStack s)
          Checks if it valid to use this operator now.
 

Method Detail

getOperatorToken

public java.lang.String getOperatorToken()
Returns the token identifying this operator.

The implementor must use this function to return a word (String) which is actually the name of the operator,as it is defined by operator's semantics.  It will be implemented differently for each concrete class that defines a new operator.

Precondition : A valid operator class,which implements subinterfaces of this one,has been created.
Postcondition : A string is returned,labeling the semantics of this class.

Returns:
The token identifying this operator.

isValid

public boolean isValid(PSStack s)
                throws PSSyntaxException
Checks if it valid to use this operator now.

The programmer that implements this method,has to specify what valid is differently for each concrete class (implementing an operator) created.Validation should take notice for:
a)the number of the parameters that the current operator needs, and the number of the parameters that the stack contains
b)the type of the parameters that the current operator needs, and the number of the parameters that the stack contains.

Precondition : A valid instance of PSStack is given and the class that implements this interface is valid.
Postcondition : A reply to the question whether the operator can perfom its define behaviour.

Parameters:
s - A reference to an instance of PSStack.
Returns:
True if the operation can be executed,false otherwise.
Throws:
PSSyntaxException - The syntax of the token is wrong???