Class KmgFormelInterpreter
- java.lang.Object
-
- KmgFormelInterpreter
-
public class KmgFormelInterpreter extends Object
Main class of JXN. In jxn theKmgFormelInterpreter
instance is accessible via the predefined variable$this
which allows to inspect and control internal aspects using the public methods of this class.
-
-
Constructor Summary
Constructors Constructor Description KmgFormelInterpreter()
KmgFormelInterpreter(boolean strSave)
KmgFormelInterpreter(boolean strSave, boolean reinit)
KmgFormelInterpreter(Object owner)
KmgFormelInterpreter(KmgFormelInterpreter fi)
KmgFormelInterpreter(KmgFormelInterpreter.NullValueHashtable varListe)
KmgFormelInterpreter(KmgFormelInterpreter.NullValueHashtable varListe, boolean strSave)
KmgFormelInterpreter(KmgFormelInterpreter.NullValueHashtable varListe, Hashtable<String,String> strListe)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description int
addDebug(int mask)
Sets debug bits given inmask
.int
clrDebug(int mask)
Clears debug bits given inmask
.void
dump()
Deprecated.UseformatVariables()
instead.Object
eval(String statement)
Parses and executes a single statement.Object
exec(String cmd)
Executescmd
.Object
execute(String cmd)
Same asexec(java.lang.String)
.static String[]
formatPackageSearchList()
Shows the packages searched for classes (same as menu: View > PackageSearchList in JxnSession window).static String[]
formatStaticMethodClassList()
Shows the classes searched for static methods (same as menu: View > StaticMethodClasses in JxnSession window).String[]
formatVariables()
Shows all known variables (same as menu: View > Variables in JxnSession window).String[]
formatVariables(String startsWith)
Shows variable names starting with ….int
getDebug()
Returns the debug level.static int
getHideTypeOutput()
ReturnsstaticHideTypeOutput
.static ArrayList<Image>
getIconImageList()
Used internally.String
getPath(String filepath)
Returns relative filepath for parameterfilepath
.static boolean
getStaticShowConditional()
ReturnsstaticShowConditional
.static int
getVersion()
ReturnsiVersion
.boolean
isDefined(String varName)
Returnstrue
ifvarName
is known.static void
main(String[] args)
Runs JxnPortable from the command line (shell) (Recommended: Start GUI using JxnPortable/JxnStart.bat).Object
remove(String varName)
Removes variablevarName
.int
setAbort(boolean abbortOnException)
Controls if to abort after anException
(default).int
setDebug(boolean abbortOnException)
Controls if to abort after anException
(default).int
setDebug(int iDbgNew)
Sets the debug level.static int
setHideTypeOutput(int hide)
Controls output of type info in the result output.static boolean
setStaticShowConditional(boolean showConditional)
Sets show conditional uniformly for all jxn files.static int
setVersion(int newVersion)
Deprecated.Currently not used.Object
sw(String condition, String thenCmd)
ExecutesthenCmd
ifcondition
istrue
or not0
or notnull
or a char from1TtYy
.Object
sw(String condition, String thenCmd, String elseCmd)
ExecutesthenCmd
ifcondition
istrue
or not0
or notnull
or a char from1TtYy
elseelseCmd
.Object
test(String cmd)
Executes commandcmd
(used forJxnUnitTest
).
-
-
-
Constructor Detail
-
KmgFormelInterpreter
public KmgFormelInterpreter()
-
KmgFormelInterpreter
public KmgFormelInterpreter(boolean strSave)
-
KmgFormelInterpreter
public KmgFormelInterpreter(boolean strSave, boolean reinit)
-
KmgFormelInterpreter
public KmgFormelInterpreter(KmgFormelInterpreter.NullValueHashtable varListe, boolean strSave)
-
KmgFormelInterpreter
public KmgFormelInterpreter(KmgFormelInterpreter.NullValueHashtable varListe)
-
KmgFormelInterpreter
public KmgFormelInterpreter(KmgFormelInterpreter.NullValueHashtable varListe, Hashtable<String,String> strListe)
-
KmgFormelInterpreter
public KmgFormelInterpreter(Object owner)
-
KmgFormelInterpreter
public KmgFormelInterpreter(KmgFormelInterpreter fi)
-
-
Method Detail
-
main
public static void main(String[] args)
Runs JxnPortable from the command line (shell) (Recommended: Start GUI using JxnPortable/JxnStart.bat).
-
setAbort
public int setAbort(boolean abbortOnException)
Controls if to abort after anException
(default).
Example:oldDebug = $this.setAbort( false ) ! => continues script after Exception
.
DupplicatessetDebug(boolean)
- Returns:
- old value of
iDebug
-
setDebug
public int setDebug(boolean abbortOnException)
Controls if to abort after anException
(default).
Example:oldDebug = $this.setDebug( false ) ! => continues script after Exception
- Returns:
- old value of
iDebug
-
setDebug
public int setDebug(int iDbgNew)
Sets the debug level. The debug level controls additional log output to the console window. The debug level is defined as a combination (sum) of the following values:- 0 : default ⇒ abort on
Exception
- 1 : continue after
Exception
- 2 : execute (filename): shows file includes
- 4 : sets show conditional commands (
#if, #ifdef, #ifndef, #else if, #else, #return
) for the current jxn file,
see alsosetStaticShowConditional(boolean)
andJxnFunction.setShowConditional(boolean)
- 16 : shows findClass
- 32 : shows findMethod by name
- 64 : shows findMethod for operator
Example:oldDebug = $this.setDebug(4+64)
- Parameters:
iDbgNew
- sum of the above values.iDbgNew > 0
continues after anException
.- Returns:
- old value
- 0 : default ⇒ abort on
-
addDebug
public int addDebug(int mask)
Sets debug bits given inmask
.- Returns:
- old value
- See Also:
setDebug(int)
-
clrDebug
public int clrDebug(int mask)
Clears debug bits given inmask
.- Returns:
- old value
- See Also:
setDebug(int)
-
getDebug
public int getDebug()
Returns the debug level.- See Also:
setDebug(int)
-
setVersion
public static int setVersion(int newVersion)
Deprecated.Currently not used.
-
getVersion
public static int getVersion()
ReturnsiVersion
.
-
setStaticShowConditional
public static boolean setStaticShowConditional(boolean showConditional)
Sets show conditional uniformly for all jxn files.
Usage:KmgFormelInterpreter.setStaticShowConditional(true)
To set show conditional individually only for the current jxn file use:$this.
addDebug
(4)
- Returns:
- old value
- See Also:
setDebug(int)
-
getStaticShowConditional
public static boolean getStaticShowConditional()
ReturnsstaticShowConditional
.
-
setHideTypeOutput
public static int setHideTypeOutput(int hide)
Controls output of type info in the result output.
Example:KmgFormelInterpreter.setHideTypeOutput(1)
- Parameters:
hide
-
0 : show all type info (default)
1 : no type info for java primitives
2 : no class name for algebra objects
3 : class name without package path
4 : type info only for arrays
5 : hide all type info
- Returns:
- old value
-
getHideTypeOutput
public static int getHideTypeOutput()
ReturnsstaticHideTypeOutput
.
-
isDefined
public boolean isDefined(String varName)
Returnstrue
ifvarName
is known.
Usage:$this.isDefined( "varName" )
-
remove
public Object remove(String varName)
Removes variablevarName
.
Usage:$this.remove( "varName" )
or#remove varName
-
dump
public void dump()
Deprecated.UseformatVariables()
instead.
-
formatVariables
public String[] formatVariables()
Shows all known variables (same as menu: View > Variables in JxnSession window).
Usage:#edit $this.formatVariables()
-
formatVariables
public String[] formatVariables(String startsWith)
Shows variable names starting with ….
-
formatPackageSearchList
public static String[] formatPackageSearchList()
Shows the packages searched for classes (same as menu: View > PackageSearchList in JxnSession window).
Usage:#edit KmgFormelInterpreter.formatPackageSearchList()
-
formatStaticMethodClassList
public static String[] formatStaticMethodClassList()
Shows the classes searched for static methods (same as menu: View > StaticMethodClasses in JxnSession window).
Usage:#edit KmgFormelInterpreter.formatStaticMethodClassList()
-
getPath
public String getPath(String filepath)
Returns relative filepath for parameterfilepath
. MethodgetPath
is required for file access, if the current jxn file folder differs from the current default folder (user.dir) (→@File("").getAbsolutePath()
or →System.getProperty("user.dir")
)
Note: The default folder (user.dir) is determined at start of jxn as follows: If jxn is started without a file and the file is then selected with JxnSession Menu: Load… the default folder for jxn is and remains JxnPortable/user. If jxn is started with a jxn file (e.g. double-click on the file) the default folder is the folder of that (first) file. To apply a file path relative to a jxn script file folder (rather than relative to the default folder) usefn = $this.getPath("path_relative_to_jxn_file")
.- Returns:
- filepath relative to the folder of the current jxn file, if argument
filepath
is relative
filepath relative to the JxnPortable folder, iffilepath.startsWith("JXN:")
e.g.$this.getPath("JXN:user/myFile.txt")
else (absolute)filepath
as passed as argument
-
test
public Object test(String cmd)
- Parameters:
cmd
- statement_sequence (one or more statements separated by';'
) or #filename[.jxn].- Returns:
- the result of the command or the
Exception
object, if the command fails.
-
sw
public Object sw(String condition, String thenCmd, String elseCmd)
ExecutesthenCmd
ifcondition
istrue
or not0
or notnull
or a char from1TtYy
elseelseCmd
.
Usage:$this.sw( condition, thenCmd, elseCmd )
- Parameters:
condition
- single statementthenCmd
- statement_sequence (one or more statements separated by';'
) or #filename[.jxn]elseCmd
- statement_sequence (one or more statements separated by';'
) or #filename[.jxn]
-
sw
public Object sw(String condition, String thenCmd)
ExecutesthenCmd
ifcondition
istrue
or not0
or notnull
or a char from1TtYy
.
Usage:$this.sw( condition, thenCmd )
- Parameters:
condition
- single statementthenCmd
- statement_sequence (one or more statements separated by';'
) or #filename[.jxn]
-
exec
public Object exec(String cmd)
Executescmd
.
Usage:$this.exec( command )
- Parameters:
cmd
- statement_sequence (one or more statements separated by';'
) or #filename[.jxn].- Returns:
- the result of the
cmd
. A script terminates ifcmd
throws anException
-
execute
public Object execute(String cmd)
Same asexec(java.lang.String)
.
-
-