net.sourceforge.nrl.parser.ast
Interface IModelReference

All Superinterfaces:
IConstraint, IExpression, IIdentifier, INRLAstNode

public interface IModelReference
extends IIdentifier

A reference to a model element, consisting of several steps along element and attribute names. Includes an optional "where" clause. The class effectively represents a simple query over a model.


Field Summary
static int REFERENCE_ELEMENT
          Reference type: references a model element.
static int REFERENCE_GLOBAL_VARIABLE
          Reference type: global variable reference.
static int REFERENCE_RELATIVE_ATTRIBUTE
          Reference type: a reference to an attribute, relative to the current evaluation context.
static int REFERENCE_STATIC_ATTRIBUTE
          Reference type: a reference to a static attribute, or enumeration value.
static int REFERENCE_TOP_CONTEXT_RELATIVE_ATTRIBUTE
          Reference type: a reference to an attribute relative to the rule or fragment context.
static int REFERENCE_VARIABLE_RELATIVE_ATTRIBUTE
          Reference type: an attribute relative to a variable, for example x.date, where x is some bound variable.
static String SEPARATOR
          The step separator constant
static int STEP_ATTRIBUTE
          The initial step is an attribute of a model element
static int STEP_MODEL_ELEMENT
          The initial step is a model element
static int STEP_VARIABLE
          The initial step is a variable reference
 
Fields inherited from interface net.sourceforge.nrl.parser.ast.INRLAstNode
NEWLINE
 
Method Summary
 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.
 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.
 IModelElement getTarget()
          Return the final target of a reference, which is always a model element.
 
Methods inherited from interface net.sourceforge.nrl.parser.ast.constraints.IConstraint
getNRLDataType, setNRLDataType
 
Methods inherited from interface net.sourceforge.nrl.parser.ast.INRLAstNode
accept, dump, getColumn, getLine, getUserData, setUserData
 

Field Detail

REFERENCE_ELEMENT

static final int REFERENCE_ELEMENT
Reference type: references a model element. This happens, for example, in a rule context.

See Also:
Constant Field Values

REFERENCE_STATIC_ATTRIBUTE

static final int REFERENCE_STATIC_ATTRIBUTE
Reference type: a reference to a static attribute, or enumeration value. For example, TradeType.FX. Such a reference typically starts with a model element and points to a static attribute.

See Also:
Constant Field Values

REFERENCE_RELATIVE_ATTRIBUTE

static final int REFERENCE_RELATIVE_ATTRIBUTE
Reference type: a reference to an attribute, relative to the current evaluation context. For example tradeHeader.tradeDate.

See Also:
Constant Field Values

REFERENCE_TOP_CONTEXT_RELATIVE_ATTRIBUTE

static final int REFERENCE_TOP_CONTEXT_RELATIVE_ATTRIBUTE
Reference type: a reference to an attribute relative to the rule or fragment context. For example, in a rule each leg has date = Trade.date, the reference Trade.date refers to the date of the overall rule context, not the leg. The element Trade must be the rule context, otherwise an error is raised during resolution.

See Also:
Constant Field Values

REFERENCE_VARIABLE_RELATIVE_ATTRIBUTE

static final int REFERENCE_VARIABLE_RELATIVE_ATTRIBUTE
Reference type: an attribute relative to a variable, for example x.date, where x is some bound variable.

See Also:
Constant Field Values

REFERENCE_GLOBAL_VARIABLE

static final int REFERENCE_GLOBAL_VARIABLE
Reference type: global variable reference. The first step is a variable with a string or number bound to it.

See Also:
Constant Field Values

STEP_ATTRIBUTE

static final int STEP_ATTRIBUTE
The initial step is an attribute of a model element

See Also:
Constant Field Values

STEP_MODEL_ELEMENT

static final int STEP_MODEL_ELEMENT
The initial step is a model element

See Also:
Constant Field Values

STEP_VARIABLE

static final int STEP_VARIABLE
The initial step is a variable reference

See Also:
Constant Field Values

SEPARATOR

static final String SEPARATOR
The step separator constant

See Also:
Constant Field Values
Method Detail

getCurrentContext

IModelElement getCurrentContext()
Return the "current context" in which this reference was made. This is only valid if getReferenceType() returns 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.

Returns:
the element or null if wrong reference type

getInitialStepType

int getInitialStepType()
Return the type of model reference this is: whether it starts with a variable, with a model element, or with an attribute.

Returns:
the initial step type, one of the STEP constants defined in this interface

getInitialStep

Object getInitialStep()
Return the initial step. Depending on the result of getInitialStepType() this will return:

IMPORTANT: This can only be called after a model has been loaded, because information from the model is needed to determine this.

Returns:
the initial step, never null

getOriginalString

String getOriginalString()
Return the original model reference string found in the NRL text.

Returns:
the string

getRemainingSteps

List<IAttribute> getRemainingSteps()
Return the remaining steps after the initial step has been traversed. This is always a collection of IAttribute objects.

Returns:
the collection, can be empty

getReferenceType

int getReferenceType()
Indicate what type of reference this is: to an attribute, to a static attribute or enumeration, etc. This returns one of REFERENCE_ELEMENT, REFERENCE_RELATIVE_ATTRIBUTE, REFERENCE_STATIC_ATTRIBUTE, REFERENCE_TOP_CONTEXT_RELATIVE_ATTRIBUTE or REFERENCE_VARIABLE_RELATIVE_ATTRIBUTE.

Returns:
the constant

getTarget

IModelElement getTarget()
Return the final target of a reference, which is always a model element. This is used to determine what the last step in a sequence of steps pointed to.

There 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.

Returns:
the target attribute


Copyright © 2006-2010 Christian Nentwich and others