DynamicJava Javadoc: Class VariableContext

Overview | Package | Class | Use | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## koala.dynamicjava.interpreter.context
Class VariableContext

    java.lang.Object
      |
      +--koala.dynamicjava.interpreter.context.VariableContext

All Implemented Interfaces:
  SimpleContext

Direct Known Subclasses:
  GlobalContext

public class VariableContext
extends java.lang.Object
implements SimpleContext

This class encapsulates the behaviour of Java scopes.

Inner Class Summary
`protected static class` | `VariableContext.AbstractVariable` To store the variables
`protected class` | `VariableContext.Constant` To store the constants
`protected static class` | `VariableContext.Link` To store one scope
`protected static class` | `VariableContext.LinkFactory` To manage the creation of scopes and links
`protected static class` | `VariableContext.Scope` A table which maps a string with an object
`protected static class` | `VariableContext.Variable` To store the variables

Field Summary
`protected VariableContext.Scope` | `cscope` The current scope for variables
`protected VariableContext.Scope` | `scope` The current scope
`protected VariableContext.Link` | `scopes` The scopes

Constructor Summary
`VariableContext()` Creates a new context initialized with an empty initial scope
`VariableContext(java.util.Set entries)` Creates a new context initialized with the given entries defined in the initial scope.

Method Summary
`void` | `define(java.lang.String name, java.lang.Object value)` Defines a new variable in the current scope
`void` | `defineConstant(java.lang.String name, java.lang.Object value)` Defines a new constant variable in the current scope
`void` | `defineVariables(java.util.Set vars)` Defines the given variables
`void` | `enterScope()` Enters a scope
`void` | `enterScope(java.util.Set entries)` Enters a scope and defines the given entries to null.
`java.lang.Object` | `get(java.lang.String name)` Returns the value of a variable with the given name
`java.util.Map` | `getConstants()` Creates a map that contains the constants in this context
`java.util.Set` | `getCurrentScopeVariableNames()` Returns the current scope variables (strings) in a set
`java.util.Set` | `getCurrentScopeVariables()` Returns the current scope variables in a set
`boolean` | `isDefinedVariable(java.lang.String name)` Tests whether an entry is defined in this context
`boolean` | `isFinal(java.lang.String name)` Tests whether a variable is final in this context
`java.util.Set` | `leaveScope()` Leaves the current scope
`void` | `set(java.lang.String name, java.lang.Object value)` Sets the value of a defined variable
`void` | `setConstant(java.lang.String name, java.lang.Object value)` Sets the value of a constant variable in the current scope
`void` | `setVariable(java.lang.String name, java.lang.Object value)` Sets the value of a variable in the current scope

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### scopes

    protected VariableContext.Link scopes

  The scopes

### scope

    protected VariableContext.Scope scope

  The current scope

### cscope

    protected VariableContext.Scope cscope

  The current scope for variables

Constructor Detail

### VariableContext

    public VariableContext()

  Creates a new context initialized with an empty initial scope

### VariableContext

    public VariableContext(java.util.Set entries)

  Creates a new context initialized with the given entries defined in the initial scope.
  Parameters:
    `entries` - a set of string

Method Detail

### enterScope

    public void enterScope()

  Enters a scope
  Specified by:
    `enterScope` in interface `SimpleContext`

### enterScope

    public void enterScope(java.util.Set entries)

  Enters a scope and defines the given entries to null.
  Specified by:
    `enterScope` in interface `SimpleContext`
  Parameters:
    `entries` - a set of string

### defineVariables

    public void defineVariables(java.util.Set vars)

  Defines the given variables
  Specified by:
    `defineVariables` in interface `SimpleContext`

### leaveScope

    public java.util.Set leaveScope()

  Leaves the current scope
  Specified by:
    `leaveScope` in interface `SimpleContext`
  Returns:
    the set of variable defined in this scope

### getCurrentScopeVariables

    public java.util.Set getCurrentScopeVariables()

  Returns the current scope variables in a set
  Specified by:
    `getCurrentScopeVariables` in interface `SimpleContext`

### getCurrentScopeVariableNames

    public java.util.Set getCurrentScopeVariableNames()

  Returns the current scope variables (strings) in a set
  Specified by:
    `getCurrentScopeVariableNames` in interface `SimpleContext`

### isDefinedVariable

    public boolean isDefinedVariable(java.lang.String name)

  Tests whether an entry is defined in this context
  Specified by:
    `isDefinedVariable` in interface `SimpleContext`
  Parameters:
    `name` - the name of the entry

### isFinal

    public boolean isFinal(java.lang.String name)

  Tests whether a variable is final in this context
  Specified by:
    `isFinal` in interface `SimpleContext`
  Parameters:
    `name` - the name of the entry
  Returns:
    false if the variable is not final
  Throws:
    `java.lang.IllegalStateException` - if the variable is not defined

### define

    public void define(java.lang.String name,
                       java.lang.Object value)

  Defines a new variable in the current scope
  Specified by:
    `define` in interface `SimpleContext`
  Parameters:
    `name` - the name of the new entry
    `value` - the value of the entry
  Throws:
    `java.lang.IllegalStateException` - if the variable is already defined

### defineConstant

    public void defineConstant(java.lang.String name,
                               java.lang.Object value)

  Defines a new constant variable in the current scope
  Specified by:
    `defineConstant` in interface `SimpleContext`
  Parameters:
    `name` - the name of the new entry
    `value` - the value of the entry
  Throws:
    `java.lang.IllegalStateException` - if the variable is already defined

### get

    public java.lang.Object get(java.lang.String name)

  Returns the value of a variable with the given name
  Specified by:
    `get` in interface `SimpleContext`
  Parameters:
    `name` - the name of the value to get
  Throws:
    `java.lang.IllegalStateException` - if the variable is not defined

### set

    public void set(java.lang.String name,
                    java.lang.Object value)

  Sets the value of a defined variable
  Specified by:
    `set` in interface `SimpleContext`
  Parameters:
    `name` - the name of the entry
    `value` - the value of the entry
  Throws:
    `java.lang.IllegalStateException` - if the variable is not defined or is final

### setConstant

    public void setConstant(java.lang.String name,
                            java.lang.Object value)

  Sets the value of a constant variable in the current scope
  Specified by:
    `setConstant` in interface `SimpleContext`
  Parameters:
    `name` - the name of the entry
    `value` - the value of the entry

### setVariable

    public void setVariable(java.lang.String name,
                            java.lang.Object value)

  Sets the value of a variable in the current scope
  Specified by:
    `setVariable` in interface `SimpleContext`
  Parameters:
    `name` - the name of the entry
    `value` - the value of the entry

### getConstants

    public java.util.Map getConstants()

  Creates a map that contains the constants in this context
  Specified by:
    `getConstants` in interface `SimpleContext`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001 Stephane Hillion. All Rights Reserved.