Class FormCalcScriptHandler.FormCalcParser
- java.lang.Object
-
- com.adobe.xfa.formcalc.CalcParser
-
- com.adobe.xfa.scripthandler.formcalc.FormCalcScriptHandler.FormCalcParser
-
- All Implemented Interfaces:
com.adobe.xfa.formcalc.CalcParserConstants
,DebugHost
,ProtocolHost
,ScriptHost
,java.lang.Cloneable
- Enclosing class:
- FormCalcScriptHandler
public static class FormCalcScriptHandler.FormCalcParser extends com.adobe.xfa.formcalc.CalcParser implements ScriptHost, ProtocolHost, DebugHost
-
-
Field Summary
-
Fields inherited from class com.adobe.xfa.formcalc.CalcParser
CODESIZE, DATASIZE, jj_nt, moCode, moData, moFrame, moScope, mStack, token, token_source
-
Fields inherited from interface com.adobe.xfa.formcalc.CalcParserConstants
ALLOWKEYWORDS, ALNUM_PART, ALPHA_PART, AND1, AND2, ASGN, BREAK, COMMA, CONTINUE, DEFAULT, DIV, DO, DOT, DOTDOT, DOTHASH, DOTSTAR, DOWNTO, ELSE, ELSEIF, END, ENDFOR, ENDFUNC, ENDIF, ENDWHILE, EOF, EQ1, EQ2, ERROR, EXIT, EXPONENT_PART, FOR, FOREACH, FUNC, GE1, GE2, GT1, GT2, HEXDIGIT, IDENT, IF, IN, INTEGER, INTEGER_PART, KEYID, LBRACE, LE1, LE2, LPAREN, LT1, LT2, MINUS, NE1, NE2, NOT, NULL1, NULL2, OR1, OR2, PLUS, RBRACE, REAL, RETURN, RPAREN, STAR, STEP, STRING, THEN, tokenImage, UPTO, VAR, WHILE
-
-
Constructor Summary
Constructors Constructor Description FormCalcParser(AppModel oAppModel, FormCalcScriptHandler oScriptHandler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
breakPoint(com.adobe.xfa.formcalc.CalcParser oParser, int nScriptID, int nLine, boolean bSet)
Abstract method that sets or clears a breakpoint.boolean
cancelActionOccured()
Method that is called periodically during script execution.boolean
command(com.adobe.xfa.formcalc.CalcParser oParser, int eCmd)
Abstract method that allows for single-stepping.Obj
getItem(java.lang.String sItem, Obj[] oObj)
Abstract method to get the handle of a SOM object.CalcSymbol[]
getItemValue(java.lang.String sItem, Obj[] oObj)
Virtual method to get the value(s) of a SOM reference.java.lang.String
getStackTrace(com.adobe.xfa.formcalc.CalcParser oParser)
Abstract method that returns a new-line delimited string showing the current stack and parameter values.CalcSymbol
getUrl(java.lang.String sUrl)
Abstract method to get data from an URL.void
getVariables(com.adobe.xfa.formcalc.CalcParser oParser, java.util.List<java.lang.String> oNames, java.util.List<CalcSymbol> oValues)
Abstract method that returns parallel lists of variables/parameters and values (the lists are the same size).void
poll()
Abstract method that is called periodically during script execution.CalcSymbol
postUrl(java.lang.String sUrl, java.lang.String sSoapHeader, java.lang.String sData, java.lang.String sContentType, java.lang.String sEnc)
Abstract method to post data to an URL and get its response.int
putItem(Obj[] oObj, CalcSymbol oValue)
Virtual method to set the value of an SOM reference.int
putItemValue(java.lang.String sItem, Obj[] oObj, CalcSymbol oValue)
Virtual method to set the value of a SOM reference.CalcSymbol
putUrl(java.lang.String sUrl, java.lang.String sData, java.lang.String sEnc)
Abstract method to put data to an URL.int
stopped(int nScriptID, int nLine)
Abstract method that is called when the engine stops in debug mode.-
Methods inherited from class com.adobe.xfa.formcalc.CalcParser
Accessor, AdditiveExpression, And, ArgumentList, Arguments, AssignmentExpression, BlockExpression, BreakExpression, clone, compile, Condition, ContinueExpression, debugEnable, DeclarationExpression, disable_tracing, Do, DotOp, Elif, ElifExpression, Else, enable_tracing, EndFor, EndFunc, EndIf, EndVar, EndWhile, Eq, EqualityExpression, evaluate, Expression, ExpressionList, For, Foreach, ForeachExpression, ForExpression, FormCalculation, Func, Function, FunctionCall, Ge, generateParseException, getCalcResult, getDupsMode, getNextToken, getToken, Gt, Identifier, If, IfExpression, In, inUse, Le, LogicalAndExpression, LogicalOrExpression, Lt, MultiplicativeExpression, Ne, Null, Number, Or, ParameterList, Parameters, PrimaryExpression, putScript, ReInit, ReInit, ReInit, ReInit, RelationalExpression, setDebugHost, setDisplayHost, setDupsMode, setLegacyScripting, setLocale, setProtocolHost, setScriptHost, setScriptID, setSyntaxCheckMode, SimpleExpression, Step, Then, To, UnaryExpression, Var, Variable, While, WhileExpression
-
-
-
-
Constructor Detail
-
FormCalcParser
public FormCalcParser(AppModel oAppModel, FormCalcScriptHandler oScriptHandler)
-
-
Method Detail
-
getItem
public Obj getItem(java.lang.String sItem, Obj[] oObj)
Description copied from interface:ScriptHost
Abstract method to get the handle of a SOM object.A SOM reference provides access to objects, object properties and methods, as well as access to the values of objects, properties and methods. A SOM reference may be qualified, as in, for example, Field2.Color[2].Value, Field3[-1] -- some of which may be relative to the current object. A SOM reference may also contain any number of object literals of the form #N where N is a non-negative number corresponding to the 0-based index of an array of ObjImpl *. As an example of SOM references with object literals consider: #0.Parent, and #0.SetColor(#1.Border[1].Value)
The return object is an object handle -- an ObjImpl *. If the given SOM reference refers to several SOM objects, this method should throw an exception.
- Specified by:
getItem
in interfaceScriptHost
- Parameters:
sItem
- a given SOM reference.oObj
- an array of objects. If non-null, this is array whose size corresponds to the maximal object literal occurence in the given SOM reference.- Returns:
- a returned object upon success.
-
getItemValue
public CalcSymbol[] getItemValue(java.lang.String sItem, Obj[] oObj)
Description copied from interface:ScriptHost
Virtual method to get the value(s) of a SOM reference.A SOM reference provides access to objects, object properties and methods, as well as access to the values of objects, properties and methods. A SOM reference may be qualified, as in, for example, Field2.Color[2].Value, Field3[-1] -- some of which may be relative to the current object. A SOM reference may also contain any number of object literals of the form #N where N is a non-negative number corresponding to the 0-based index of an array of Obj. As an example of SOM references with object literals consider: #0.Parent, and #0.SetColor(#1.Border[1].Value)
The return values are objects of type
CalcSymbol
which are no more than typed-values.
References to:- null-valued objects should be returned as
CalcSymbol
s of type TypeNull. - string-valued objects should be returned as
CalcSymbol
s of type TypeString. - numeric-valued objects should be preferably returned
as string-valued
CalcSymbol
s of type TypeString to avoid loss of precision, although it is possible for them to be returned as numeric-valuedCalcSymbol
s of type TypeDouble. - errors should be returned as error-valued
CalcSymbol
s of type TypeError.
To illustrate all the above, here's a degenerate implementation that, irrespective of the SOM reference given, always returns a single value of type error, accompanied with an "unknown accessor" message text.
import com.adobe.xfa.formcalc.ScriptHost; import com.adobe.xfa.formcalc.CalcSymbol; import com.adobe.xfa.Obj; import com.adobe.xfa.ut.MsgFormat; import com.adobe.xfa.ut.ResId; class FormCalcUser implements ScriptHost { CalcSymbol[] getItemValue(String sItem, Obj[] oObj) { MsgFormat sFmt = new MsgFormat(ResId.FC_ERR_ACCESSOR); sFmt.format(sItem); CalcSymbol[] oRetValues = new CalcSymbol[1]; oRetValues[0] = new CalcSymbol(sFmt, true); return oRetValues; } ... };
- Specified by:
getItemValue
in interfaceScriptHost
- Parameters:
sItem
- a SOM reference.oObj
- an array of objects. If non-null, this is an array whose size corresponds to the maximal object literal occurence in the given SOM reference.- Returns:
- the resulting array of values upon success.
- null-valued objects should be returned as
-
putItemValue
public int putItemValue(java.lang.String sItem, Obj[] oObj, CalcSymbol oValue)
Description copied from interface:ScriptHost
Virtual method to set the value of a SOM reference.A SOM reference provides access to objects, object properties and methods, as well as access to the values of objects, properties and methods. A SOM reference may be qualified, as in, for example, Field2.Color[2].Value, Field3[-1] -- some of which may be relative to the current object. A SOM reference may also contain any number of object literals of the form #N where N is a non-negative number corresponding to the 0-based index of an array of ObjImpl *. As an example of SOM references with object literals consider: #0.Parent, and #0.SetColor(#1.Border[1].Value)
The given SOM reference may refer to more than one scripting object, in which case this methods sets the value of several SOM objects.
The given value is an object of type
CalcSymbol
which again, is no more than a typed-value. Only CalcSymbols of one of these types will ever be involved:- null-valued objects of type CalcTypeNull,
- string-valued objects of type CalcTypeString, and possibly,
- string-valued objects of type CalcTypeVariable.
CalcSymbol.getStringValue()
method to get the CalcSymbols's value. To illustrate all the above, here's a degenerate implementation that, stores the given object into a hash table indexed by the given SOM reference.import com.adobe.xfa.formcalc.ScriptHost; import com.adobe.xfa.formcalc.CalcSymbol; import com.adobe.xfa.ut.Obj; import java.util.HashMap; class FormCalcUser implements ScriptHost { HashMap moMap; int PutItemValue(String sItem, Obj[] oObj, CalcSymbol oValue) { moMap.remove(sItem); moMap.put(sItem, oValue); return 0; } ... };
- Specified by:
putItemValue
in interfaceScriptHost
- Parameters:
sItem
- the given SOM reference.oObj
- an array of objects. If non-null, this is an array whose size corresponds to the maximal object literal occurence in the given SOM reference.oValue
- the given object value.- Returns:
- 0 upon success.
-
putItem
public int putItem(Obj[] oObj, CalcSymbol oValue)
Description copied from interface:ScriptHost
Virtual method to set the value of an SOM reference.The given value is an object of type
CalcSymbol
which again, is no more than a typed-value. Only CalcSymbols of one of these types will ever be involved:- null-valued objects of type CalcTypeNull,
- string-valued objects of type CalcTypeString, and possibly,
- string-valued objects of type CalcTypeVariable.
CalcSymbol.getStringValue()
method to get the CalcSymbols's value.- Specified by:
putItem
in interfaceScriptHost
- Parameters:
oObj
- an array of objects. If non-null, this is an array whose size corresponds to the maximal object literal occurence in the given SOM reference.oValue
- the given object value.- Returns:
- 0 upon success.
-
getUrl
public CalcSymbol getUrl(java.lang.String sUrl) throws CalcException
Description copied from interface:ProtocolHost
Abstract method to get data from an URL.- Specified by:
getUrl
in interfaceProtocolHost
- Parameters:
sUrl
- the URL to get.- Returns:
- a returned CalcSymbol value upon success.
- Throws:
CalcException
-
putUrl
public CalcSymbol putUrl(java.lang.String sUrl, java.lang.String sData, java.lang.String sEnc) throws CalcException
Description copied from interface:ProtocolHost
Abstract method to put data to an URL.- Specified by:
putUrl
in interfaceProtocolHost
- Parameters:
sUrl
- the URL to put.sData
- the data to put.sEnc
- the encoding to use.- Returns:
- a returned CalcSymbol value upon success.
- Throws:
CalcException
-
postUrl
public CalcSymbol postUrl(java.lang.String sUrl, java.lang.String sSoapHeader, java.lang.String sData, java.lang.String sContentType, java.lang.String sEnc) throws CalcException
Description copied from interface:ProtocolHost
Abstract method to post data to an URL and get its response.- Specified by:
postUrl
in interfaceProtocolHost
- Parameters:
sUrl
- the URL to post.sSoapHeader
- an optional post header.sData
- the data to post.sEnc
- the encoding to use.- Returns:
- a returned CalcSymbol value upon success.
- Throws:
CalcException
-
stopped
public int stopped(int nScriptID, int nLine)
Description copied from interface:DebugHost
Abstract method that is called when the engine stops in debug mode.
-
poll
public void poll()
Description copied from interface:DebugHost
Abstract method that is called periodically during script execution.
-
breakPoint
public boolean breakPoint(com.adobe.xfa.formcalc.CalcParser oParser, int nScriptID, int nLine, boolean bSet)
Description copied from interface:DebugHost
Abstract method that sets or clears a breakpoint.- Specified by:
breakPoint
in interfaceDebugHost
- Parameters:
oParser
- the parser to affect.nScriptID
- the ID of script, which had been set viaCalcParser.setScriptID(int)
.nLine
- the line of script.bSet
- true if setting breakpoint; false if clearing it.- Returns:
- true if successful.
-
command
public boolean command(com.adobe.xfa.formcalc.CalcParser oParser, int eCmd)
Description copied from interface:DebugHost
Abstract method that allows for single-stepping. Note that this call does not actually cause any script to be executed. Rather, it sets the internal state so that the next time the appropriate condition is met, the Stopped callback will be called.
-
getStackTrace
public java.lang.String getStackTrace(com.adobe.xfa.formcalc.CalcParser oParser)
Description copied from interface:DebugHost
Abstract method that returns a new-line delimited string showing the current stack and parameter values.- Specified by:
getStackTrace
in interfaceDebugHost
- Parameters:
oParser
- the parser to query.- Returns:
- a new-line delimited string showing the current stack and parameter values.
-
getVariables
public void getVariables(com.adobe.xfa.formcalc.CalcParser oParser, java.util.List<java.lang.String> oNames, java.util.List<CalcSymbol> oValues)
Description copied from interface:DebugHost
Abstract method that returns parallel lists of variables/parameters and values (the lists are the same size). The symbols are not copied, so they must not be stored for later use. Note that it's only meaningful to call this function from within a break-point.- Specified by:
getVariables
in interfaceDebugHost
- Parameters:
oParser
- the parser to query.oNames
- returned list of variable/parameter names.oValues
- returned list of values.
-
cancelActionOccured
public boolean cancelActionOccured()
Description copied from interface:ScriptHost
Method that is called periodically during script execution. The method returns true if user has pressed Esc Key during the execution of FormCalc.- Specified by:
cancelActionOccured
in interfaceScriptHost
-
-