Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.nfunk.jep
Class Variable

    java.lang.Object
      java.util.Observable
          org.nfunk.jep.Variable

Direct Known Subclasses:
  XVariable

    public class Variable

extends java.util.Observable

Information about a variable. Each variable has a name, a value. There is a flag to indicate whether it is a constant or not (constants cannot have their value changed). There is also a flag to indicate whether the value of the variable is valid, if the variable is initialised without a value then its value is said to be invalid.

Version:
  2.3.0 beta 2 Now extends Observable so observers can track if the value has been changed.
Author:
  Rich Morris Created on 18-Nov-2003

Field Summary
`protected java.lang.String` | `name`

Constructor Summary
`protected` | `Variable(java.lang.String name)` Constructors are protected.
`protected` | `Variable(java.lang.String name, java.lang.Object value)` Constructors are protected.

Method Summary
`java.lang.String` | `getName()`
`java.lang.Object` | `getValue()`
`boolean` | `hasValidValue()` Is the value of this variable valid?
`boolean` | `isConstant()`
`void` | `setIsConstant(boolean b)`
`void` | `setValidValue(boolean val)` Sets whether the value of variable is valid.
`boolean` | `setValue(java.lang.Object object)` Sets the value of the variable.
`protected boolean` | `setValueRaw(java.lang.Object object)` In general subclasses should override this method rather than setValue.
`java.lang.String` | `toString()` Returns a string with the variable name followed by it's value.

Methods inherited from class java.util.Observable
`addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged`

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

Field Detail

### name

    protected java.lang.String name

Constructor Detail

### Variable

    protected Variable(java.lang.String name)

  Constructors are protected. Variables should only be created through the associated `VariableFactory` which are in turned called by `SymbolTable`.

### Variable

    protected Variable(java.lang.String name,
                       java.lang.Object value)

  Constructors are protected. Variables should only be created through the associated `VariableFactory` which are in turned called by `SymbolTable`.

Method Detail

### getName

    public java.lang.String getName()

### isConstant

    public boolean isConstant()

### setIsConstant

    public void setIsConstant(boolean b)

### getValue

    public java.lang.Object getValue()

### hasValidValue

    public boolean hasValidValue()

  Is the value of this variable valid?

### setValidValue

    public void setValidValue(boolean val)

  Sets whether the value of variable is valid.

### setValue

    public boolean setValue(java.lang.Object object)

  Sets the value of the variable. Constant values cannot be changed.

  This method call java.util.Observable.notifyObservers() to indicate to anyone interested that the value has been changed. Note subclasses should override setValueRaw rather than this method so they do not need to handle the Observable methods.

  Returns:
    false if tried to change a constant value.
  Since:
    2.3.0 beta 2 added Observable

### setValueRaw

    protected boolean setValueRaw(java.lang.Object object)

  In general subclasses should override this method rather than setValue. This is because setValue notifies any observers and then calls this method.

  Parameters:
    `object` -
  Returns:
    false if tried to change a constant value.
  Since:
    2.3.0 beta 2

### toString

    public java.lang.String toString()

  Returns a string with the variable name followed by it's value. For example for the variable "a" with the value 10, the following string is returned:

      a: 10

  If the variable is a constant the string " (Constant" is appended.

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    A string with the variable name and value.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

http://www.singularsys.com/jep Copyright © 2007 Singular Systems