public class JZtxtcmdScript
extends javax.script.CompiledScript
JZtxtcmd
in the srcJava_Zbnf source package.
This class is independent of ZBNF. It is used for working in srcJava_vishiaBase environment.
It means, without the srcJava_Zbnf source package all sources of that are able to compile, but
this class have not data, respectively it is not instantiated. It may be possible to instantiate
and fill by direct invocation of the new_semantic(...) and add_semantic(...) operations, for example
for simple scripts.Modifier and Type | Class and Description |
---|---|
static class |
JZtxtcmdScript.AccessFilesetname
This class contains the fileset-variable name and maybe an FilePath as accessPath.
|
static interface |
JZtxtcmdScript.AddSub2List |
static class |
JZtxtcmdScript.Argument
Argument for a subroutine.
|
static class |
JZtxtcmdScript.AssignExpr |
static class |
JZtxtcmdScript.CallStatement |
static class |
JZtxtcmdScript.CmdInvoke
class for a cmd execution (operation system cmd process invocation).
|
static class |
JZtxtcmdScript.CondStatement |
static class |
JZtxtcmdScript.DataText
In ZBNF: <*dataAccess:formatString>
|
static class |
JZtxtcmdScript.DefClasspathVariable |
static class |
JZtxtcmdScript.DefClassVariable |
static class |
JZtxtcmdScript.DefContainerVariable
It is a List, either as constant container or as any java.util.List-instance.
|
static class |
JZtxtcmdScript.DefFilepath
A Filepath variable.
|
static class |
JZtxtcmdScript.DefListElement
A list element is a statement in the
JZtxtcmdScript.JZcmditem.statementlist of the JZtxtcmdScript.DefContainerVariable item. |
static class |
JZtxtcmdScript.DefVariable |
static class |
JZtxtcmdScript.ExitStatement |
static class |
JZtxtcmdScript.FileOpArg |
static class |
JZtxtcmdScript.ForStatement |
static class |
JZtxtcmdScript.IfCondition |
static class |
JZtxtcmdScript.IfStatement |
static class |
JZtxtcmdScript.JZcmdCalculatorExpr |
static class |
JZtxtcmdScript.JZcmdClass
A class in the JZcmd syntax.
|
static class |
JZtxtcmdScript.JZcmdDataAccess
This class wraps the
DataAccess.DataAccessSet to support JZcmd-specific enhancements. |
static class |
JZtxtcmdScript.JZcmdDatapathElement
This class extends the
DatapathElement respectively SetDatapathElement
with more references which contains the method arguments which should be evaluated with the JZcmd
capability. |
static class |
JZtxtcmdScript.JZcmdDatapathElementClass |
static class |
JZtxtcmdScript.JZcmdInclude |
static class |
JZtxtcmdScript.JZcmdInstanceofExpr |
static class |
JZtxtcmdScript.JZcmditem
Common Superclass for a JZcmd script item.
|
static class |
JZtxtcmdScript.JZscriptSettings |
static class |
JZtxtcmdScript.Onerror
This class contains expressions for error handling.
|
static class |
JZtxtcmdScript.Scriptfile
For one scriptfile, on include use extra instance per include.
|
static class |
JZtxtcmdScript.StatementList
Organization class for a list of script elements inside another Scriptelement.
|
static class |
JZtxtcmdScript.Subroutine |
static class |
JZtxtcmdScript.TextColumn
JZcmditem which contain a column for text positioning.
|
static class |
JZtxtcmdScript.TextOut |
static class |
JZtxtcmdScript.ThreadBlock |
static class |
JZtxtcmdScript.UserFileset
A < fileset> in the ZmakeStd.zbnf.
|
static class |
JZtxtcmdScript.ZbnfJZcmdScript
Main class for ZBNF parse result.
|
static class |
JZtxtcmdScript.Zmake |
Modifier and Type | Field and Description |
---|---|
protected JZtxtcmdScript.JZcmditem |
checkJZcmdFile
Text expression for a file name where the script content is written to.
|
(package private) JZtxtcmdScript.JZcmditem |
checkJZcmdXmlFile
Text expression for a file name where the parsed script in XML is written to.
|
(package private) java.util.Map<java.lang.String,JZtxtcmdScript.JZcmdClass> |
classesAll |
(package private) LogMessage |
console |
(package private) java.io.File |
fileScript
The file which has contained the script.
|
(package private) JZtxtcmdScript.JZscriptSettings |
jzScriptSettings |
(package private) JZtxtcmdScript.Subroutine |
mainRoutine
The script element for the whole file.
|
(package private) JZtxtcmdScript.JZcmdClass |
scriptClass
The class which presents the script level.
|
(package private) JZtxtcmdEngine |
scriptEngine
The JSR-223-conform engine for this script.
|
(package private) java.util.Map<java.lang.String,JZtxtcmdScript.Subroutine> |
subroutinesAll
All subroutines of this script with name class.sub in alphabetic order to search.
|
static java.lang.String |
version
Version, history and license.
|
(package private) XmlNode |
xmlSrc
Only set if checkJZcmdXmlFile is not null, removed after processing.
|
Constructor and Description |
---|
JZtxtcmdScript(LogMessage console,
java.io.File fileScript,
JZtxtcmdEngine scriptEngine)
Creates.
|
Modifier and Type | Method and Description |
---|---|
void |
addContentToSelectContainer(JZtxtcmdScript.AddSub2List list)
Adds the content of the translated script to any list or map which contains all subroutines of the script,
maybe a list for selection.
|
private void |
addSubOfJZcmdClass(JZtxtcmdScript.JZcmdClass jzcmdClass,
JZtxtcmdScript.AddSub2List list,
int level)
Core and recursively called routine.
|
static JZtxtcmdScript |
createScriptFromFile(java.io.File fileScript,
LogMessage log,
java.io.File checkXmlOutput)
Translates with given script in text format.
|
static JZtxtcmdScript |
createScriptFromString(StringPartScan sourceScript,
LogMessage log,
java.io.File checkXmlOutput,
java.io.File fileScript)
Translates with given script in text format.
|
java.lang.Object |
eval(javax.script.ScriptContext context)
Executes the main routine of the script.
|
JZtxtcmdScript.JZcmdClass |
getClass(java.lang.CharSequence name) |
JZtxtcmdEngine |
getEngine() |
JZtxtcmdScript.Subroutine |
getMain() |
JZtxtcmdScript.Subroutine |
getSubroutine(java.lang.CharSequence name) |
java.util.Set<java.util.Map.Entry<java.lang.String,JZtxtcmdScript.Subroutine>> |
iterSubroutines()
Allows to iterate over all given subroutines.
|
JZtxtcmdScript.JZcmdClass |
scriptClass() |
private void |
setScriptFromString(StringPartScan sourceScript,
JZtxtcmdScript.ZbnfJZcmdScript zbnfDstScript,
java.io.File dirIncludeBase,
java.io.File checkXmlOutput)
Translates, internally and recursively for included scripts
|
void |
writeStruct(java.lang.Appendable out) |
public static final java.lang.String version
iterSubroutines()
necessary to search all sub routines with a specified name pattern,
Used for org.vishia.gral.cfg.GuiCfg
in srcJava_vishiaGui component.
JZtxtcmdScript.JZcmditem.writeStructLine(Appendable)
starts now with "JZtxtcmdScript: "
because elsewhere its output cannot be associated "what is it" in applications. Only console output.
JZtxtcmdScript#createScriptFromString(org.vishia.util.StringPartScan, MainCmdLogging_ifc, File, File)
the included script statements are stored in the JZtxtcmdScript.JZcmdInclude
item itself,
and executed in this order.
setScriptFromString(StringPartScan, ZbnfJZcmdScript, File, File)
:
Now it is possible to read an include script from an operation,
which is hence stored in the jar file. Syntay is: include %<#?backlevel>:pkg.path.Class.operation()
.
The backlevel
is to built a reference current directory for further includes.
It should be relative in the same working tree, usual on the root of a working tree.
JZtxtcmdScript.JZcmditem.new_textExpr(ZbnfParseResultItem)
:
If this new text expression has no semantic specification for attribute "indent" written as (exmpl) ?.indent=-3
then the indent of the parent is valid. It is better for generated text.
JZtxtcmdScript.JZcmditem.new_textExpr(ZbnfParseResultItem)
also in JZtxtcmdScript.StatementList.new_textExpr(ZbnfParseResultItem)
#createScriptFromString(StringPartScan, MainCmdLogging_ifc, File, File)
with null as fileScript arg now runs as described.
#createScriptFromFile(File, MainCmdLogging_ifc, File)
and #createScriptFromString(StringPartScan, MainCmdLogging_ifc, File, File)
added. The adequate routines in org.vishia.jztxtcmd.JZtxtcmd#translateAndSetGenCtrl(StringPartScan, MainCmdLogging_ifc, File, File)
is obsolete yet. This change was possible with joining srcJava_Zbnf with srcJava_vishiaBase because the ZbnfParser
is necessary for that.
The motivation was: Re-translated a script in a graphical environment (build with JZtxtcmd). It should be simple. It is a refactoring.
ZbnfParser
capability for define attributes on a syntax item
and the capability of JZtxtcmdScript.StatementList.new_textExpr(ZbnfParseResultItem)
with the result item.
JZtxtcmdScript.Subroutine
now has the reference JZtxtcmdScript.Subroutine.theScript
to get the script
for a JZtxtcmdExecuter#execSub(Subroutine, List, boolean, Appendable, File, CmdExecuter)
invocation.
JZtxtcmdExecuter.ExecuteLevel.jzcmdMain
JZtxtcmdScript.JZcmdClass.listClassesAndSubroutines
JZtxtcmdScript.Subroutine.new_List()
necessary in any zbnf syntax (where...).
JZtxtcmdScript.DefContainerVariable
: A List is accepted as container for constant elements now, changed in JZtxtcmdSyntax
.
DefSubtext now supported.
JZtxtcmdScript.StatementList.new_hasNext()
returns a JZtxtcmdScript.StatementList
instead JZtxtcmdScript.JZcmditem
because there may be not only one const text element between <:hasNext>...<.hasNext>. No change in the JZtxtcmdExecuter
necessary.
JZtxtcmdScript.StatementList.set_plainText(String)
because it is done only one time on preparation of the script, not more as one in any loop of execution.
It is changed in functionality: <:s>
to skip over white spaces and the next line indentation.
The JZtxtcmdScript.JZscriptSettings
is created as composite one time in this class and referenced in
JZtxtcmdScript.StatementList.jzSettings
for usage in that functionality.
JZtxtcmdScript.FileOpArg
File: "myFile".exists()
or adequate. A relative filename
is related to the JZtxtcmdExecuter.ExecuteLevel.currdir()
.
text = path/to/output
is able to set in the script yet too.
JZcmditem#add_dataStruct(StatementList)
with 'M' instead 'X' adequate to change in JZcmdExecuter.
JZtxtcmdScript.JZcmditem.scriptException(String)
JZtxtcmdScript.DefClassVariable
with JZtxtcmdScript.DefClassVariable.loader
:
Syntax: Class var = :loader: package.path.Class; with a loader.
JZtxtcmdScript.JZcmdDatapathElementClass.dpathClass
:
Using a Class variable instead constant package.path.Class possible.
Syntax: new &datapath.Classvar:(args) and java &datapath.Classvar:method(args):
fileScript
stored here.
JZtxtcmdScript.JZcmditem
has one of 4 active associations for its content.
JZtxtcmdScript.JZcmditem
. That class contains only elements which are necessary for all statements. Some special statements
have its own class with some more elements, especially for the ZBNF parse result. Compare it with the syntax
in JZtxtcmdSyntax
.
#translateAndSetGenCtrl(File)
returns void.
JZtxtcmdScript.JZcmditem.parentList
and JZtxtcmdScript.StatementList.parentStatement
<:include:path>
of a sub script is supported up to now.
<:scriptclass:JavaPath>
is supported up to now.
ZbatchExpressionSet#ascertainValue(Object, Map, boolean, boolean, boolean)
is moved
and adapted from TextGenerator.getContent. It is a feauture from the Expression to ascertain its value.
That method and ZbatchExpressionSet#text()
can be invoked from a user script immediately.
The ZbatchExpressionSet
is used in org.vishia.zmake.ZmakeUserScript
.
XXXXXXStatement
('e',...) which can have ZbatchExpressionSet#constValue
instead a ZbatchExpressionSet#datapath
.
ZbnfDataPathElement
is a derived class of DataAccess.DatapathElement
which contains destinations for argument parsing of a called Java-subroutine in a dataPath.
XXXXXXStatement
and a JZtxtcmdScript.Argument
have the same usage aspects for arguments
which represents values either as constants or dataPath. Use Argument as super class for ScriptElement.
ZbatchExpressionSet#textArg
if a data path is given, use for formatting a numerical value.
#translateAndSetGenCtrl(StringPartBase)
etc.
CalculatorExpr
for expressions.
XXXXXXStatement#datapath
with DataAccess.DatapathElement
XXXXXXStatement
instead Zbnf_ScriptElement (shorter). The Scriptelement
is the component for the genContent-Elements now instead Zbnf_genContent. This class contains attributes of the
content elements. Only if a sub content is need, an instance of Zbnf_genContent is created as XXXXXXStatement#statementlist
.
Furthermore the XXXXXXStatement#statementlist
should be final because it is only created if need for the special
XXXXXXStatement#elementType
-types (TODO). This version works for org.vishia.stateMGen.StateMGen
.
org.vishia.zbatch.ZbatchExecuter
now too.
final LogMessage console
final java.io.File fileScript
final JZtxtcmdEngine scriptEngine
getEngine()
.final java.util.Map<java.lang.String,JZtxtcmdScript.Subroutine> subroutinesAll
final java.util.Map<java.lang.String,JZtxtcmdScript.JZcmdClass> classesAll
JZtxtcmdScript.Subroutine mainRoutine
<*subtext:name:...>
protected JZtxtcmdScript.JZcmditem checkJZcmdFile
JZtxtcmdScript.JZcmditem checkJZcmdXmlFile
XmlNode xmlSrc
JZtxtcmdScript.JZcmdClass scriptClass
JZtxtcmdScript.JZscriptSettings jzScriptSettings
public JZtxtcmdScript(LogMessage console, java.io.File fileScript, JZtxtcmdEngine scriptEngine)
console
- fileScript
- The file which has contained the script. It is used only to provide the variables
'scriptdir' and 'scriptfile' for execution. The file is not evaluated. It means, it does not need
to exist.public static JZtxtcmdScript createScriptFromFile(java.io.File fileScript, LogMessage log, java.io.File checkXmlOutput) throws javax.script.ScriptException
fileScript
- The file which has contained the script. It is used only to provide the variables
'scriptdir' and 'scriptfile' for execution. The file is not evaluated. It means, it does not need
to exist.sourceScript
- The content of fileScript or from any other source. This is the script source.
Use new StringPartScan.StringPartScan(CharSequence)
to create one with a String given syntax.log
- if null then the MainCmdLoggingStream
is used with System.out.checkXmlOutput
- may be null, for output the script in XML form.javax.script.ScriptException
public static JZtxtcmdScript createScriptFromString(StringPartScan sourceScript, LogMessage log, java.io.File checkXmlOutput, java.io.File fileScript) throws javax.script.ScriptException
fileScript
- The file which has contained the script. It is used only to provide the variables
'scriptdir' and 'scriptfile' for execution. The file is not evaluated. It means, it does not need
to exist.sourceScript
- The content of fileScript or from any other source. This is the script source.
Use new StringPartScan.StringPartScan(CharSequence)
to create one with a String given syntax.log
- if null then the MainCmdLoggingStream
is used with System.out.checkXmlOutput
- may be null, for output the script in XML form.javax.script.ScriptException
private void setScriptFromString(StringPartScan sourceScript, JZtxtcmdScript.ZbnfJZcmdScript zbnfDstScript, java.io.File dirIncludeBase, java.io.File checkXmlOutput) throws javax.script.ScriptException, java.io.FileNotFoundException
java.io.FileNotFoundException
javax.script.ScriptException
public java.lang.Object eval(javax.script.ScriptContext context) throws javax.script.ScriptException
eval
in class javax.script.CompiledScript
javax.script.ScriptException
CompiledScript.eval(javax.script.ScriptContext)
public JZtxtcmdEngine getEngine()
getEngine
in class javax.script.CompiledScript
public JZtxtcmdScript.JZcmdClass scriptClass()
public final JZtxtcmdScript.Subroutine getMain()
public java.util.Set<java.util.Map.Entry<java.lang.String,JZtxtcmdScript.Subroutine>> iterSubroutines()
public JZtxtcmdScript.Subroutine getSubroutine(java.lang.CharSequence name)
public JZtxtcmdScript.JZcmdClass getClass(java.lang.CharSequence name)
public void writeStruct(java.lang.Appendable out) throws java.io.IOException
java.io.IOException
public void addContentToSelectContainer(JZtxtcmdScript.AddSub2List list)
private void addSubOfJZcmdClass(JZtxtcmdScript.JZcmdClass jzcmdClass, JZtxtcmdScript.AddSub2List list, int level)
jzcmdClass
- firstly the script class, nested the sub classes.level
- firstly 1, nested 2...