gov.nasa.arc.brahms.common.rt
Class VariableCtx

java.lang.Object
  extended by gov.nasa.arc.brahms.common.rt.BrahmsObjectCtx
      extended by gov.nasa.arc.brahms.common.rt.VariableCtx
All Implemented Interfaces:
IBrahmsObjectCtx, IRuntimeConstants, IVariableCtx, java.io.Serializable
Direct Known Subclasses:
VMVariableCtx

public class VariableCtx
extends BrahmsObjectCtx
implements IVariableCtx

The VariableCtx maintains information regarding the binding of a variable defined for a frame and bound in a frame context. The binding of a variable can be one or more values depending on the type of variable and depending on the binding of the variable in a precondition or activity.

Version:
$Revision: 1.4 $ $Date: 2009/11/23 19:12:22 $ $Author: rnado $
Author:
Ron van Hoof
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface gov.nasa.arc.brahms.common.rt.IRuntimeConstants
ABORTED, ACTIVE, ACTIVITY, AVAILABLE, COMPLETED, CONSEQUENCE, DETECTABLE, ENDED, ENGINE, EXTERNAL_AGENT, FROM, IMPASSED, INITIAL, INTERRUPTED, JAVA_PROPERTY, sABORTED, sACTIVE, sAVAILABLE, sCOMPLETED, sENDED, sIMPASSED, sINTERRUPTED, sUNAVAILABLE, TO, TRANSFER, UNAVAILABLE
 
Constructor Summary
protected VariableCtx(Variable var)
          Constructor, creates a new context for a variable.
  VariableCtx(Variable var, IFrameCtx frame)
          Constructor, creates a new context for a variable bound in a specific frame context.
 
Method Summary
 void addBinding(java.lang.Boolean value)
          Adds the specified value to bind the variable.
 void addBinding(java.lang.Byte value)
          Adds the specified value to bind the variable.
 void addBinding(java.lang.Character value)
          Adds the specified value to bind the variable.
 void addBinding(java.lang.Double value)
          Adds the specified value to bind the variable.
 void addBinding(java.lang.Float value)
          Adds the specified value to bind the variable.
 void addBinding(IConceptCtx value)
          Adds the specified value to bind the variable.
 void addBinding(java.lang.Integer value)
          Adds the specified value to bind the variable.
 void addBinding(java.lang.Long value)
          Adds the specified value to bind the variable.
 void addBinding(java.lang.Object value)
          Adds the specified value to bind the variable.
 void addBinding(java.lang.Short value)
          Adds the specified value to bind the variable.
 void addBinding(java.lang.String value)
          Adds the specified value to bind the variable.
 void addBinding(Unknown value)
          Adds the specified value to bind the variable.
 void addBinding(Value value)
          Adds the specified value to bind the variable.
 void addJavaBinding(java.lang.Object value)
          Adds the specified value to bind the variable.
 void clearBinding()
          Clears the bindings, removing all binding values.
 java.util.Enumeration getBinding()
          Returns a list of all the value bindings for this variable.
 IBrahmsObjectCtx getBindingElement()
          Returns the element binding the variable (PreconditionCtx, DetectableCtx, TransferDefinitionCtx, ActivityCtx)
 IFrameCtx getBindingFrame()
          Returns the frame context in which the variable is bound.
 boolean hasBinding(java.lang.Object value)
          Tests whether this context has the specified value as a binding.
 boolean isBound()
          Returns whether the variable is bound to a value (true) or not (false).
 void removeBinding(java.lang.Object value)
          Removes the specified value as a binding for the variable.
 void setBindingElement(IBrahmsObjectCtx elm)
          Sets the element binding the variable (PreconditionCtx, DetectableCtx, TransferDefinitionCtx, ActivityCtx)
 void setBindingFrame(IFrameCtx frame)
          Sets the frame context in which the variable is bound.
 void setBound(boolean bound)
          Specifies whether the variable is bound to a value (true) or not (false).
 
Methods inherited from class gov.nasa.arc.brahms.common.rt.BrahmsObjectCtx
addNote, getContextFor, getEndTime, getID, getNote, getNotes, getStartTime, removeNote, setContextFor, setEndTime, setID, setStartTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.nasa.arc.brahms.common.rt.IBrahmsObjectCtx
addNote, getContextFor, getEndTime, getID, getNote, getNotes, getStartTime, removeNote, setEndTime, setID, setStartTime
 

Constructor Detail

VariableCtx

protected VariableCtx(Variable var)
               throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Constructor, creates a new context for a variable. Initially the variable is unbound, meaning no values are bound to the variable.

Parameters:
var - the variable for which this variable context is the context
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an internal error occurs

VariableCtx

public VariableCtx(Variable var,
                   IFrameCtx frame)
            throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Constructor, creates a new context for a variable bound in a specific frame context. Initially the variable is unbound, meaning no values are bound to the variable.

Parameters:
var - the variable for which this variable context is the context
frame - the frame context in which the variable is bound
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if frame is null
Method Detail

setBindingFrame

public void setBindingFrame(IFrameCtx frame)
                     throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Sets the frame context in which the variable is bound.

Specified by:
setBindingFrame in interface IVariableCtx
Parameters:
frame - the IFrameCtx in which the variable is bound.
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if a null frame is specified

getBindingFrame

public IFrameCtx getBindingFrame()
                          throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns the frame context in which the variable is bound.

Specified by:
getBindingFrame in interface IVariableCtx
Returns:
IFrameCtx the frame in which the variable is bound.
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if no binding frame is specified

setBindingElement

public void setBindingElement(IBrahmsObjectCtx elm)
                       throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Sets the element binding the variable (PreconditionCtx, DetectableCtx, TransferDefinitionCtx, ActivityCtx)

Specified by:
setBindingElement in interface IVariableCtx
Parameters:
elm - the IBrahmsObjectCtx binding the variable.
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if a null element is specified

getBindingElement

public IBrahmsObjectCtx getBindingElement()
                                   throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns the element binding the variable (PreconditionCtx, DetectableCtx, TransferDefinitionCtx, ActivityCtx)

Specified by:
getBindingElement in interface IVariableCtx
Returns:
IBrahmsObjectCtx the element binding the variable.
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if no binding element is specified

setBound

public void setBound(boolean bound)
Specifies whether the variable is bound to a value (true) or not (false).

Specified by:
setBound in interface IVariableCtx
Parameters:
bound - true if a value is assigned, false otherwise

isBound

public boolean isBound()
Returns whether the variable is bound to a value (true) or not (false).

Specified by:
isBound in interface IVariableCtx
Returns:
boolean true if a value is assigned, false otherwise

addBinding

public void addBinding(java.lang.Object value)
                throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Adds the specified value to bind the variable.

Specified by:
addBinding in interface IVariableCtx
Parameters:
value - the object to be added as a binding
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if value is null

addBinding

public void addBinding(java.lang.Integer value)
                throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Adds the specified value to bind the variable.

Specified by:
addBinding in interface IVariableCtx
Parameters:
value - the Integer to be added as a binding
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if value is null

addBinding

public void addBinding(java.lang.Character value)
                throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Adds the specified value to bind the variable.

Specified by:
addBinding in interface IVariableCtx
Parameters:
value - the Character to be added as a binding
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if value is null

addBinding

public void addBinding(java.lang.Byte value)
                throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Adds the specified value to bind the variable.

Specified by:
addBinding in interface IVariableCtx
Parameters:
value - the Byte to be added as a binding
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if value is null

addBinding

public void addBinding(java.lang.Short value)
                throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Adds the specified value to bind the variable.

Specified by:
addBinding in interface IVariableCtx
Parameters:
value - the Short to be added as a binding
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if value is null

addBinding

public void addBinding(java.lang.Long value)
                throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Adds the specified value to bind the variable.

Specified by:
addBinding in interface IVariableCtx
Parameters:
value - the Long to be added as a binding
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if value is null

addBinding

public void addBinding(java.lang.Float value)
                throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Adds the specified value to bind the variable.

Specified by:
addBinding in interface IVariableCtx
Parameters:
value - the Float to be added as a binding
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if value is null

addBinding

public void addBinding(java.lang.Double value)
                throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Adds the specified value to bind the variable.

Specified by:
addBinding in interface IVariableCtx
Parameters:
value - the Double to be added as a binding
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if value is null

addBinding

public void addBinding(java.lang.Boolean value)
                throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Adds the specified value to bind the variable.

Specified by:
addBinding in interface IVariableCtx
Parameters:
value - the Boolean to be added as a binding
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if value is null

addBinding

public void addBinding(java.lang.String value)
                throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Adds the specified value to bind the variable.

Specified by:
addBinding in interface IVariableCtx
Parameters:
value - the String to be added as a binding
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if value is null

addBinding

public void addBinding(IConceptCtx value)
                throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Adds the specified value to bind the variable.

Specified by:
addBinding in interface IVariableCtx
Parameters:
value - the IConceptCtx to be added as a binding
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if value is null

addJavaBinding

public void addJavaBinding(java.lang.Object value)
                    throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Adds the specified value to bind the variable.

Specified by:
addJavaBinding in interface IVariableCtx
Parameters:
value - the Java Object to be added as a binding
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if value is null

addBinding

public void addBinding(Unknown value)
                throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Adds the specified value to bind the variable.

Specified by:
addBinding in interface IVariableCtx
Parameters:
value - the Unknown value to be added as a binding
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if value is null

addBinding

public void addBinding(Value value)
                throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Adds the specified value to bind the variable.

Specified by:
addBinding in interface IVariableCtx
Parameters:
value - the Value to be added as a binding
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if value is null

hasBinding

public boolean hasBinding(java.lang.Object value)
Tests whether this context has the specified value as a binding. To test for primitive values use their object wrappers to test for the binding.

Specified by:
hasBinding in interface IVariableCtx
Parameters:
value - the value to be tested

removeBinding

public void removeBinding(java.lang.Object value)
                   throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Removes the specified value as a binding for the variable. The value can be a Value object, a concept context or a primitive value wrapped into an object.

Specified by:
removeBinding in interface IVariableCtx
Parameters:
value - the value to be removed as a binding
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if value is null, no values are present, or the value is not found

clearBinding

public void clearBinding()
Clears the bindings, removing all binding values.

Specified by:
clearBinding in interface IVariableCtx

getBinding

public java.util.Enumeration getBinding()
                                 throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns a list of all the value bindings for this variable.

Specified by:
getBinding in interface IVariableCtx
Returns:
Enumeration an enumeration of Value
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if there are no bindings


Copyright © 1997-2012 All Rights Reserved.