public class CommonAstSupport.Library
extends java.lang.Object
Implementation of common, AST related actions, such as persistence, AST node addition and removal, string and basic output services, adding nodes to the results view, etc.
Implementation of services to put, get, and remove annotations to/from ASTs.
Constructor and Description |
---|
Library() |
Modifier and Type | Method and Description |
---|---|
boolean |
absolutePath(java.lang.String path)
Compares the current source AST's path from the root with the
specified path.
|
boolean |
addAllToView(java.util.List<Aast> list)
Add the current copy AST to the filtered view of ASTs which can
be pipelined to the next ruleset.
|
boolean |
addAncestorToView(long level)
Add a specified ancestor of the current copy AST to the filtered
view of ASTs which can be pipelined to the next ruleset, if the
all nodes in the ancestry chain (up to and including the specified
level) are not
null . |
void |
addNewProgramFile(Aast root)
Add the given AST as a new program file, by registering its filename.
|
boolean |
addParentToView()
Add the parent of the current copy AST to the filtered view of
ASTs which can be pipelined to the next ruleset, if the parent
node is not
null . |
boolean |
addPathToViewFrom(long type)
Add to the filtered view of ASTs all of the nodes which form the
path from an ancestor node of type
type to the current
copy AST. |
boolean |
addToView()
Add the current copy AST to the filtered view of ASTs which can
be pipelined to the next ruleset.
|
boolean |
addToView(java.lang.Long id)
Add the AST specified by the passed ID to the filtered view of ASTs
which can be pipelined to the next ruleset.
|
boolean |
addTreeToView(long maxLevels)
Add the current copy AST, and all of its descendants through
maxLevels generations, to the filtered view of ASTs
which can be pipelined to the next ruleset. |
boolean |
ancestor(long type,
long maxLevels)
Implementation of the
ancestor user function. |
boolean |
breakpoint(java.lang.String location,
boolean suspend,
java.lang.Object... args)
Logs a list of
Object s in ERR console with a (usually short) description. |
java.lang.String |
charAt(java.lang.String text,
int index)
Get the character at the specified index, as a string.
|
boolean |
childAt(long type,
long index)
Compares the current source AST's immediate descendant (direct
child) at a specific 0-based index for a match with a specific token
type.
|
java.lang.Class |
classForName(java.lang.String name)
Get the class with the given name.
|
java.lang.Class |
classForName(java.lang.String name,
boolean noThrow)
Get the class with the given name.
|
void |
clearNewProgramFiles()
Clear the list of newly, generated,
program file
names . |
boolean |
closeStream(java.lang.Long id)
Closes a stream that was previously opened and which was associated
with a specific ID.
|
boolean |
compareNodes(Aast node1,
Aast node2)
Check if two nodes are equivalent (if they represent the same expression so they will
probably generate the same code.
|
void |
compileError(int id,
java.lang.String message)
Throws a
CompileException with a user-defined message. |
void |
compileError(int id,
java.lang.String message,
Aast ast)
Throws a
CompileException with a user-defined message. |
java.lang.String |
copies(java.lang.String text,
int num)
Returns a string that is comprised of the input string concatenated
num times without intervening spaces. |
java.lang.Object |
create(java.lang.Class<?> target,
java.lang.Object[] args)
Create a new instance of the specified class, passing the provided
arguments to its constructor.
|
java.lang.Object |
create(java.lang.String className,
java.lang.Object[] args)
Create a new instance of the specified class, passing the provided
arguments to its constructor.
|
java.util.List<?> |
createList(java.lang.Object[] elements)
Create a new
List which contains the specified
elements as its members. |
java.util.List<?> |
createListFromObject(java.lang.Object array)
Generate a list from an array of objects.
|
<K,V> java.util.LinkedHashMap<K,V> |
createMap(java.util.Set<K> keys,
java.util.List<V> values)
Create a linked hash map whose keys are defined by
keys
and whose values are defined by values . |
java.util.Map<?,?> |
createMapAstKeyToAst(java.lang.String name)
|
java.util.Map<?,?> |
createMapAstKeyToInt(java.lang.String name)
Create a db-backed map, with a
AstKey key and Integer values. |
java.util.Map<?,?> |
createMapAstKeyToString(java.lang.String name)
Create a db-backed map, with a
AstKey key and String values. |
java.util.Map<?,?> |
createMapFrameAstKeyToString(java.lang.String name)
Create a db-backed map, with a
FrameAstKey key and String values. |
java.util.LinkedHashSet<?> |
createSet(java.lang.Object[] elements)
Create a linked hash set containing the specified elements.
|
java.util.Map<?,?> |
createString2IntMap(java.lang.String name)
Create a db-backed map, with a
String key and an Integer value. |
java.util.Map<?,?> |
createString2LongMap(java.lang.String name)
Create a db-backed map, with a
String key and a Long value. |
java.util.Map<?,?> |
createString2StringMap(java.lang.String name)
Create a db-backed map, with a
String key and a String value. |
java.util.Map<?,?> |
createStringMapToLongSet(java.lang.String name)
Create a db-backed map, with a
String key and as values another set, having
Long for key. |
java.util.Map<?,?> |
createStringMapToStringMap(java.lang.String name)
Create a db-backed map, with a
String key and as values another map, having
String for both key and value. |
java.util.Map<?,?> |
createStringMapToStringSet(java.lang.String name)
Create a db-backed map, with a
String key and as values another set, having
String for key. |
java.util.Set<?> |
createStringSet(java.lang.String name)
Create a db-backed set, with a
String key. |
java.util.UUID |
createUUID(long high,
long low)
Creates new UUID instance from the supplied data.
|
boolean |
declaresMember(java.lang.Class cls,
java.lang.String name)
Tests whether the specified class declares member of the supplied name.
|
boolean |
descendant(long type,
long maxLevels)
Implementation of the
descendant user function. |
boolean |
downPath(java.lang.String path)
Determines if the current source AST's path downward matches
the specified path, on a case-insensitive basis.
|
boolean |
dumpStack()
Debug method to print a stack trace dump to
stderr . |
void |
endCurrentWalk()
End the current AST walk.
|
java.lang.Boolean |
eval(java.lang.String expr)
Implementation of the
eval user function. |
java.lang.Boolean |
evalLib(java.lang.String name,
java.lang.Object[] args)
Implementation of the
evalLib user function. |
java.lang.Object |
exec(java.lang.String expr)
Implementation of the
exec user function. |
java.lang.Object |
execLib(java.lang.String name,
java.lang.Object[] args)
Implementation of the
execLib user function. |
java.lang.String |
fixupFileName(java.lang.String text)
Fixing the file name for special Windows requirement.
|
java.lang.String |
fixupRegex(java.lang.String text)
Fixing the regular expression string for special Windows requirement.
|
void |
forceMapValue(java.util.Map<?,?> map,
java.lang.Object key,
java.lang.Object value)
For the given db-backed map (if not in runtime conversion mode), force a logged change
with the given key and value, for the currently processed AST.
|
boolean |
fprintf(java.lang.Long id,
java.lang.String format,
java.lang.Object[] args)
Given a format string using C-like
printf syntax, and
an array of runtime replacement arguments, perform formatted variable
substitution and APPEND the resulting string to previously opened
stream identified by a numeric ID. |
boolean |
fprintf(java.lang.String filename,
java.lang.String format,
java.lang.Object[] args)
Given a format string using C-like
printf syntax, and
an array of runtime replacement arguments, perform formatted variable
substitution and APPEND the resulting string to a named file. |
java.util.Set<java.lang.String> |
getAllClassesInPackage(java.lang.String pkg)
Get the simple java class names for all classes in this package (builtin or converted code).
|
Aast |
getAnalog()
Get the AST node which is located in the copy tree at the analogous
index position as the current source AST, with respect to their
respective parents.
|
Aast |
getAncestor(java.lang.Integer index,
java.lang.String key,
java.lang.Object value,
java.lang.Object[] types)
Return the first ancestor node with the specified annotation,
optionally refining the match by annotation value and/or token type.
|
Aast |
getAncestor(java.lang.String key,
java.lang.Object value,
java.lang.Object[] types)
Return the first ancestor node with the specified annotation,
optionally refining the match by annotation value and/or token type.
|
java.lang.Boolean |
getAncestorNoteBoolean(long level,
java.lang.String key)
Gets a
Boolean annotation from the specified ancestor
in the copy AST. |
java.lang.Boolean |
getAncestorNoteBoolean(long level,
java.lang.String key,
java.lang.Boolean defaultValue)
Gets a
Boolean annotation from the specified ancestor
in the copy AST. |
java.lang.Boolean |
getAncestorNoteBoolean(long level,
java.lang.String key,
long index)
Gets a
Boolean annotation at a specific index from an
array annotation in the specified ancestor of the current
copy AST. |
java.lang.Double |
getAncestorNoteDouble(long level,
java.lang.String key)
Gets a
Double annotation from the specified ancestor
in the copy AST. |
java.lang.Double |
getAncestorNoteDouble(long level,
java.lang.String key,
long index)
Gets a
Double annotation at a specific index from an
array annotation in the specified ancestor of the current
copy AST. |
java.lang.Long |
getAncestorNoteLong(long level,
java.lang.String key)
Gets a
Long annotation from the specified ancestor
in the copy AST. |
java.lang.Long |
getAncestorNoteLong(long level,
java.lang.String key,
long index)
Gets a
Long annotation at a specific index from an
array annotation in the specified ancestor of the current
copy AST. |
java.lang.String |
getAncestorNoteString(long level,
java.lang.String key)
Gets a
String annotation from the specified ancestor
in the copy AST. |
java.lang.String |
getAncestorNoteString(long level,
java.lang.String key,
long index)
Gets a
String annotation at a specific index from an
array annotation in the specified ancestor of the current
copy AST. |
Aast |
getAncestorOfType(java.lang.Object[] types)
Return the first ancestor node which matches one of the specified
token types.
|
java.lang.String |
getAncestorTreeDump(long level)
Accesses the text representation (human readable 'parser output') of
the tree rooted at the specified ancestor AST node, if such a node
exists.
|
Aast |
getAst(java.lang.Long id)
Returns an AST instance referenced by its ID if it is loaded (and
registered) in the current resolver.
|
Aast |
getAst(java.lang.Long id,
boolean loadTree)
Returns an AST instance referenced by its ID.
|
long |
getChildIndex()
Returns the 0-based child index of the current AST.
|
java.lang.String |
getClassSimpleName(java.lang.String className)
Returns the simple class name of the supplied (fully qualified) class name.
|
long |
getColumn()
Get the column number in the source code file at which the current
source AST was found.
|
java.lang.String |
getConfigParameter(java.lang.String id)
Retrieve value of specified configuration variable.
|
java.lang.Boolean |
getConfigParameter(java.lang.String id,
boolean def)
Retrieve value of specified configuration variable.
|
java.lang.String |
getConfigParameter(java.lang.String id,
java.lang.String def)
Retrieve value of specified configuration variable.
|
java.lang.String |
getConvertedSimpleClassName(java.lang.String qname)
Get the converted simple class name for the specified fully-qualified 4GL class name.
|
Aast |
getCopy()
Get the instance of the copy AST currently set in the resolver.
|
long |
getDepth()
Get the number of generations away from the root AST node this AST
is located (in the source AST).
|
java.lang.String |
getFile()
Get the name of the source code file associated with the current
source AST.
|
int |
getGapMarking(java.lang.String classname)
Get the gap marking for the specified Java class, implementing a legacy OE class.
|
int |
getGapMarking(java.lang.String classname,
java.lang.String method,
java.lang.String signature)
Get the gap marking for the specified method in the given Java class, implementing a
legacy OE method.
|
java.lang.Long |
getId()
Get the project-unique AST node ID of the current, source AST.
|
long |
getLeftSiblings()
Returns the number of siblings to the current AST's left.
|
java.lang.String |
getLegacyName(java.lang.Class<?> cls,
java.lang.String methodName)
Returns the legacy name of the supplied method on the supplied class.
|
long |
getLine()
Get the line number in the source code file at which the current
source AST was found.
|
java.lang.reflect.Method |
getMethod(java.lang.Class cls,
java.lang.String name,
java.lang.Object[] paramTypes)
Resolve a reflective method, given a class, method name, and
parameter signature.
|
java.lang.String |
getMethodNoCase(java.lang.Class cls,
java.lang.String insensitiveName)
Tests whether the specified class has tge method of the supplied name.
|
java.lang.Class |
getMethodParamType(java.lang.Class cls,
java.lang.String methodName,
int requiredParamNum,
int paramIdx,
java.lang.Class expectedParamType)
Returns method parameter type on the specified index.
|
java.lang.String |
getName()
Get the token name of the current, source AST.
|
int |
getNextChildIndex()
Implementation of the
nextChildIndex user
variable which denotes which child is about to be processed when
processing a 'next-child' rule. |
java.lang.Boolean |
getNoteBoolean(java.lang.String key)
Gets a
Boolean annotation from the current,
copy AST. |
java.lang.Boolean |
getNoteBoolean(java.lang.String key,
long index)
Gets a
Boolean annotation at a specific index from an
array annotation in the current copy AST. |
java.lang.Double |
getNoteDouble(java.lang.String key)
Gets a
Double annotation from the current,
copy AST. |
java.lang.Double |
getNoteDouble(java.lang.String key,
long index)
Gets a
Double annotation at a specific index from an
array annotation in the current copy AST. |
java.lang.Long |
getNoteLong(java.lang.String key)
Gets a
Long annotation from the current,
copy AST. |
java.lang.Long |
getNoteLong(java.lang.String key,
long index)
Gets a
Long annotation at a specific index from an
array annotation in the current copy AST. |
long |
getNoteSize(java.lang.String key)
Returns the size of an array annotation as indexed by an arbitrary
key.
|
java.lang.String |
getNoteString(java.lang.String key)
Gets a
String annotation from the current,
copy AST. |
java.lang.String |
getNoteString(java.lang.String key,
long index)
Gets a
String annotation at a specific index from an
array annotation in the current copy AST. |
java.lang.String |
getNoteType(java.lang.String key)
Determines the type of an annotation (if it exists) as indexed by an
arbitrary key.
|
long |
getNow()
Get the current system time in milliseconds since the epoch.
|
long |
getNumBytesWritten(java.lang.Long id)
Returns the number of bytes written to this stream since it was
opened.
|
long |
getNumImmediateChildren()
Implementation of the
numImmediateChildren user
variable. |
Aast |
getParent()
Get the current, source AST's parent, if any.
|
java.lang.String |
getPath()
Accesses the full path from the current source AST to the root.
|
java.lang.String |
getPersistenceFilename()
Returns the project relative filename of the copy AST persistence
file, using the default persistence naming convention.
|
java.lang.Boolean |
getReferenceNoteBoolean(long id,
java.lang.String key)
Gets a
Boolean annotation from the referenced node
in the copy AST. |
java.lang.Boolean |
getReferenceNoteBoolean(long id,
java.lang.String key,
long index)
Gets a
Boolean annotation at a specific index from an
array annotation in the referenced node of the current
copy AST. |
java.lang.Double |
getReferenceNoteDouble(long id,
java.lang.String key)
Gets a
Double annotation from the referenced node
in the copy AST. |
java.lang.Double |
getReferenceNoteDouble(long id,
java.lang.String key,
long index)
Gets a
Double annotation at a specific index from an
array annotation in the referenced node of the current
copy AST. |
java.lang.Long |
getReferenceNoteLong(long id,
java.lang.String key)
Gets a
Long annotation from the referenced node
in the copy AST. |
java.lang.Long |
getReferenceNoteLong(long id,
java.lang.String key,
long index)
Gets a
Long annotation at a specific index from an
array annotation in the referenced node of the current
copy AST. |
java.lang.String |
getReferenceNoteString(long id,
java.lang.String key)
Gets a
String annotation from the referenced node
in the copy AST. |
java.lang.String |
getReferenceNoteString(long id,
java.lang.String key,
long index)
Gets a
String annotation at a specific index from an
array annotation in the referenced node of the current
copy AST. |
java.lang.Class |
getResourceType(java.lang.Class clazz,
java.lang.String method)
Returns the resource type declared by the supplied method.
|
long |
getRightSiblings()
Returns the number of siblings to the current AST's right.
|
java.lang.Object |
getStoredObject(java.lang.String id)
Get the object stored by the pattern engine under the given id.
|
java.lang.Object |
getStoredObject(java.lang.String category,
java.lang.String id)
Get the object stored by the pattern engine under the given category and id.
|
java.lang.String |
getText()
Get the token text of the current source AST.
|
Aast |
getThis()
Get the instance of the source AST currently set in the resolver.
|
java.lang.String |
getTreeDump()
Accesses the text representation (human readable 'parser output') of
the tree rooted at the current AST node.
|
int |
getType()
Get the token type of the current, source AST.
|
boolean |
imaginary()
Implementation of the
imaginary user function. |
long |
indexOf(java.lang.String text,
java.lang.String find)
Returns the 0-based index of the first character that matches
the find string in the input string or -1 if no match was found.
|
long |
indexOf(java.lang.String text,
java.lang.String find,
long start)
Returns the 0-based index of the first character that matches
the find string after the starting point in the input string or -1
if no match was found.
|
java.lang.Object |
invoke(java.lang.reflect.Method method,
java.lang.Object target,
java.lang.Object[] args)
Helper function to invoke an arbitrary method through reflection.
|
boolean |
isAst(java.lang.String filename)
Determines if the given file is a valid AST.
|
boolean |
isConditionalRuleSets()
Check if conditional rule-sets is activated.
|
boolean |
isDenormalizeDynamicTempTables()
Check whether the extent properties in dynamic temp-tables should be denormalized.
|
boolean |
isFlagActivated(java.lang.String flag)
If conditional rule-set is enabled, check if the given flag is activated.
|
boolean |
isNote(java.lang.String key)
Determines if an annotation exists of any
String ,
Double , Long , or Boolean
value, indexed by an arbitrary key. |
boolean |
isRuntimeConfig()
Determines whether the
Configuration is in conversion mode (configuration is read
from the configuration directory) or server run time mode. |
boolean |
isRuntimeQueryMode()
Check if the current mode is for runtime-conversion of query/tables.
|
long |
lastIndexOf(java.lang.String text,
java.lang.String find)
Returns the 0-based index of the first character of the last match
to the find string in the input string or -1 if no match was found.
|
long |
lastIndexOf(java.lang.String text,
java.lang.String find,
long start)
Returns the 0-based index of the first character of the last match
of the find string before the starting point in the input string or
-1 if no match was found.
|
boolean |
leaf()
Implementation of the
leaf user function. |
ClassDefinition |
loadClassDefinition(java.lang.String clsName)
Get the parser's
ClassDefinition for a given qualified class name, in legacy form. |
ConvertedClassName |
loadConvertedClass(java.lang.String filename,
boolean isNew,
Aast ast)
Load the specified converted class.
|
ConvertedClassName |
loadConvertedClassByQname(java.lang.String qname)
Load the specified converted class.
|
Aast |
loadTree(java.lang.String filename)
Load the AST stored in the given file.
|
java.lang.String |
lower(java.lang.String text)
Lowercase and return the given string.
|
boolean |
matches(java.lang.String text,
java.lang.String regex)
Determine whether
text matches the specified regular
expression. |
boolean |
matches(java.lang.String text,
java.lang.String regex,
boolean sensitive)
Determine whether
text matches the specified regular
expression, taking the caller's case-sensitivity into account. |
private boolean |
matchTokenType(Aast node,
java.lang.Object[] types)
Determine whether the token type of the specified node matches any
of the given types.
|
int |
nextSequenceValue(java.lang.String name)
Get the next value for the given sequence.
|
datetimetz |
now()
Get the NOW value.
|
java.lang.Long |
openStoredStream(java.lang.String name)
Opens a new in-memory stream for writing, associates an unique ID with that stream and
stores it (can be retrieved later using
PatternEngine.getStoredObject(String) ). |
java.lang.Long |
openStream(java.lang.String filename,
boolean projectRelative)
Opens a new stream for writing and associates a unique ID with that
stream.
|
java.math.BigDecimal |
parseBigDecimal(java.lang.String text)
Parse a
BigDecimal from text and return it. |
datetime |
parseDatetimeLiteral(java.lang.String text)
Parse the ISO8601 text as a datetime literal.
|
datetimetz |
parseDatetimetzLiteral(java.lang.String text)
Parse the ISO8601 text as a datetimetz literal.
|
java.lang.Double |
parseDouble(java.lang.String text)
Parse a
Double from text and return it. |
java.lang.Double |
parseDoubleQuiet(java.lang.String text)
Parse a
Double from text and return it. |
java.lang.Long |
parseLong(java.lang.String text)
Parse a
Long from text and return it. |
java.lang.Long |
parseLong(java.lang.String text,
int radix)
Parse a
Long from text using the given
radix, and return it. |
java.lang.Long |
parseLongQuiet(java.lang.String text)
Parse a
Long from text and return it. |
java.lang.Long |
parseLongQuiet(java.lang.String text,
int radix)
Parse a
Long from text using the given
radix, and return it. |
Aast |
parseTree(java.lang.String filename)
Load the AST stored in the given file and return it.
|
boolean |
persist()
Persist the copy AST to file, using the default persistence naming
convention.
|
boolean |
persist(Aast root,
java.lang.String filename,
boolean projectRelative,
boolean terse)
Persist the specified AST to file, using the default persistence naming
convention.
|
boolean |
persist(java.lang.String filename,
boolean projectRelative)
Persist the copy AST to file, using the default persistence naming
convention.
|
boolean |
persist(java.lang.String filename,
boolean projectRelative,
boolean terse)
Persist the copy AST to file, using the default persistence naming
convention.
|
boolean |
print(java.lang.String text)
Debug user function implementation to print text to stdout.
|
boolean |
printAst()
Prints a string representation of the current source AST to stdout,
indented appropriately to indicate its depth in the AST structure.
|
boolean |
printf(java.lang.String format,
java.lang.Object[] args)
Prints a string formatted by
sprintf(java.lang.String, java.lang.Object[]) to stdout
with no trailing line break. |
boolean |
printfln(java.lang.String format,
java.lang.Object[] args)
Prints a string formatted by
sprintf(java.lang.String, java.lang.Object[]) to stdout
with a trailing line break. |
boolean |
println(java.lang.String text)
Debug user function implementation to print text to stdout, followed
by a line break.
|
boolean |
putAncestorNote(long level,
java.lang.String key,
java.lang.Boolean value)
Store an annotation of type
Boolean in the specified
ancestor in the copy AST. |
boolean |
putAncestorNote(long level,
java.lang.String key,
java.lang.Boolean value,
long index)
Store an element in an array annotation of type
Boolean
at the specified index in the specified ancestor in the copy
AST. |
boolean |
putAncestorNote(long level,
java.lang.String key,
java.lang.Double value)
Store an annotation of type
Double in the specified
ancestor in the copy AST. |
boolean |
putAncestorNote(long level,
java.lang.String key,
java.lang.Double value,
long index)
Store an element in an array annotation of type
Double
at the specified index in the specified ancestor in the copy
AST. |
boolean |
putAncestorNote(long level,
java.lang.String key,
java.lang.Long value)
Store an annotation of type
Long in the specified
ancestor in the copy AST. |
boolean |
putAncestorNote(long level,
java.lang.String key,
java.lang.Long value,
long index)
Store an element in an array annotation of type
Long
at the specified index in the specified ancestor in the copy
AST. |
boolean |
putAncestorNote(long level,
java.lang.String key,
java.lang.String value)
Store an annotation of type
String in the specified
ancestor in the copy AST. |
boolean |
putAncestorNote(long level,
java.lang.String key,
java.lang.String value,
long index)
Store an element in an array annotation of type
String
at the specified index in the specified ancestor in the copy
AST. |
boolean |
putNote(java.lang.String key,
java.lang.Boolean value)
Store an annotation of type
Boolean in the current
copy AST. |
boolean |
putNote(java.lang.String key,
java.lang.Boolean value,
long index)
Store an annotation of type
Boolean at the specified
index in an array annotation in the current copy AST. |
boolean |
putNote(java.lang.String key,
java.lang.Double value)
Store an annotation of type
Double in the current
copy AST. |
boolean |
putNote(java.lang.String key,
java.lang.Double value,
long index)
Store an annotation of type
Double at the specified
index in an array annotation in the current copy AST. |
boolean |
putNote(java.lang.String key,
java.lang.Long value)
Store an annotation of type
Long in the current
copy AST. |
boolean |
putNote(java.lang.String key,
java.lang.Long value,
long index)
Store an annotation of type
Long at the specified
index in an array annotation in the current copy AST. |
boolean |
putNote(java.lang.String key,
java.lang.String value)
Store an annotation of type
String in the current
copy AST. |
boolean |
putNote(java.lang.String key,
java.lang.String value,
long index)
Store an annotation of type
String at the specified
index in an array annotation in the current copy AST. |
boolean |
putReferenceNote(long id,
java.lang.String key,
java.lang.Boolean value)
Store an annotation of type
Boolean in the referenced
node in the copy AST. |
boolean |
putReferenceNote(long id,
java.lang.String key,
java.lang.Boolean value,
long index)
Store an element in an array annotation of type
Boolean
at the specified index in the referenced node in the copy
AST. |
boolean |
putReferenceNote(long id,
java.lang.String key,
java.lang.Double value)
Store an annotation of type
Double in the referenced
node in the copy AST. |
boolean |
putReferenceNote(long id,
java.lang.String key,
java.lang.Double value,
long index)
Store an element in an array annotation of type
Double
at the specified index in the referenced node in the copy
AST. |
boolean |
putReferenceNote(long id,
java.lang.String key,
java.lang.Long value)
Store an annotation of type
Long in the referenced
node in the copy AST. |
boolean |
putReferenceNote(long id,
java.lang.String key,
java.lang.Long value,
long index)
Store an element in an array annotation of type
Long
at the specified index in the referenced node in the copy
AST. |
boolean |
putReferenceNote(long id,
java.lang.String key,
java.lang.String value)
Store an annotation of type
String in the referenced
node in the copy AST. |
boolean |
putReferenceNote(long id,
java.lang.String key,
java.lang.String value,
long index)
Store an element in an array annotation of type
String
at the specified index in the referenced node in the copy
AST. |
java.lang.String |
quoteReplacement(java.lang.String text)
Calling the java.util.regex.Matcher.quoteReplacement().
|
void |
registerTree(Aast ast)
Register the given AST and all its descendants with the AST resolver.
|
boolean |
relativePath(java.lang.String path)
Determines if the current source AST's path from the root ends
with the specified path, on a case-insensitive basis.
|
boolean |
remove()
Removes the current AST node from the copy AST.
|
boolean |
removeAncestorNote(long level,
java.lang.String key)
Remove an annotation from the specified ancestor in the
copy AST.
|
boolean |
removeAncestorNote(long level,
java.lang.String key,
long index)
Remove an element (at the specified index) of an array annotation
from an annotation specified by the key in the specified ancestor of
the current copy AST.
|
void |
removeAst(java.lang.Long id)
Remove the entire tree enclosing the specified AST from the resolver.
|
boolean |
removeNote(java.lang.String key)
Remove an annotation from the current copy AST.
|
boolean |
removeNote(java.lang.String key,
long index)
Remove an element (at the specified index) of an array annotation
from an annotation specified by the key in the current copy
AST.
|
java.lang.String |
removeQuotes(java.lang.String text)
Strip enclosing double or single quotes, if any, plus any options, from the given string.
|
boolean |
removeReferenceNote(long id,
java.lang.String key)
Remove an annotation from the referenced node in the
copy AST.
|
boolean |
removeReferenceNote(long id,
java.lang.String key,
long index)
Remove an element (at the specified index) of an array annotation
from an annotation referenced by the key in the referenced node of
the current copy AST.
|
boolean |
returnsHandle(java.lang.Class clazz,
java.lang.String method)
Returns
true if the supplied method declares handle as its return type. |
boolean |
root()
Implementation of the
root user function. |
void |
saveClasses()
Save all the 4GL classes (builtin or business logic), .NET or Java classes encountered
during parsing.
|
void |
setConvertedClassName(java.lang.String filename,
java.lang.String legacyName,
java.lang.String pkgname,
java.lang.String classname)
For a given legacy class, set its converted Java name and package.
|
boolean |
setText(java.lang.String text)
Set the token text of the current copy AST.
|
boolean |
setType(long type)
Set the token type of the current, copy AST.
|
boolean |
sibling(long type)
Test whether any of the current AST's siblings matches the given
token type.
|
java.util.List<?> |
splitToList(java.lang.String val,
java.lang.String delim)
Split the given value into a list of
String 's, using the given delimiter. |
java.lang.String |
sprintf(java.lang.String format,
java.lang.Object[] args)
Given a format string using C-like
printf syntax, and
an array of runtime replacement arguments, perform formatted variable
substitution and return the resulting string. |
void |
storeObject(java.lang.String id,
java.lang.Object object)
Store the given object under the given id.
|
void |
storeObject(java.lang.String category,
java.lang.String id,
java.lang.Object object)
Store the given object under the given category and id.
|
java.lang.String |
string(boolean value)
Convert a boolean value to its default string representation.
|
java.lang.String |
string(double value)
Convert a numeric value to its default string representation.
|
java.lang.String |
string(long value)
Convert a numeric value to its default string representation.
|
long |
stringLength(java.lang.String text)
Returns the length in characters of the given string.
|
java.lang.String |
substring(java.lang.String text,
long index)
Returns the portion of the input string from the 0-based index
to the end.
|
java.lang.String |
substring(java.lang.String text,
long begin,
long end)
Returns the portion of the input string from the 0-based index
to the end.
|
java.lang.String |
switchQuotes(java.lang.String text,
java.lang.String prevQuoteChar,
java.lang.String newQuoteChar)
Prepare the given text so that its quotes can be switched from the previous quote to the
new quotes.
|
void |
throwException(java.lang.String message)
Throws a
CommonAstSupport.UserGeneratedException with a
user-defined message. |
void |
throwException(java.lang.String message,
Aast ast)
Throws a
CommonAstSupport.UserGeneratedException with a
user-defined message. |
java.math.BigDecimal |
toBigDecimal(java.lang.Double num)
Convert a
double value to a BigDecimal . |
date |
today()
Get the TODAY value.
|
java.lang.String |
trimLeading(java.lang.String text)
Trim leading whitespace from
text , without triggering
a NullPointerException if text is
null . |
java.lang.String |
trimTrailing(java.lang.String text)
Trim trailing whitespace (space, tab, CR and LF) from
text , without triggering a
NullPointerException if text is null . |
java.lang.String |
trimTrailingSpaces(java.lang.String text)
Trim only trailing spaces from
text , without triggering a
NullPointerException if text is null . |
boolean |
upPath(java.lang.String path)
Determines if the current source AST's path upward matches
the specified path, on a case-insensitive basis.
|
java.lang.String |
upper(java.lang.String text)
Uppercase and return the given string.
|
void |
withServicesFile(java.lang.String filename)
Mark this file 'with_services'.
|
java.util.List |
wrapText(java.lang.String text,
int width)
Wrap a text string to fit into one or more lines of the specified
width.
|
public int getGapMarking(java.lang.String classname)
The gap is read from the LegacyResourceSupport
annotation.
classname
- The fully-qualified Java class name.public int getGapMarking(java.lang.String classname, java.lang.String method, java.lang.String signature)
The gap is read from the LegacyResourceSupport
annotation.
classname
- The fully-qualified Java class name.method
- The Java method name.signature
- The legacy signature for the OE method. This must match with the Java method's
LegacySignature
.public ConvertedClassName loadConvertedClass(java.lang.String filename, boolean isNew, Aast ast) throws java.lang.ClassNotFoundException
ClassDefinition
structure for a new class (to be later populated with members by the parser), or will
restore an instance from an already-converted class.filename
- The file name for the legacy OO class.isNew
- Flag indicating that this is a new class (now being parsed), or a previously
converted class.ast
- The abstract syntax tree node.java.lang.ClassNotFoundException
- If the class can't be resolved or loaded.public ConvertedClassName loadConvertedClassByQname(java.lang.String qname) throws java.lang.ClassNotFoundException
qname
- The legacy OO class qualified name.java.lang.ClassNotFoundException
- If the class can't be resolved or loaded.public ClassDefinition loadClassDefinition(java.lang.String clsName)
ClassDefinition
for a given qualified class name, in legacy form.clsName
- The qualified legacy class name.ClassDefinition
instance, or null
if it does not
exist.public void endCurrentWalk()
AstSymbolResolver.setEndWalk(boolean)
public java.lang.Class classForName(java.lang.String name) throws java.lang.ClassNotFoundException
TYPE
member.name
- Name of a class, or the type name of a primitive.java.lang.ClassNotFoundException
- if no class is found for name
.public java.lang.Class classForName(java.lang.String name, boolean noThrow) throws java.lang.ClassNotFoundException
TYPE
member.name
- Name of a class, or the type name of a primitive.noThrow
- Set to true
to never throw any exception.null
.java.lang.ClassNotFoundException
- if no class is found for name
and noThrow
is false.public java.lang.reflect.Method getMethod(java.lang.Class cls, java.lang.String name, java.lang.Object[] paramTypes) throws java.lang.NoSuchMethodException
cls
- Method's class.name
- Name of the method.paramTypes
- Array of classes representing the types of the parameters
expected by the method.java.lang.NoSuchMethodException
- if the method as described does not exist.public java.lang.Object invoke(java.lang.reflect.Method method, java.lang.Object target, java.lang.Object[] args) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
method
- Method to invoke.target
- Object upon which the method will be invoked.args
- Parameters passed to the method.java.lang.IllegalAccessException
- if method object enforces Java language access control and
the underlying method is inaccessible.java.lang.reflect.InvocationTargetException
- if the underlying method throws an exception.public boolean declaresMember(java.lang.Class cls, java.lang.String name)
cls
- Class to test.name
- Target member name.true
if the class declares the supplied member, false
otherwise.public java.lang.String getMethodNoCase(java.lang.Class cls, java.lang.String insensitiveName)
cls
- Class to test.insensitiveName
- Case insensitive target method name.null
if not found.public java.lang.Class getMethodParamType(java.lang.Class cls, java.lang.String methodName, int requiredParamNum, int paramIdx, java.lang.Class expectedParamType)
cls
- The target class.methodName
- The target case sensitive method name.requiredParamNum
- Only match methods with the specified number of parameters.paramIdx
- The index of the parameter type to return.expectedParamType
- Expected paramater type. This helps in finding the correct method overload.null
if the target method is not found or the target method
doesn't declare the requested parameter.public java.lang.Class getResourceType(java.lang.Class clazz, java.lang.String method)
handle
by declaring
the annotation ResourceType
with the
resource type defined.clazz
- The class to check.method
- The method to check.public java.lang.String getClassSimpleName(java.lang.String className)
className
- Simple or fully qualified class name.public boolean returnsHandle(java.lang.Class clazz, java.lang.String method)
true
if the supplied method declares handle
as its return type.clazz
- The class to check.method
- The method to check.public java.lang.String getLegacyName(java.lang.Class<?> cls, java.lang.String methodName)
LegacyMethod
or LegacyAttribute
annotations.cls
- Class where to search for the supplied method.methodName
- The class method name.public java.lang.Object create(java.lang.String className, java.lang.Object[] args) throws java.lang.ClassNotFoundException, java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.reflect.InvocationTargetException
className
- Fully qualified name of the class to be instantiated.args
- Constructor arguments. Currently, null
arguments within this array are not supported.java.lang.ClassNotFoundException
- if a class named className
cannot be found.java.lang.NullPointerException
- if any argument in args
is null
.java.lang.NoSuchMethodException
- if the signature defined by args
matches no
constructor in the specified class.java.lang.IllegalAccessException
- if the Constructor
used enforces Java language
access control and the underlying constructor is
inaccessible.java.lang.IllegalArgumentException
- if the number of actual and formal parameters required by
the underlying constructor differ; if an unwrapping
conversion for primitive arguments fails; or if, after
possible unwrapping, a parameter value cannot be converted
to the corresponding formal parameter type by a method
invocation conversion; if more than one suitable matching
constructor was detected (indicating ambiguity).java.lang.InstantiationException
- if the class that declares the underlying constructor
represents an abstract class.java.lang.reflect.InvocationTargetException
- if the underlying constructor throws an exception.public java.lang.Object create(java.lang.Class<?> target, java.lang.Object[] args) throws java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.reflect.InvocationTargetException
target
- Class to be instantiated.args
- Constructor arguments. Currently, null
arguments within this array are not supported.java.lang.NullPointerException
- if any argument in args
is null
.java.lang.NoSuchMethodException
- if the signature defined by args
matches no
constructor in the specified class.java.lang.IllegalAccessException
- if the Constructor
used enforces Java language
access control and the underlying constructor is
inaccessible.java.lang.IllegalArgumentException
- if the number of actual and formal parameters required by
the underlying constructor differ; if an unwrapping
conversion for primitive arguments fails; or if, after
possible unwrapping, a parameter value cannot be converted
to the corresponding formal parameter type by a method
invocation conversion; if more than one suitable matching
constructor was detected (indicating ambiguity).java.lang.InstantiationException
- if the class that declares the underlying constructor
represents an abstract class.java.lang.reflect.InvocationTargetException
- if the underlying constructor throws an exception.public java.util.List<?> createList(java.lang.Object[] elements)
List
which contains the specified
elements as its members.elements
- Elements of the newly created list object.elements
.public java.util.List<?> splitToList(java.lang.String val, java.lang.String delim)
String
's, using the given delimiter.val
- The value to split.delim
- The delimiter.public java.util.List<?> createListFromObject(java.lang.Object array)
array
- An object that represents an array of objects.array
.public java.util.LinkedHashSet<?> createSet(java.lang.Object[] elements)
equals
method of the elements) are discarded. Iteration over the resulting
set is guaranteed to be in the same order as unique elements were
found in the elements
array.elements
- Array whose unique elements define the contents of the
newly created set.elements
.public <K,V> java.util.LinkedHashMap<K,V> createMap(java.util.Set<K> keys, java.util.List<V> values) throws java.lang.IllegalArgumentException
keys
and whose values are defined by values
. The map is
populated by iterating over keys
and associating the
value at the corresponding position in the values
list.
Thus, it is important that the iteration order of keys
is well-defined, and corresponds identically with that of
values
.keys
- Set which defines the keys of the new map.values
- List which defines the values of the new map.java.lang.IllegalArgumentException
- if the sizes of the specified data structures are not
equal.public java.util.UUID createUUID(long high, long low)
high
- The most significant bits of the UUIDlow
- The least significant bits of the UUIDpublic long getNow()
System.currentTimeMillis()
public Aast getThis()
public Aast getCopy()
public Aast getAnalog()
This is meant to enable ascent rules which change the copy tree at the current level, such that the copy map is no longer a reliable mechanism to retrieve the proper analog to the current source node.
null
if no such AST
exists.public Aast parseTree(java.lang.String filename)
filename
- Name of file in which AST is stored.java.lang.IllegalArgumentException
- if there is any error loading filename
.public Aast loadTree(java.lang.String filename)
filename
- Name of file in which AST is stored.java.lang.IllegalArgumentException
- if there is any error loading filename
.public void registerTree(Aast ast)
ast
- Tree to register.public Aast getAst(java.lang.Long id)
id
- The project-unique ID that specifies the AST.null
if the associated AST either
doesn't exist or is not loaded (and registered in the
resolver).public Aast getAst(java.lang.Long id, boolean loadTree)
id
- The project-unique ID that specifies the AST.loadTree
- if true
, the tree enclosing the AST with the given ID will be
loaded and registered with the current resolver. Use this option with
caution. ASTs can be large and this can consume a lot of memory.null
if the associated AST doesn't exist.public void removeAst(java.lang.Long id)
id
- The project-unique ID that specifies the AST.public boolean isAst(java.lang.String filename)
filename
- The filename to check. It does not need to have the AST extension.true
if there is an AST for the given file.public int getType()
Corresponds with runtime variable type
.
public boolean setType(long type)
true
.public java.lang.String getName()
Corresponds with runtime variable name
.
public Aast getParent()
Corresponds with runtime variable parent
.
null
if no source or parent.public java.lang.String getText()
Corresponds with runtime variable text
.
public boolean setText(java.lang.String text)
true
.public java.lang.Long getId()
Corresponds with runtime variable id
.
public java.lang.String getFile()
P2J_HOME
.
Corresponds with runtime variable file
.
public java.lang.String getPersistenceFilename()
Corresponds with runtime variable persistenceFilename
.
null
if the filename cannot
be obtained.public long getLine()
Corresponds with runtime variable line
.
public long getColumn()
Corresponds with runtime variable column
.
public long getDepth()
Corresponds with runtime variable depth
.
public java.lang.String getPath()
Aast.getPath()
.public java.lang.String getTreeDump()
public java.lang.String getAncestorTreeDump(long level)
level
- Number of generations up the tree to walk to obtain the
ancestor. Set to -1
to obtain the tree root,
0
is the current node, 1
is the
parent, 2
is the 'grandparent' and so forth.null
if no such node exists (if the
level
specified is greater than depth of the
tree).public boolean matches(java.lang.String text, java.lang.String regex)
text
matches the specified regular
expression.text
- String to test.regex
- Regular expression to apply against text
.true
for a match, else false
.public boolean matches(java.lang.String text, java.lang.String regex, boolean sensitive)
text
matches the specified regular
expression, taking the caller's case-sensitivity into account. If
the case-insensitive mode is chosen, both the input text and the
regular expression will be lowercased before match processing occurs.text
- String to test.regex
- Regular expression to apply against text
.sensitive
- true
if normal case-sensitivity should be
used, false
for case-insensitive matching.true
for a match, else false
.public java.lang.Boolean evalLib(java.lang.String name, java.lang.Object[] args)
evalLib
user function. Accepts
the name of a named expression and executes that expression. The
expression to which this function refers is assumed to return a
Boolean
result. This is a convenience form of
execLib
which eliminates the cast when used as a
condition.name
- Name of an expression to execute.args
- The array of Object
instances of the correct
data type and in the correct order to match our parameter
list. Each element of the array will be assigned into the
matching parameter in our parameter list before the
expression is executed.ExpressionException
- if any error occurs compiling the named expression before
its first use.public java.lang.Object execLib(java.lang.String name, java.lang.Object[] args)
execLib
user function. Accepts
the name of a named expression and executes that expression.name
- Name of an expression to execute.args
- The array of Object
instances of the correct
data type and in the correct order to match our parameter
list. Each element of the array will be assigned into the
matching parameter in our parameter list before the
expression is executed.ExpressionException
- if any error occurs compiling the named expression before
its first use.public java.lang.Boolean eval(java.lang.String expr)
eval
user function. Accepts the
an expression, then compiles (if necessary) and executes that
expression returning a Boolean
result. This is a
convenience form of exec
which eliminates the cast
when used as a condition.expr
- An expression to execute.ExpressionException
- if any error occurs compiling the expression before it's
first use.public java.lang.Object exec(java.lang.String expr)
exec
user function. Accepts the
an expression, then compiles (if necessary) and executes that
expression.expr
- An expression to execute.ExpressionException
- if any error occurs compiling the expression before it's
first use.public boolean root()
root
user function. Determines
whether the current AST is the root of the source tree.true
if AST has no parent, else
false
.public boolean leaf()
leaf
user function. Determines
whether the current AST is a leaf node of the source tree.true
if AST has no children, else
false
.public long getNumImmediateChildren()
numImmediateChildren
user
variable.public int getNextChildIndex()
nextChildIndex
user
variable which denotes which child is about to be processed when
processing a 'next-child' rule. Since child indices are 0-based,
the next child index will always be greater than 0 during the
processing of a 'next-child' rule, since the first time a
'next-child' rule is called, the previous child is 0 and the next
child is 1 (so the return from this function will be 1).public boolean imaginary()
imaginary
user function.
Determines whether the token underlying the current AST was created
artificially, or is based upon a source code element.true
if AST has a line:column position of 0:0,
else false
.public boolean absolutePath(java.lang.String path)
path
- Root-to-current path, formatted as described in
Aast.getPath()
.true
if specified path matches current source
AST's path exactly, else false
.public boolean relativePath(java.lang.String path)
The current source AST's type IS included in this path, which is
different from the upPath(java.lang.String)
which compares paths upward
from the parent node.
path
- Partial path from the current AST up to an arbitrary
number of parent nodes, formatted as described in
Aast.getPath()
.true
if specified path matches the end of the
current source AST's path exactly, else false
.public boolean upPath(java.lang.String path)
The type of the current node is NOT included in the up path. This
is the only difference with relativePath(java.lang.String)
.
path
- Partial path from the current AST's parent upward to an
arbitrary number of ancestor nodes, formatted as described
in Aast.getPath()
.true
if specified path exactly matches the
upward path from the current source AST's parent, else
false
.public boolean downPath(java.lang.String path)
true
. The format of the
'segments' of the down path starts with the immediate child's type
and each subsequent segment must be the type of the next child
down in the hierarchy. The type of the current node is NOT included
in the down path.path
- Partial path from the current AST down to an arbitrary
number of descendant nodes, formatted as described in
Aast.getPath()
.true
if specified path exactly matches the
downward path from the current source AST, else
false
.public boolean ancestor(long type, long maxLevels)
ancestor
user function. Indicates
whether a token type exists within the ancestry of the current source
AST.type
- Token type to be matched.maxLevels
- Maximum number of generations up the tree to search for an
ancestor. Set to -1
to search up to the tree
root, 0
for the current node, 1
for the parent, 2
for the 'grandparent' and so
forth.true
if token
was found as an
ancestor's token type within maxLevels
generations, else false
.public boolean descendant(long type, long maxLevels)
descendant
user function.
Searches the current source AST's descendants for a token type
match.type
- Token type to be matched.maxLevels
- Number of generations to search before abandoning the test.
Set to 0
to search exhaustively.true
if token
was found as an
descendant's token type within maxLevels
generations, else false
.public boolean childAt(long type, long index)
type
- Token type to be matched.index
- 0-based index of the child to test.true
if token
was found in a
specific child's token type, else false
if
no child exists at that index or if the child does not
match the token type.public boolean sibling(long type)
type
- Token type to match.true
if any of the current AST's siblings
match, else false
.public long getLeftSiblings()
Corresponds with runtime variable leftSiblings
.
public long getRightSiblings()
Corresponds with runtime variable rightSiblings
.
public long getChildIndex()
Corresponds with runtime variable childIndex
.
public boolean addToView()
true
public boolean addAllToView(java.util.List<Aast> list)
list
- The nodes to add to the view.true
public boolean addToView(java.lang.Long id)
true
if the AST is valid (and thus was added),
false
otherwise.public boolean addParentToView()
null
.true
public boolean addAncestorToView(long level)
null
.level
- Identifies the ancestor by the number of generations 'up'
the tree from the current node. 0 specifies the current
node, 1 specifies the parent node, 2 specifies the
'grandparent' node and so forth.true
public boolean addTreeToView(long maxLevels)
maxLevels
generations, to the filtered view of ASTs
which can be pipelined to the next ruleset.maxLevels
- Number of descendant generations to add. To add only the
current AST, specify 1
(or better yet, use
addToView()
).true
public boolean addPathToViewFrom(long type)
type
to the current
copy AST. The nodes are added in root to leaf order. If an
ancestor node of type type
does not exist, no nodes
are added (not even the current one).type
- Ancestor token type which marks the beginning of the path.true
if an ancestor of type type
was found and the path of nodes was successfully added to
the filtered view, else false
.public boolean printAst()
true
public boolean remove()
true
public java.lang.String charAt(java.lang.String text, int index)
text
- The source text.index
- The character's index.public java.lang.String upper(java.lang.String text)
text
- The string to uppercase.text
string in all upper case.public java.lang.String lower(java.lang.String text)
text
- The string to lowercase.text
string in all lower case.public java.lang.String string(long value)
value
- Number to convert.public java.lang.String string(double value)
value
- Number to convert.public java.lang.String string(boolean value)
value
- Number to convert.public java.lang.String substring(java.lang.String text, long index)
text
- The input string.index
- The character at which to start the substring.public java.lang.String substring(java.lang.String text, long begin, long end)
text
- The input string.begin
- The character at which to start the substring.end
- The character before which to end the substring.public long indexOf(java.lang.String text, java.lang.String find)
text
- The input string.find
- The string to search for.public long indexOf(java.lang.String text, java.lang.String find, long start)
text
- The input string.find
- The string to search for.start
- The starting index from which to search.public long lastIndexOf(java.lang.String text, java.lang.String find)
text
- The input string.find
- The string to search for.public long lastIndexOf(java.lang.String text, java.lang.String find, long start)
text
- The input string.find
- The string to search for.start
- The starting index from which to search backward.public long stringLength(java.lang.String text)
text
- The input string.public java.lang.String copies(java.lang.String text, int num)
num
times without intervening spaces.text
- The input string.num
- The number of times to repeat the input string in the
output string.public java.util.List wrapText(java.lang.String text, int width)
width
are not split, but will appear in
their own line. All lines are left-aligned within the alloted width.text
- Text to be split.width
- Per-line width in characters.text
split into
lines of the specified width.public java.lang.String removeQuotes(java.lang.String text)
text
- String optionally enclosed in quotes.text
, but with quotes
removed.public java.lang.String switchQuotes(java.lang.String text, java.lang.String prevQuoteChar, java.lang.String newQuoteChar)
This includes un-escaping and un-doubling the previous quote char and escaping the new quote char.
text
- The text to have its quotes switched.prevQuoteChar
- The previous quote.newQuoteChar
- The new quote.public java.lang.String trimLeading(java.lang.String text)
text
, without triggering
a NullPointerException
if text
is
null
.text
- Text string to be trimmed.text
with leading whitespace removed, or
null
if text
is null
.public java.lang.String trimTrailing(java.lang.String text)
text
, without triggering a
NullPointerException
if text
is null
.text
- Text string to be trimmed.text
with trailing whitespace removed, or null
if text
is null
.public java.lang.String trimTrailingSpaces(java.lang.String text)
text
, without triggering a
NullPointerException
if text
is null
.text
- Text string to be trimmed.text
with trailing whitespace removed, or null
if text
is null
.public java.lang.Long parseLong(java.lang.String text) throws java.lang.NumberFormatException
Long
from text
and return it.text
- String representing a base-10 long
value.text
as a Long
.java.lang.NumberFormatException
- if text
cannot be parsed into a long.public java.lang.Long parseLong(java.lang.String text, int radix) throws java.lang.NumberFormatException
Long
from text
using the given
radix, and return it.text
- String representing a long
value with the
specified radix.radix
- Radix to be used interpreting text
.text
as a Long
.java.lang.NumberFormatException
- if text
cannot be parsed into a long.public java.lang.Long parseLongQuiet(java.lang.String text)
Long
from text
and return it. Do
not raise an exception if text
cannot be parsed.text
- String representing a base-10 long
value.text
as a Long
, or
null
if text
cannot be parsed into
a Long
.public java.lang.Long parseLongQuiet(java.lang.String text, int radix)
Long
from text
using the given
radix, and return it. Do not raise an exception if text
cannot be parsed.text
- String representing a long
value with the
specified radix.radix
- Radix to be used interpreting text
.text
as a Long
, or
null
if text
cannot be parsed into
a Long
.public java.lang.Double parseDouble(java.lang.String text) throws java.lang.NumberFormatException
Double
from text
and return it.text
- String representing a double
value.text
as a Double
.java.lang.NumberFormatException
- if text
cannot be parsed into a double.public java.lang.Double parseDoubleQuiet(java.lang.String text)
Double
from text
and return it.
Do not raise an exception if text
cannot be parsed.text
- String representing a double
value.text
as a Double
or
null
if text
cannot be parsed.public java.math.BigDecimal parseBigDecimal(java.lang.String text)
BigDecimal
from text
and return it.text
- String representing a decimal value.text
as a BigDecimal
.java.lang.NumberFormatException
- if text
cannot be parsed into a decimal.public datetimetz now()
public date today()
public datetimetz parseDatetimetzLiteral(java.lang.String text)
text
- The datetimetz literal in ISO8601 format.public datetime parseDatetimeLiteral(java.lang.String text)
text
- The datetime literal in ISO8601 format.public java.math.BigDecimal toBigDecimal(java.lang.Double num)
double
value to a BigDecimal
.num
- A Double
instance to be converted.public boolean print(java.lang.String text)
text
- Text to be printed.public boolean println(java.lang.String text)
text
- Text to be printed.public boolean persist() throws ConfigurationException, AstException
true
.ConfigurationException
- if P2J_HOME
has not been defined for this
process.AstException
- if any error occurs persisting the AST.public boolean persist(java.lang.String filename, boolean projectRelative) throws ConfigurationException, AstException
filename
- The file to persist.projectRelative
- true
if the filename is relative to the
project home directory, false
if the filename
is absolute or relative to the current directory.true
.ConfigurationException
- if P2J_HOME
has not been defined for this
process.AstException
- if any error occurs persisting the AST.public boolean persist(java.lang.String filename, boolean projectRelative, boolean terse) throws ConfigurationException, AstException
filename
- The file to persist.projectRelative
- true
if the filename is relative to the
project home directory, false
if the filename
is absolute or relative to the current directory.terse
- true
to persist the AST in terse mode,
otherwise false
.true
.ConfigurationException
- if P2J_HOME
has not been defined for this
process.AstException
- if any error occurs persisting the AST.public boolean persist(Aast root, java.lang.String filename, boolean projectRelative, boolean terse) throws ConfigurationException, AstException
root
- The root AST.filename
- The file to persist.projectRelative
- true
if the filename is relative to the
project home directory, false
if the filename
is absolute or relative to the current directory.terse
- true
to persist the AST in terse mode,
otherwise false
.true
.ConfigurationException
- if P2J_HOME
has not been defined for this
process.AstException
- if any error occurs persisting the AST.public void addNewProgramFile(Aast root)
root
- The AST root.public void clearNewProgramFiles()
program file
names
.public boolean dumpStack()
stderr
.true
.public void compileError(int id, java.lang.String message, Aast ast) throws CompileException
CompileException
with a user-defined message. This will halt pattern
engine processing.
Data associated with the currently processing AST node will NOT be included in the formatted message.
Both id
and message
should match one of the Progress' set of compile
errors, so it would be properly recognized by the dynamic conversion module.
id
- The identifier of the error message.message
- Error message to include in the exception's text.ast
- The AST that caused the error.CompileException
- Always, with the provided information.public void compileError(int id, java.lang.String message) throws CompileException
CompileException
with a user-defined message. This will halt pattern
engine processing.
Data associated with the currently processing AST node will NOT be included in the formatted message.
Both id
and message
should match one of the Progress' set of compile
errors, so it would be properly recognized by the dynamic conversion module.
id
- The identifier of the error message.message
- Error message to include in the exception's text.CompileException
- Always, with the provided information.public void throwException(java.lang.String message) throws CommonAstSupport.UserGeneratedException
CommonAstSupport.UserGeneratedException
with a
user-defined message. This will halt pattern engine processing.
Data associated with the currently processing AST node will be included in the formatted message.
Use this method if the error you encounter is a P2J specific issue. If it is an error
detected in code, use the compileError(int, String)
instead, with the
parameters compatible to P4GL compiler error set.
message
- Error message to include in the exception's text.CommonAstSupport.UserGeneratedException
public void throwException(java.lang.String message, Aast ast) throws CommonAstSupport.UserGeneratedException
CommonAstSupport.UserGeneratedException
with a
user-defined message. This will halt pattern engine processing.message
- Error message.ast
- AST at which failure occurred.CommonAstSupport.UserGeneratedException
public java.lang.String sprintf(java.lang.String format, java.lang.Object[] args)
printf
syntax, and
an array of runtime replacement arguments, perform formatted variable
substitution and return the resulting string.format
- A format string using C-like sprintf
syntax
for its substitution placeholders.args
- An array of objects which must contain only the following
types:
args
substituted in for the appropriate,
respective placeholder variables.public boolean fprintf(java.lang.String filename, java.lang.String format, java.lang.Object[] args) throws ConfigurationException, java.lang.IllegalArgumentException, java.io.IOException
printf
syntax, and
an array of runtime replacement arguments, perform formatted variable
substitution and APPEND the resulting string to a named file. The
file will be opened and closed in this method, such that no state
is maintained between calls.filename
- The file to which the resulting string will be appended.
If the file doesn't exist it will be created. The filename
MUST be specified in a format that is relative to the
project root.format
- A format string using C-like sprintf
syntax
for its substitution placeholders.args
- An array of objects which must contain only the following
types:
true
.ConfigurationException
- if P2J_HOME
has not been defined for this
process.java.lang.IllegalArgumentException
- if a stream for the specified filename cannot be created.java.io.IOException
public java.lang.Long openStream(java.lang.String filename, boolean projectRelative) throws ConfigurationException, java.lang.IllegalArgumentException, java.io.IOException
filename
- The name of the file to be opened.projectRelative
- true
if the filename is relative to the
project home directory, false
if the filename
is absolute or relative to the current directory.ConfigurationException
- if P2J_HOME
has not been defined for this
process.java.lang.IllegalArgumentException
- if a stream for the specified filename cannot be created.java.io.IOException
public boolean closeStream(java.lang.Long id) throws java.io.IOException
id
- The ID of a stream which muct have previously been opened.true
.java.io.IOException
public long getNumBytesWritten(java.lang.Long id)
id
- The ID of a stream which muct have previously been opened.public boolean fprintf(java.lang.Long id, java.lang.String format, java.lang.Object[] args) throws java.lang.IllegalArgumentException, java.io.IOException
printf
syntax, and
an array of runtime replacement arguments, perform formatted variable
substitution and APPEND the resulting string to previously opened
stream identified by a numeric ID. This is a stateful version of
the fprintf(String,String,Object[])
. Use the methods
openStream(java.lang.String, boolean)
and closeStream(java.lang.Long)
to open and close the
stream.
The output from this method will be UTF-8 encoded.
id
- The ID of a stream which muct have previously been opened.format
- A format string using C-like sprintf
syntax
for its substitution placeholders.args
- An array of objects which must contain only the following
types:
true
.java.lang.IllegalArgumentException
- if the specified stream does not exist.java.io.IOException
public boolean printf(java.lang.String format, java.lang.Object[] args)
sprintf(java.lang.String, java.lang.Object[])
to stdout
with no trailing line break.format
- A format string using C-like sprintf
syntax
for its substitution placeholders.args
- An array of objects which must contain only the following
types:
true
.public boolean breakpoint(java.lang.String location, boolean suspend, java.lang.Object... args)
Object
s in ERR
console with a (usually short) description.
Optionally, the processing can be suspended if a debugger is attached to process and
inspect the logged entities. The advantage of this method is the direct access to
objects passed in as parameters, instead of looking them up in the TRPL runtime
structures and over the printf(java.lang.String, java.lang.Object[])
is the lack of formatting parameter (the
Object.toString()
) used here is powerful enough to display lists, integer and
boolean values usually encountered in TRPL code. It also can display any datatypes
instead of only 3 supported by printf
.
Notes:
location
- A short message that will displayed in front of the list of other objects.suspend
- Activate a special breakpoint location after the values were logged. If this is
false
or no breakpoint was set in debugger, this method behaves like
printfln
to err console that displays the values in a column.args
- The list of entities to be displayed. Depending on their type, the output for
each one is different, the emphasis being put on Aast
objects. The items
in this list will be TAB-indented.true
.public boolean printfln(java.lang.String format, java.lang.Object[] args)
sprintf(java.lang.String, java.lang.Object[])
to stdout
with a trailing line break.format
- A format string using C-like sprintf
syntax
for its substitution placeholders.args
- An array of objects which must contain only the following
types:
true
.public Aast getAncestorOfType(java.lang.Object[] types)
types
- Token types to match. May not be null
or
empty.null
if no such node was found.public Aast getAncestor(java.lang.String key, java.lang.Object value, java.lang.Object[] types)
key
- Annotation key for which to search; may not be
null
.value
- Optional annotation value to match. If null
,
a match on the annotation key (and optionally on token
type) is sufficient to constitute success.types
- Optional array of Integer
values representing
valid token types. If empty, token type is not considered
as a match criterion.null
if no match was found.java.lang.ClassCastException
- if types
contains any object type other than
Integer
.public Aast getAncestor(java.lang.Integer index, java.lang.String key, java.lang.Object value, java.lang.Object[] types)
index
- Index of annotation to compare when a node is found with
the specfied annotation key
. Only valid for
list type annotations; must be null
for
simple annotations.key
- Annotation key for which to search; may not be
null
.value
- Optional annotation value to match. If null
,
a match on the annotation key (and optionally on token
type) is sufficient to constitute success.types
- Optional array of Integer
values representing
valid token types. If empty, token type is not considered
as a match criterion.null
if no match was found.java.lang.ClassCastException
- if types
contains any object type other than
Integer
.public boolean isNote(java.lang.String key)
String
,
Double
, Long
, or Boolean
value, indexed by an arbitrary key.key
- Key under which the annotation is stored.true
if an annotation exists mapped by that
key.public java.lang.String getNoteType(java.lang.String key)
java.lang.String
.key
- Key under which the annotation is stored.null
if the
annotation doesn't exist.public long getNoteSize(java.lang.String key)
key
- Key under which the annotation is stored.public java.lang.String getNoteString(java.lang.String key)
String
annotation from the current,
copy AST.key
- Case-insensitive annotation key.null
if it
does not exist in the current, copy AST.public java.lang.String getNoteString(java.lang.String key, long index)
String
annotation at a specific index from an
array annotation in the current copy AST.key
- Case-insensitive annotation key.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
find the annotation.null
if the annotation
doesn't exist, if the annotation is not an array or if no
element exists at the given index.public java.lang.Long getNoteLong(java.lang.String key)
Long
annotation from the current,
copy AST.key
- Case-insensitive annotation key.null
if it
does not exist in the current, copy AST.public java.lang.Long getNoteLong(java.lang.String key, long index)
Long
annotation at a specific index from an
array annotation in the current copy AST.key
- Case-insensitive annotation key.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
find the annotation.null
if the annotation
doesn't exist, if the annotation is not an array or if no
element exists at the given index.public java.lang.Double getNoteDouble(java.lang.String key)
Double
annotation from the current,
copy AST.key
- Case-insensitive annotation key.null
if it
does not exist in the current, copy AST.public java.lang.Double getNoteDouble(java.lang.String key, long index)
Double
annotation at a specific index from an
array annotation in the current copy AST.key
- Case-insensitive annotation key.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
find the annotation.null
if the annotation
doesn't exist, if the annotation is not an array or if no
element exists at the given index.public java.lang.Boolean getNoteBoolean(java.lang.String key)
Boolean
annotation from the current,
copy AST.key
- Case-insensitive annotation key.null
if it
does not exist in the current, copy AST.public java.lang.Boolean getNoteBoolean(java.lang.String key, long index)
Boolean
annotation at a specific index from an
array annotation in the current copy AST.key
- Case-insensitive annotation key.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
find the annotation.null
if the annotation
doesn't exist, if the annotation is not an array or if no
element exists at the given index.public java.lang.String getAncestorNoteString(long level, java.lang.String key)
String
annotation from the specified ancestor
in the copy AST.level
- Number of generations up the tree to walk to obtain the
ancestor. Set to -1
to obtain the tree root,
0
is the current node, 1
is the
parent, 2
is the 'grandparent' and so forth.key
- Case-insensitive annotation key.null
if
either the annotation or the specified ancestor does not
exist.public java.lang.String getAncestorNoteString(long level, java.lang.String key, long index)
String
annotation at a specific index from an
array annotation in the specified ancestor of the current
copy AST.level
- Number of generations up the tree to walk to obtain the
ancestor. Set to -1
to obtain the tree root,
0
is the current node, 1
is the
parent, 2
is the 'grandparent' and so forth.key
- Case-insensitive annotation key.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
find the annotation.null
if the annotation
doesn't exist, if the annotation is not an array or if no
element exists at the given index.public java.lang.Long getAncestorNoteLong(long level, java.lang.String key)
Long
annotation from the specified ancestor
in the copy AST.level
- Number of generations up the tree to walk to obtain the
ancestor. Set to -1
to obtain the tree root,
0
is the current node, 1
is the
parent, 2
is the 'grandparent' and so forth.key
- Case-insensitive annotation key.null
if
either the annotation or the specified ancestor does not
exist.public java.lang.Long getAncestorNoteLong(long level, java.lang.String key, long index)
Long
annotation at a specific index from an
array annotation in the specified ancestor of the current
copy AST.level
- Number of generations up the tree to walk to obtain the
ancestor. Set to -1
to obtain the tree root,
0
is the current node, 1
is the
parent, 2
is the 'grandparent' and so forth.key
- Case-insensitive annotation key.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
find the annotation.null
if the annotation
doesn't exist, if the annotation is not an array or if no
element exists at the given index.public java.lang.Double getAncestorNoteDouble(long level, java.lang.String key)
Double
annotation from the specified ancestor
in the copy AST.level
- Number of generations up the tree to walk to obtain the
ancestor. Set to -1
to obtain the tree root,
0
is the current node, 1
is the
parent, 2
is the 'grandparent' and so forth.key
- Case-insensitive annotation key.null
if
either the annotation or the specified ancestor does not
exist.public java.lang.Double getAncestorNoteDouble(long level, java.lang.String key, long index)
Double
annotation at a specific index from an
array annotation in the specified ancestor of the current
copy AST.level
- Number of generations up the tree to walk to obtain the
ancestor. Set to -1
to obtain the tree root,
0
is the current node, 1
is the
parent, 2
is the 'grandparent' and so forth.key
- Case-insensitive annotation key.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
find the annotation.null
if the annotation
doesn't exist, if the annotation is not an array or if no
element exists at the given index.public java.lang.Boolean getAncestorNoteBoolean(long level, java.lang.String key)
Boolean
annotation from the specified ancestor
in the copy AST.level
- Number of generations up the tree to walk to obtain the
ancestor. Set to -1
to obtain the tree root,
0
is the current node, 1
is the
parent, 2
is the 'grandparent' and so forth.key
- Case-insensitive annotation key.null
if
either the annotation or the specified ancestor does not
exist.public java.lang.Boolean getAncestorNoteBoolean(long level, java.lang.String key, java.lang.Boolean defaultValue)
Boolean
annotation from the specified ancestor
in the copy AST.level
- Number of generations up the tree to walk to obtain the
ancestor. Set to -1
to obtain the tree root,
0
is the current node, 1
is the
parent, 2
is the 'grandparent' and so forth.key
- Case-insensitive annotation key.defaultValue
- When the annotation is not found, this is the value returned from the method.null
if
either the annotation or the specified ancestor does not
exist.public java.lang.Boolean getAncestorNoteBoolean(long level, java.lang.String key, long index)
Boolean
annotation at a specific index from an
array annotation in the specified ancestor of the current
copy AST.level
- Number of generations up the tree to walk to obtain the
ancestor. Set to -1
to obtain the tree root,
0
is the current node, 1
is the
parent, 2
is the 'grandparent' and so forth.key
- Case-insensitive annotation key.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
find the annotation.null
if the annotation
doesn't exist, if the annotation is not an array or if no
element exists at the given index.public java.lang.String getReferenceNoteString(long id, java.lang.String key)
String
annotation from the referenced node
in the copy AST.id
- The unique ID that references a specific node in the tree.key
- Case-insensitive annotation key.null
if
either the annotation or the referenced node does not
exist.public java.lang.String getReferenceNoteString(long id, java.lang.String key, long index)
String
annotation at a specific index from an
array annotation in the referenced node of the current
copy AST.id
- The unique ID that references a specific node in the tree.key
- Case-insensitive annotation key.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
find the annotation.null
if the annotation
doesn't exist, if the annotation is not an array, if no
element exists at the given index or the referenced node
does not exist.public java.lang.Long getReferenceNoteLong(long id, java.lang.String key)
Long
annotation from the referenced node
in the copy AST.id
- The unique ID that references a specific node in the tree.key
- Case-insensitive annotation key.null
if
either the annotation or the referenced node does not
exist.public java.lang.Long getReferenceNoteLong(long id, java.lang.String key, long index)
Long
annotation at a specific index from an
array annotation in the referenced node of the current
copy AST.id
- The unique ID that references a specific node in the tree.key
- Case-insensitive annotation key.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
find the annotation.null
if the annotation
doesn't exist, if the annotation is not an array, if no
element exists at the given index or the referenced node
does not exist.public java.lang.Double getReferenceNoteDouble(long id, java.lang.String key)
Double
annotation from the referenced node
in the copy AST.id
- The unique ID that references a specific node in the tree.key
- Case-insensitive annotation key.null
if
either the annotation or the referenced node does not
exist.public java.lang.Double getReferenceNoteDouble(long id, java.lang.String key, long index)
Double
annotation at a specific index from an
array annotation in the referenced node of the current
copy AST.id
- The unique ID that references a specific node in the tree.key
- Case-insensitive annotation key.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
find the annotation.null
if the annotation
doesn't exist, if the annotation is not an array, if no
element exists at the given index or the referenced node
does not exist.public java.lang.Boolean getReferenceNoteBoolean(long id, java.lang.String key)
Boolean
annotation from the referenced node
in the copy AST.id
- The unique ID that references a specific node in the tree.key
- Case-insensitive annotation key.null
if
either the annotation or the referenced node does not
exist.public java.lang.Boolean getReferenceNoteBoolean(long id, java.lang.String key, long index)
Boolean
annotation at a specific index from an
array annotation in the referenced node of the current
copy AST.id
- The unique ID that references a specific node in the tree.key
- Case-insensitive annotation key.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
find the annotation.null
if the annotation
doesn't exist, if the annotation is not an array, if no
element exists at the given index or the referenced node
does not exist.public boolean putNote(java.lang.String key, java.lang.String value)
String
in the current
copy AST. If an annotation exists with the identical key,
it is replaced.key
- Case-insensitive annotation key.value
- Annotation data.public boolean putNote(java.lang.String key, java.lang.String value, long index)
String
at the specified
index in an array annotation in the current copy AST.key
- Case-insensitive annotation key.value
- Annotation data.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
place the annotation.public boolean putNote(java.lang.String key, java.lang.Long value)
Long
in the current
copy AST. If an annotation exists with the identical key,
it is replaced.key
- Case-insensitive annotation key.value
- Annotation data.public boolean putNote(java.lang.String key, java.lang.Long value, long index)
Long
at the specified
index in an array annotation in the current copy AST.key
- Case-insensitive annotation key.value
- Annotation data.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
place the annotation.public boolean putNote(java.lang.String key, java.lang.Double value)
Double
in the current
copy AST. If an annotation exists with the identical key,
it is replaced.key
- Case-insensitive annotation key.value
- Annotation data.public boolean putNote(java.lang.String key, java.lang.Double value, long index)
Double
at the specified
index in an array annotation in the current copy AST.key
- Case-insensitive annotation key.value
- Annotation data.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
place the annotation.public boolean putNote(java.lang.String key, java.lang.Boolean value)
Boolean
in the current
copy AST. If an annotation exists with the identical key,
it is replaced.key
- Case-insensitive annotation key.value
- Annotation data.public boolean putNote(java.lang.String key, java.lang.Boolean value, long index)
Boolean
at the specified
index in an array annotation in the current copy AST.key
- Case-insensitive annotation key.value
- Annotation data.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
place the annotation.public boolean removeNote(java.lang.String key)
key
- Case-insensitive annotation key.true
if an entry for key
was
found and removed; false
if none was found.public boolean removeNote(java.lang.String key, long index)
key
- Case-insensitive annotation key.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
remove the annotation.true
if an entry for key
was
found and removed; false
if none was found,
if the annotation is not an array or if no element exists
at the given index.public boolean putAncestorNote(long level, java.lang.String key, java.lang.String value)
String
in the specified
ancestor in the copy AST. If an annotation exists with
the identical key, it is replaced.level
- Number of generations up the tree to walk to obtain the
ancestor. Set to -1
to obtain the tree root,
0
is the current node, 1
is the
parent, 2
is the 'grandparent' and so forth.key
- Case-insensitive annotation key.value
- Annotation data.true
if the annotation was added,
false
if no such ancestor was found.public boolean putAncestorNote(long level, java.lang.String key, java.lang.String value, long index)
String
at the specified index in the specified ancestor in the copy
AST. The special index of -1 indicates the add as the last element
of the array.level
- Number of generations up the tree to walk to obtain the
ancestor. Set to -1
to obtain the tree root,
0
is the current node, 1
is the
parent, 2
is the 'grandparent' and so forth.key
- Case-insensitive annotation key.value
- Annotation data.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
insert the annotation.true
if the annotation was added,
false
if no such ancestor was found.public boolean putAncestorNote(long level, java.lang.String key, java.lang.Long value)
Long
in the specified
ancestor in the copy AST. If an annotation exists with
the identical key, it is replaced.level
- Number of generations up the tree to walk to obtain the
ancestor. Set to -1
to obtain the tree root,
0
is the current node, 1
is the
parent, 2
is the 'grandparent' and so forth.key
- Case-insensitive annotation key.value
- Annotation data.true
if the annotation was added,
false
if no such ancestor was found.public boolean putAncestorNote(long level, java.lang.String key, java.lang.Long value, long index)
Long
at the specified index in the specified ancestor in the copy
AST. The special index of -1 indicates the add as the last element
of the array.level
- Number of generations up the tree to walk to obtain the
ancestor. Set to -1
to obtain the tree root,
0
is the current node, 1
is the
parent, 2
is the 'grandparent' and so forth.key
- Case-insensitive annotation key.value
- Annotation data.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
insert the annotation.true
if the annotation was added,
false
if no such ancestor was found.public boolean putAncestorNote(long level, java.lang.String key, java.lang.Double value)
Double
in the specified
ancestor in the copy AST. If an annotation exists with
the identical key, it is replaced.level
- Number of generations up the tree to walk to obtain the
ancestor. Set to -1
to obtain the tree root,
0
is the current node, 1
is the
parent, 2
is the 'grandparent' and so forth.key
- Case-insensitive annotation key.value
- Annotation data.true
if the annotation was added,
false
if no such ancestor was found.public boolean putAncestorNote(long level, java.lang.String key, java.lang.Double value, long index)
Double
at the specified index in the specified ancestor in the copy
AST. The special index of -1 indicates the add as the last element
of the array.level
- Number of generations up the tree to walk to obtain the
ancestor. Set to -1
to obtain the tree root,
0
is the current node, 1
is the
parent, 2
is the 'grandparent' and so forth.key
- Case-insensitive annotation key.value
- Annotation data.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
insert the annotation.true
if the annotation was added,
false
if no such ancestor was found.public boolean putAncestorNote(long level, java.lang.String key, java.lang.Boolean value)
Boolean
in the specified
ancestor in the copy AST. If an annotation exists with
the identical key, it is replaced.level
- Number of generations up the tree to walk to obtain the
ancestor. Set to -1
to obtain the tree root,
0
is the current node, 1
is the
parent, 2
is the 'grandparent' and so forth.key
- Case-insensitive annotation key.value
- Annotation data.true
if the annotation was added,
false
if no such ancestor was found.public boolean putAncestorNote(long level, java.lang.String key, java.lang.Boolean value, long index)
Boolean
at the specified index in the specified ancestor in the copy
AST. The special index of -1 indicates the add as the last element
of the array.level
- Number of generations up the tree to walk to obtain the
ancestor. Set to -1
to obtain the tree root,
0
is the current node, 1
is the
parent, 2
is the 'grandparent' and so forth.key
- Case-insensitive annotation key.value
- Annotation data.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
insert the annotation.true
if the annotation was added,
false
if no such ancestor was found.public boolean removeAncestorNote(long level, java.lang.String key)
level
- Number of generations up the tree to walk to obtain the
ancestor. Set to -1
to obtain the tree root,
0
is the current node, 1
is the
parent, 2
is the 'grandparent' and so forth.key
- Case-insensitive annotation key.true
if an entry for key
was
found and removed; false
if no such annotation
or no such ancestor was found.public boolean removeAncestorNote(long level, java.lang.String key, long index)
level
- Number of generations up the tree to walk to obtain the
ancestor. Set to -1
to obtain the tree root,
0
is the current node, 1
is the
parent, 2
is the 'grandparent' and so forth.key
- Case-insensitive annotation key.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
remove the annotation.true
if an entry for key
was
found and removed; false
if none was found,
if the annotation is not an array or if no element exists
at the given index or if the specified ancestor does not
exist.public boolean putReferenceNote(long id, java.lang.String key, java.lang.String value)
String
in the referenced
node in the copy AST. If an annotation exists with
the identical key, it is replaced.id
- The unique ID that references a specific node in the tree.key
- Case-insensitive annotation key.value
- Annotation data.true
if the annotation was added,
false
if no such node was found.public boolean putReferenceNote(long id, java.lang.String key, java.lang.String value, long index)
String
at the specified index in the referenced node in the copy
AST. The special index of -1 indicates the add as the last element
of the array.id
- The unique ID that references a specific node in the tree.key
- Case-insensitive annotation key.value
- Annotation data.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
insert the annotation.true
if the annotation was added,
false
if no such node was found.public boolean putReferenceNote(long id, java.lang.String key, java.lang.Long value)
Long
in the referenced
node in the copy AST. If an annotation exists with
the identical key, it is replaced.id
- The unique ID that references a specific node in the tree.key
- Case-insensitive annotation key.value
- Annotation data.true
if the annotation was added,
false
if no such node was found.public boolean putReferenceNote(long id, java.lang.String key, java.lang.Long value, long index)
Long
at the specified index in the referenced node in the copy
AST. The special index of -1 indicates the add as the last element
of the array.id
- The unique ID that references a specific node in the tree.key
- Case-insensitive annotation key.value
- Annotation data.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
insert the annotation.true
if the annotation was added,
false
if no such node was found.public boolean putReferenceNote(long id, java.lang.String key, java.lang.Double value)
Double
in the referenced
node in the copy AST. If an annotation exists with
the identical key, it is replaced.id
- The unique ID that references a specific node in the tree.key
- Case-insensitive annotation key.value
- Annotation data.true
if the annotation was added,
false
if no such node was found.public boolean putReferenceNote(long id, java.lang.String key, java.lang.Double value, long index)
Double
at the specified index in the referenced node in the copy
AST. The special index of -1 indicates the add as the last element
of the array.id
- The unique ID that references a specific node in the tree.key
- Case-insensitive annotation key.value
- Annotation data.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
insert the annotation.true
if the annotation was added,
false
if no such node was found.public boolean putReferenceNote(long id, java.lang.String key, java.lang.Boolean value)
Boolean
in the referenced
node in the copy AST. If an annotation exists with
the identical key, it is replaced.id
- The unique ID that references a specific node in the tree.key
- Case-insensitive annotation key.value
- Annotation data.true
if the annotation was added,
false
if no such node was found.public boolean putReferenceNote(long id, java.lang.String key, java.lang.Boolean value, long index)
Boolean
at the specified index in the referenced node in the copy
AST. The special index of -1 indicates the add as the last element
of the array.id
- The unique ID that references a specific node in the tree.key
- Case-insensitive annotation key.value
- Annotation data.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
insert the annotation.true
if the annotation was added,
false
if no such node was found.public boolean removeReferenceNote(long id, java.lang.String key)
id
- The unique ID that references a specific node in the tree.key
- Case-insensitive annotation key.true
if an entry for key
was
found and removed; false
if no such annotation
or no such node was found.public boolean removeReferenceNote(long id, java.lang.String key, long index)
id
- The unique ID that references a specific node in the tree.key
- Case-insensitive annotation key.index
- The index of -1 indicates the last element of the array.
Otherwise this is the explicit zero-based index at which to
remove the annotation.true
if an entry for key
was
found and removed; false
if none was found,
if the annotation is not an array or if no element exists
at the given index or if the referenced node does not
exist.public java.lang.String getConfigParameter(java.lang.String id)
id
- Configuration variable ID.public void saveClasses()
public java.lang.String getConfigParameter(java.lang.String id, java.lang.String def)
id
- Configuration variable ID.def
- Default value for the variable.public java.lang.Boolean getConfigParameter(java.lang.String id, boolean def)
id
- Configuration variable ID.def
- Default value for the variable.public boolean isRuntimeConfig()
Configuration
is in conversion mode (configuration is read
from the configuration directory) or server run time mode.true
if it is a server run time mode (when configuration is NOT read
from the configuration directory).public boolean isDenormalizeDynamicTempTables()
true
if the extent properties in dynamic temp-tables should be denormalized.public boolean isFlagActivated(java.lang.String flag)
flag
- The flag to check.PatternEngine.isFlagActivated(String)
public boolean isConditionalRuleSets()
PatternEngine.isConditionalRuleSets()
public boolean isRuntimeQueryMode()
private boolean matchTokenType(Aast node, java.lang.Object[] types)
node
- An AST.types
- Array of Integer
s representing valid token
types. May be empty, must not be null
.true
if a match is detected, else
false
.java.lang.ClassCastException
- if types
contains any object type other than
Integer
.public java.lang.String fixupRegex(java.lang.String text)
text
- Regular expression string to be adjusted acccording to
OS special requirements.public java.lang.String fixupFileName(java.lang.String text)
text
- The string representing the filename with path separator.public java.lang.String quoteReplacement(java.lang.String text)
text
- String to replace special characters. An examples: \ or $.public void storeObject(java.lang.String id, java.lang.Object object)
PatternEngine.getStoredObject(String)
.id
- Arbitrary object id.object
- Object to store.public void storeObject(java.lang.String category, java.lang.String id, java.lang.Object object)
PatternEngine.getStoredObject(String, String)
.category
- Arbitrary object category.id
- Arbitrary object id.object
- Object to store.public java.lang.Object getStoredObject(java.lang.String id)
id
- Object's identifier.null
if none.public java.lang.Object getStoredObject(java.lang.String category, java.lang.String id)
id
- Object's identifier.null
if none.public java.lang.Long openStoredStream(java.lang.String name)
PatternEngine.getStoredObject(String)
).
Note that ByteArrayOutputStream
is stored under the given name, then this stream
is wrapped with ByteCountOutputStream
and the ID of ByteCountOutputStream
is returned for using in rules pipeline.name
- Unique name of this stream under which it will be stored. Doesn't match returned
ID.public boolean compareNodes(Aast node1, Aast node2)
This feature was introduced because of the lack of support for recursive call in TRPL. At this moment only the type/text of the nodes and their subnodes are checked. Depending on necessities, the compare operation may be extended to annotations, too.
public void withServicesFile(java.lang.String filename)
filename
- The file name.public java.util.Map<?,?> createString2IntMap(java.lang.String name)
String
key and an Integer
value.
For runtime conversion, a simple HashMap
will be returned.
ConversionData.createMap(java.lang.Class<?>, java.lang.Class<?>, java.lang.String)
public java.util.Map<?,?> createString2LongMap(java.lang.String name)
String
key and a Long
value.
For runtime conversion, a simple HashMap
will be returned.
ConversionData.createMap(java.lang.Class<?>, java.lang.Class<?>, java.lang.String)
public java.util.Map<?,?> createString2StringMap(java.lang.String name)
String
key and a String
value.
For runtime conversion, a simple HashMap
will be returned.
ConversionData.createMap(java.lang.Class<?>, java.lang.Class<?>, java.lang.String)
public java.util.Set<?> createStringSet(java.lang.String name)
String
key.
For runtime conversion, a simple TreeSet
will be returned.
ConversionData.createSet(java.lang.Class<?>, java.lang.String)
public java.util.Map<?,?> createStringMapToStringMap(java.lang.String name)
String
key and as values another map, having
String
for both key and value.
For runtime conversion, a simple HashMap
will be returned.
ConversionData.createMapToMap(java.lang.Class<?>, java.lang.Class<?>, java.lang.Class<?>, java.lang.String)
public java.util.Map<?,?> createStringMapToStringSet(java.lang.String name)
String
key and as values another set, having
String
for key.
For runtime conversion, a simple HashMap
will be returned.
ConversionData.createMapToSet(java.lang.Class<?>, java.lang.Class<?>, java.lang.String)
public java.util.Map<?,?> createStringMapToLongSet(java.lang.String name)
String
key and as values another set, having
Long
for key.
For runtime conversion, a simple HashMap
will be returned.
ConversionData.createMapToSet(java.lang.Class<?>, java.lang.Class<?>, java.lang.String)
public java.util.Map<?,?> createMapAstKeyToString(java.lang.String name)
AstKey
key and String
values.
For runtime conversion, a simple HashMap
will be returned.
ConversionData.createMap(java.lang.Class<?>, java.lang.Class<?>, java.lang.String)
public java.util.Map<?,?> createMapAstKeyToInt(java.lang.String name)
AstKey
key and Integer
values.
For runtime conversion, a simple HashMap
will be returned.
ConversionData.createMap(java.lang.Class<?>, java.lang.Class<?>, java.lang.String)
public java.util.Map<?,?> createMapFrameAstKeyToString(java.lang.String name)
FrameAstKey
key and String
values.
For runtime conversion, a simple HashMap
will be returned.
ConversionData.createMap(java.lang.Class<?>, java.lang.Class<?>, java.lang.String)
public java.util.Map<?,?> createMapAstKeyToAst(java.lang.String name)
AstKey
key and Aast
values.
For runtime conversion, a simple HashMap
will be returned.
ConversionData.createMap(java.lang.Class<?>, java.lang.Class<?>, java.lang.String)
public void setConvertedClassName(java.lang.String filename, java.lang.String legacyName, java.lang.String pkgname, java.lang.String classname)
filename
- The associated file name.legacyName
- The legacy fully qualified name.pkgname
- The converted package name.classname
- The simple Java class name.public void forceMapValue(java.util.Map<?,?> map, java.lang.Object key, java.lang.Object value)
map
- The db-backed map.key
- The key for which the value needs to be logged.value
- The value which needs to be logged.public int nextSequenceValue(java.lang.String name)
For runtime, it will use the sequences
map to store them.
name
- The sequence name.public java.util.Set<java.lang.String> getAllClassesInPackage(java.lang.String pkg)
pkg
- The package name.public java.lang.String getConvertedSimpleClassName(java.lang.String qname)
qname
- The qualified class name.null
if it was not found.