public class ModelReferenceImpl extends ConstraintImpl implements IModelReference
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.
| Modifier and Type | Field and Description |
|---|---|
static char |
KEYWORD_ESCAPE_CHARACTER
The character that may appear at the start of steps to escape an NRL keyword.
|
childIndex, parent, startIndex, stopIndex, tokenREFERENCE_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_VARIABLENEWLINE| Constructor and Description |
|---|
ModelReferenceImpl(ModelReferenceImpl other)
Initialise the model reference by cloning another
|
ModelReferenceImpl(org.antlr.runtime.Token token) |
| Modifier and Type | Method and Description |
|---|---|
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.
|
getNRLDataType, setNRLDataTypedoIndent, getColumn, getLine, getUserData, initialisePositionFromChild, setColumn, setLine, setUserDatadupNode, getCharPositionInLine, getChildIndex, getParent, getText, getToken, getTokenStartIndex, getTokenStopIndex, getType, isNil, setChildIndex, setParent, setTokenStartIndex, setTokenStopIndex, setUnknownTokenBoundaries, toStringaddChild, addChildren, createChildrenList, deleteChild, freshenParentAndChildIndexes, freshenParentAndChildIndexes, getAncestor, getAncestors, getChild, getChildCount, getChildren, getFirstChildWithType, hasAncestor, replaceChildren, sanityCheckParentAndChildIndexes, sanityCheckParentAndChildIndexes, setChild, toStringTreeclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetNRLDataType, setNRLDataTypegetColumn, getLine, getUserData, setUserDatapublic static final char KEYWORD_ESCAPE_CHARACTER
getOriginalString().public ModelReferenceImpl(org.antlr.runtime.Token token)
public ModelReferenceImpl(ModelReferenceImpl other)
other - the reference to clonepublic void accept(INRLAstVisitor visitor)
INRLAstNodeaccept in interface INRLAstNodeaccept in class Antlr3NRLBaseAstvisitor - the visitorpublic String dump(int indent)
INRLAstNodedump in interface INRLAstNodedump in class Antlr3NRLBaseAstindent - the indentation count, 0 on first callpublic 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()
IModelReferencegetInitialStepType 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 String getOriginalString()
IModelReferencegetOriginalString 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()
Copyright © 2006-2013. All Rights Reserved.