net.sourceforge.nrl.parser.ast
Class Variable

java.lang.Object
  extended by net.sourceforge.nrl.parser.ast.Variable
All Implemented Interfaces:
IVariable

public class Variable
extends Object
implements IVariable

A default implementation of the variable reference interface.


Constructor Summary
Variable(String name, IExpression boundExpression)
           
Variable(String name, IModelElement boundElement)
           
 
Method Summary
 IModelElement getBoundElement()
          Return the model element bound to this variable.
 IExpression getBoundExpression()
          Return the complex expression bound to this variable.
 INRLAstNode getDeclarationNode()
          Helper node for error reporting - where the variable was declared
 String getName()
          Return the variable name.
 NRLDataType getNRLDataType()
          Return a type constant from the NRLDataType class, indicating the data type of the variable.
 Object getUserData(String key)
          Return a named user data object associated with this variable.
 boolean isBoundToElement()
          Return true if the variable is bound to a model element, false if it is bound to a complex expression
 void setDeclarationNode(INRLAstNode declarationNode)
          Helper node for error reporting - where the variable was declared
 void setNRLDataType(NRLDataType type)
          Assign an NRL type to this variable.
 void setUserData(String key, Object data)
          Associate user data with this variable node, under a given key.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Variable

public Variable(String name,
                IExpression boundExpression)

Variable

public Variable(String name,
                IModelElement boundElement)
Method Detail

getBoundElement

public IModelElement getBoundElement()
Description copied from interface: IVariable
Return the model element bound to this variable. If IVariable.isBoundToElement() returns false for this variable, then this method will return null.

Specified by:
getBoundElement in interface IVariable
Returns:
the element or null if a complex expression is bound.

getBoundExpression

public IExpression getBoundExpression()
Description copied from interface: IVariable
Return the complex expression bound to this variable. If IVariable.isBoundToElement() returns true for this variable, then this will return null, else it returns the expression.

Specified by:
getBoundExpression in interface IVariable
Returns:
the expression of null if the variable is bound to an element

getDeclarationNode

public INRLAstNode getDeclarationNode()
Helper node for error reporting - where the variable was declared

Returns:
the node

getName

public String getName()
Description copied from interface: IVariable
Return the variable name.

Specified by:
getName in interface IVariable
Returns:
the variable name

getNRLDataType

public NRLDataType getNRLDataType()
Description copied from interface: IVariable
Return a type constant from the NRLDataType class, indicating the data type of the variable.

This can only be called once a type inference algorithm has been applied to the variable or the entire AST.

Specified by:
getNRLDataType in interface IVariable
Returns:
the type, never null

getUserData

public Object getUserData(String key)
Description copied from interface: IVariable
Return a named user data object associated with this variable.

Specified by:
getUserData in interface IVariable
Parameters:
key - the key identifying the data
Returns:
the object or null if no such data

isBoundToElement

public boolean isBoundToElement()
Description copied from interface: IVariable
Return true if the variable is bound to a model element, false if it is bound to a complex expression

Specified by:
isBoundToElement in interface IVariable
Returns:
true if bound to element

setDeclarationNode

public void setDeclarationNode(INRLAstNode declarationNode)
Helper node for error reporting - where the variable was declared

Parameters:
declarationNode - the node

setNRLDataType

public void setNRLDataType(NRLDataType type)
Description copied from interface: IVariable
Assign an NRL type to this variable.

Specified by:
setNRLDataType in interface IVariable
Parameters:
type - the type

setUserData

public void setUserData(String key,
                        Object data)
Description copied from interface: IVariable
Associate user data with this variable node, under a given key.

Specified by:
setUserData in interface IVariable
Parameters:
key - the key
data - the data


Copyright © 2006-2010 Christian Nentwich and others