public class RulesTracing
extends java.lang.Object
When tracing is active all Rule
instances originating from rules xml files are created
with additional tracing information - the rules file and line number each rule is defined on.
Also all AnnotatedAst
nodes created as the result of processing of the individual
rules are annotated with the positional information.
To turn tracing ON the Java property "rules.tracing" must be defined (for example with the -D param on the command line when the Java process is started).
Modifier and Type | Class and Description |
---|---|
static class |
RulesTracing.Location
Holds the positional information.
|
Modifier and Type | Field and Description |
---|---|
private static java.lang.ThreadLocal<java.lang.Boolean> |
annotating
Flag preventing infinite recursion.
|
private static java.lang.String |
ANNOTATION_SUFFIX
Annotation key suffix.
|
static boolean |
isOn
Flag to indicate whether tracing is ON.
|
private static java.lang.ThreadLocal<java.util.Stack<RulesTracing.Location>> |
locationStack
The stack of rule processing locations.
|
Constructor and Description |
---|
RulesTracing() |
Modifier and Type | Method and Description |
---|---|
private static java.lang.String |
formatLocation(RulesTracing.Location loc)
Returns the formatted string of the passed in location.
|
static RulesTracing.Location |
peekLocation()
Peeks the positional information currently on the top of the stack.
|
static RulesTracing.Location |
popLocation()
Pops positional information from the stack.
|
static void |
pushLocation(java.lang.String file,
int line)
Pushes positional information on the stack.
|
static void |
putCreateLocation(AnnotatedAst ast)
Annotates the passed in node instance with positional information currently on the top of
the stack.
|
static void |
putCreateLocation(AnnotatedAst ast,
java.lang.String annotationName)
Annotates the passed in node instance with positional information currently on the top of
the stack.
|
static void |
removeCreateLocation(AnnotatedAst ast,
java.lang.String annotationName)
Remover the tracing annotation from the passed in node instance.
|
public static final boolean isOn
private static java.lang.ThreadLocal<java.util.Stack<RulesTracing.Location>> locationStack
private static java.lang.ThreadLocal<java.lang.Boolean> annotating
private static final java.lang.String ANNOTATION_SUFFIX
public static void pushLocation(java.lang.String file, int line)
file
- File name.line
- Line number.public static RulesTracing.Location popLocation()
public static RulesTracing.Location peekLocation()
public static void putCreateLocation(AnnotatedAst ast)
ast
- A valid syntax tree node instance to annotate.public static void putCreateLocation(AnnotatedAst ast, java.lang.String annotationName)
ast
- A valid syntax tree node instance to annotate.annotationName
- A valid annotation name.public static void removeCreateLocation(AnnotatedAst ast, java.lang.String annotationName)
ast
- A valid syntax tree node instance to annotate.annotationName
- A valid annotation name.private static java.lang.String formatLocation(RulesTracing.Location loc)
loc
- A valid location.