|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.antlr.runtime.tree.BaseTree
org.antlr.runtime.tree.CommonTree
net.sourceforge.nrl.parser.ast.impl.Antlr3NRLBaseAst
net.sourceforge.nrl.parser.ast.constraints.impl.ConstraintImpl
net.sourceforge.nrl.parser.ast.constraints.impl.ModelReferenceImpl
public class ModelReferenceImpl
Implementation of a model reference. When initialised during parsing, this class contains only a
broken up list of strings representing the steps through the model. This list can be obtained
using getStepsAsStrings().
A model resolver needs to be used to set the actual model references in the initial step, and the
remaining steps. In the ANTLR implementation, the
AntlrModelResolver class performs this task.
| Field Summary | |
|---|---|
static char |
KEYWORD_ESCAPE_CHARACTER
The character that may appear at the start of steps to escape an NRL keyword. |
| Fields inherited from class org.antlr.runtime.tree.CommonTree |
|---|
childIndex, parent, startIndex, stopIndex, token |
| Fields inherited from class org.antlr.runtime.tree.BaseTree |
|---|
children |
| Fields inherited from interface net.sourceforge.nrl.parser.ast.IModelReference |
|---|
REFERENCE_ELEMENT, REFERENCE_GLOBAL_VARIABLE, REFERENCE_RELATIVE_ATTRIBUTE, REFERENCE_STATIC_ATTRIBUTE, REFERENCE_TOP_CONTEXT_RELATIVE_ATTRIBUTE, REFERENCE_VARIABLE_RELATIVE_ATTRIBUTE, SEPARATOR, STEP_ATTRIBUTE, STEP_MODEL_ELEMENT, STEP_VARIABLE |
| Fields inherited from interface net.sourceforge.nrl.parser.ast.INRLAstNode |
|---|
NEWLINE |
| Fields inherited from interface org.antlr.runtime.tree.Tree |
|---|
INVALID_NODE |
| Constructor Summary | |
|---|---|
ModelReferenceImpl(ModelReferenceImpl other)
Initialise the model reference by cloning another |
|
ModelReferenceImpl(org.antlr.runtime.Token token)
|
|
| Method Summary | |
|---|---|
void |
accept(INRLAstVisitor visitor)
Accept a visitor to this node. |
void |
addStep(IAttribute step)
|
String |
dump(int indent)
Dump the AST and its children for debugging purposes |
IModelElement |
getCurrentContext()
Return the "current context" in which this reference was made. |
Object |
getInitialStep()
Return the initial step. |
int |
getInitialStepType()
Return the type of model reference this is: whether it starts with a variable, with a model element, or with an attribute. |
IAttribute |
getLastAttribute()
Get the last attribute in a model reference. |
String |
getOriginalString()
Return the original model reference string found in the NRL text. |
int |
getReferenceType()
Indicate what type of reference this is: to an attribute, to a static attribute or enumeration, etc. |
List<IAttribute> |
getRemainingSteps()
Return the remaining steps after the initial step has been traversed. |
List<String> |
getStepsAsStrings()
|
IModelElement |
getTarget()
Return the final target of a reference, which is always a model element. |
void |
initializeSteps()
AST processing method: initialise the stepsAsStrings and originalString member variables from the steps. |
void |
resetSteps()
|
void |
setCurrentContext(IModelElement currentContext)
|
void |
setInitialStep(Object obj)
|
void |
setReferenceType(int referenceType)
|
void |
shiftStepsLeft()
Delete the left-most step in the model reference, and move all other steps left. |
| Methods inherited from class net.sourceforge.nrl.parser.ast.constraints.impl.ConstraintImpl |
|---|
getNRLDataType, setNRLDataType |
| Methods inherited from class net.sourceforge.nrl.parser.ast.impl.Antlr3NRLBaseAst |
|---|
doIndent, getColumn, getLine, getUserData, initialisePositionFromChild, setColumn, setLine, setUserData |
| Methods inherited from class org.antlr.runtime.tree.CommonTree |
|---|
dupNode, getCharPositionInLine, getChildIndex, getParent, getText, getToken, getTokenStartIndex, getTokenStopIndex, getType, isNil, setChildIndex, setParent, setTokenStartIndex, setTokenStopIndex, setUnknownTokenBoundaries, toString |
| Methods inherited from class org.antlr.runtime.tree.BaseTree |
|---|
addChild, addChildren, createChildrenList, deleteChild, freshenParentAndChildIndexes, freshenParentAndChildIndexes, getAncestor, getAncestors, getChild, getChildCount, getChildren, getFirstChildWithType, hasAncestor, replaceChildren, sanityCheckParentAndChildIndexes, sanityCheckParentAndChildIndexes, setChild, toStringTree |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface net.sourceforge.nrl.parser.ast.constraints.IConstraint |
|---|
getNRLDataType, setNRLDataType |
| Methods inherited from interface net.sourceforge.nrl.parser.ast.INRLAstNode |
|---|
getColumn, getLine, getUserData, setUserData |
| Field Detail |
|---|
public static final char KEYWORD_ESCAPE_CHARACTER
getOriginalString().
| Constructor Detail |
|---|
public ModelReferenceImpl(org.antlr.runtime.Token token)
public ModelReferenceImpl(ModelReferenceImpl other)
other - the reference to clone| Method Detail |
|---|
public void accept(INRLAstVisitor visitor)
INRLAstNode
accept in interface INRLAstNodeaccept in class Antlr3NRLBaseAstvisitor - the visitorpublic String dump(int indent)
INRLAstNode
dump in interface INRLAstNodedump in class Antlr3NRLBaseAstindent - the indentation count, 0 on first call
public IModelElement getCurrentContext()
IModelReferenceIModelReference.getReferenceType() returns IModelReference.REFERENCE_RELATIVE_ATTRIBUTE.
For an attribute reference, this returns the model element in which the attribute occurred.
For example, in the rule in each of the trades,
the tradeDate is equal to '2005-12-12', calling this method on the tradeDate reference would
return Trade or whatever the type of 'trades' was.
getCurrentContext in interface IModelReferencepublic int getInitialStepType()
IModelReference
getInitialStepType in interface IModelReferencepublic Object getInitialStep()
IModelReferenceIModelReference.getInitialStepType() this will
return:
IAttribute object
IModelElement object
IVariable object
IMPORTANT: This can only be called after a model has been loaded, because information from the model is needed to determine this.
getInitialStep in interface IModelReferencepublic IAttribute getLastAttribute()
IModelReferenceattr1.attr2.attr3, returns attr3
attr1, returns attr1
getLastAttribute in interface IModelReferencepublic List<IAttribute> getRemainingSteps()
IModelReferenceIAttribute objects.
getRemainingSteps in interface IModelReferencepublic int getReferenceType()
IModelReferenceIModelReference.REFERENCE_ELEMENT,
IModelReference.REFERENCE_RELATIVE_ATTRIBUTE, IModelReference.REFERENCE_STATIC_ATTRIBUTE,
IModelReference.REFERENCE_TOP_CONTEXT_RELATIVE_ATTRIBUTE or
IModelReference.REFERENCE_VARIABLE_RELATIVE_ATTRIBUTE.
getReferenceType in interface IModelReferencepublic IModelElement getTarget()
IModelReferenceThere is only one case where this can return null: If the initial step is a variable that points to a complex expression rather than a model element. In that case, retrieve the expression from the variable.
getTarget in interface IModelReferencepublic List<String> getStepsAsStrings()
public String getOriginalString()
IModelReference
getOriginalString in interface IModelReferencepublic void initializeSteps()
This converts steps of the form a.b.c and c of b of a into a string
step list.
public void setInitialStep(Object obj)
public void addStep(IAttribute step)
public void resetSteps()
public void setCurrentContext(IModelElement currentContext)
public void setReferenceType(int referenceType)
public void shiftStepsLeft()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||