de.tuberlin.cs.cis.ocl.env
Class Environment

java.lang.Object
  |
  +--de.tuberlin.cs.cis.ocl.env.Environment

public class Environment
extends java.lang.Object

The Environment of the validator.

Author:
fchabar

Constructor Summary
Environment()
          Constructs an environment
 
Method Summary
 void bind(Binding binding)
          Inserts a binding into the environment.
 boolean contains(Identifier id)
          Determines if the identifier is already bound in the environment
 Binding lookup(Identifier id)
          Resolves a binding for an identifier.
 Binding lookupName(de.tuberlin.cs.cis.ocl.parser.node.Node origin, de.tuberlin.cs.cis.ocl.parser.node.PName name)
          Resolves a name-binding for a name originated at a distinct point in input constraints.
 Binding lookupName(de.tuberlin.cs.cis.ocl.parser.node.PName name)
          Resolves a name-binding for a name.
 Binding lookupOperation(de.tuberlin.cs.cis.ocl.parser.node.Node origin, Classifier classifier, de.tuberlin.cs.cis.ocl.parser.node.PName name, Type[] params)
          Resolves an operation defined on a classifier (via an let-expression) with the specified name and parameters.
 Binding lookupProperty(de.tuberlin.cs.cis.ocl.parser.node.Node origin, Classifier classifier, de.tuberlin.cs.cis.ocl.parser.node.PName name)
          Resolves a property defined on a classifier (via an let-expression) with the specified name.
 void remove(Identifier id)
          Removes an identifier and its binding from the environment.
 void reserve(Identifier id)
          Reserves an Identifier in the environment.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Environment

public Environment()
Constructs an environment

Method Detail

contains

public boolean contains(Identifier id)
Determines if the identifier is already bound in the environment

Parameters:
id - an identifier
Returns:
true if the identifier is already bound, otherwise false.

reserve

public void reserve(Identifier id)
             throws AlreadyBoundException
Reserves an Identifier in the environment. That is the identifier will be inserted in the environment but will not be bound. The effect is that an equal identifier cannot be bound anymore.

Parameters:
id - an identifier.
Throws:
AlreadyBoundException - if the identifier is already bound.

bind

public void bind(Binding binding)
          throws AlreadyBoundException
Inserts a binding into the environment.

Parameters:
binding - A binding containing an identifier and bound values.
Throws:
AlreadyBoundException - if the identifier contained in the binding is already bound.

remove

public void remove(Identifier id)
Removes an identifier and its binding from the environment.

Parameters:
id - an identifier.

lookup

public Binding lookup(Identifier id)
               throws BindingNotFoundException
Resolves a binding for an identifier.

Parameters:
id - an identifier
Returns:
the binding containing id
Throws:
BindingNotFoundException - if the identifier is not bound within the environment.

lookupName

public Binding lookupName(de.tuberlin.cs.cis.ocl.parser.node.PName name)
                   throws BindingNotFoundException
Resolves a name-binding for a name.

Parameters:
name - a name
Returns:
the binding containing the name as identifier (NameIdentifier).
Throws:
BindingNotFoundException - if the name is not bound within the environment

lookupName

public Binding lookupName(de.tuberlin.cs.cis.ocl.parser.node.Node origin,
                          de.tuberlin.cs.cis.ocl.parser.node.PName name)
                   throws BindingNotFoundException
Resolves a name-binding for a name originated at a distinct point in input constraints.

Parameters:
origin - used to classifier the scope the name is used in.
name - the name to be resolved at origin.
Returns:
the binding of the name
Throws:
BindingNotFoundException - if the name is not bound within the environment.

lookupProperty

public Binding lookupProperty(de.tuberlin.cs.cis.ocl.parser.node.Node origin,
                              Classifier classifier,
                              de.tuberlin.cs.cis.ocl.parser.node.PName name)
                       throws BindingNotFoundException
Resolves a property defined on a classifier (via an let-expression) with the specified name. The property is a property not an operation. The name is used at origin.

Parameters:
origin - used to determine the scope the property is used in.
classifier - the classifier the property must be defined on.
name - the name of the property
Returns:
the binding containing the specified property.
Throws:
BindingNotFoundException - if the property is not bound within the environment

lookupOperation

public Binding lookupOperation(de.tuberlin.cs.cis.ocl.parser.node.Node origin,
                               Classifier classifier,
                               de.tuberlin.cs.cis.ocl.parser.node.PName name,
                               Type[] params)
                        throws BindingNotFoundException
Resolves an operation defined on a classifier (via an let-expression) with the specified name and parameters. The name is used at origin.

Parameters:
origin - used to determine the scope the operation is used in.
classifier - the classifier the operation must be defined on.
name - the name of the operation
params - the parameters of the operation
Returns:
the binding containing the specified operation.
Throws:
BindingNotFoundException - if the property is not bound within the environment