ptolemy.data.expr
Class NamedConstantsScope

java.lang.Object
  extended by ptolemy.data.expr.NamedConstantsScope
All Implemented Interfaces:
ParserScope

public class NamedConstantsScope
extends java.lang.Object
implements ParserScope

An implementation of ParserScope that contains a map from names to value tokens.

Since:
Ptolemy II 2.1
Version:
$Id: NamedConstantsScope.java 47482 2007-12-06 18:33:55Z cxh $
Author:
Xiaojun Liu
Accepted Rating:
Red (liuxj)
Proposed Rating:
Red (liuxj)

Field Summary
private  java.util.Map _map
           
 
Constructor Summary
NamedConstantsScope(java.util.Map map)
          Construct a new scope that contains the given map from names to value tokens.
 
Method Summary
 Token get(java.lang.String name)
          Look up and return the value with the specified name in the scope.
 Type getType(java.lang.String name)
          Look up and return the type of the value with the specified name in the scope.
 InequalityTerm getTypeTerm(java.lang.String name)
          Look up and return the type term for the specified name in the scope.
 java.util.Set identifierSet()
          Return the set of identifiers defined in this scope.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_map

private java.util.Map _map
Constructor Detail

NamedConstantsScope

public NamedConstantsScope(java.util.Map map)
Construct a new scope that contains the given map from names to value tokens.

Parameters:
map - The map of names to values where the keys are Strings that name a variable and each key is a Token.
Method Detail

get

public Token get(java.lang.String name)
Look up and return the value with the specified name in the scope. Return null if the name is not defined in this scope.

Specified by:
get in interface ParserScope
Parameters:
name - The name of the variable to be looked up.
Returns:
The token associated with the given name in the scope.

getType

public Type getType(java.lang.String name)
Look up and return the type of the value with the specified name in the scope. Return null if the name is not defined in this scope.

Specified by:
getType in interface ParserScope
Parameters:
name - The name of the variable to be looked up.
Returns:
The token associated with the given name in the scope.

getTypeTerm

public InequalityTerm getTypeTerm(java.lang.String name)
Look up and return the type term for the specified name in the scope. Return null if the name is not defined in this scope, or is a constant type.

Specified by:
getTypeTerm in interface ParserScope
Parameters:
name - The name of the variable to be looked up.
Returns:
The InequalityTerm associated with the given name in the scope.
Throws:
IllegalActionException - If a value in the scope exists with the given name, but cannot be evaluated.

identifierSet

public java.util.Set identifierSet()
Return the set of identifiers defined in this scope.

Specified by:
identifierSet in interface ParserScope
Returns:
A set containing the key defined in the map.