agg.attribute.impl
Class ContextCore

java.lang.Object
  extended by agg.attribute.impl.AttrObject
      extended by agg.attribute.impl.ManagedObject
          extended by agg.attribute.impl.ContextCore
All Implemented Interfaces:
Disposable, java.io.Serializable, java.util.Observer

public class ContextCore
extends ManagedObject
implements java.io.Serializable, Disposable

Contains declarations and values of context variables; Note that this class does NOT implement the AttrContext interface; The actual implementation for it is the wrapper class ContextView, which allows to restrict access to a context while sharing actual state (variables, conditions, mappings). An example are the different access rights of the left and the right rule side in graph transformation.

See Also:
ContextView, Serialized Form

Field Summary
protected  CondTuple conditions
          Conditions of this context.
protected  java.util.Vector<TupleMapping> delayedMappingRemovals
          Container with deferred mapping removals.
protected  boolean isFrozen
          Flag; when set, mapping removals are deferred.
protected  java.util.Hashtable<ValueTuple,java.util.Vector<TupleMapping>> mappings
          Table of mappings.
protected  int mapStyle
          Kind of mapping in this context, PLAIN_MAP or MATCH_MAP.
protected  ContextCore parent
          Parent context of this context, chain of inheritance.
protected  VarTuple variables
          Variables and parameters of this context.
 
Fields inherited from class agg.attribute.impl.ManagedObject
manager
 
Fields inherited from class agg.attribute.impl.AttrObject
classHandlerExpr, classObject, classString, initialized
 
Constructor Summary
ContextCore(AttrTupleManager manager, int mapStyle)
          Creating a new root context.
ContextCore(AttrTupleManager manager, int mapStyle, ContextCore parent)
          Creating a new child context.
 
Method Summary
 boolean addDecl(AttrHandler handler, java.lang.String type, java.lang.String name)
          Adding a new declaration; "name" is a key and must not have been previously used for a declaration in this context or any of its parents.
 void addMapping(TupleMapping mapping)
          Adding a new mapping to this context.
 boolean canSetValue(java.lang.String name, ValueMember value)
          Checking if a variable can be set to a given value without violating the application conditions.
 void clearErrorMsg()
           
 void defreeze()
          Perform mapping removals which were delayed during the freeze mode.
 void dispose()
          Prepare myself for garbage collection.
protected  void finalize()
           
 void freeze()
          Switching on of the freeze mode; mapping removals are deferred until 'defreeze()' is called.
 int getAllowedMapping()
          Getting the mapping style (match or plain).
 CondTuple getConditions()
           
 DeclMember getDecl(java.lang.String name)
          Getting the declaration (type) of a variable;
 java.lang.String getErrorMsg()
           
protected  java.util.Hashtable<ValueTuple,java.util.Vector<TupleMapping>> getMapping()
          returns all mappings
 java.util.Vector<TupleMapping> getMappingsToTarget(ValueTuple target)
          Returns Vector of mappings (TupleMapping) to a target object.
 ValueMember getValue(java.lang.String name)
          Getting the value of a variable.
 VarTuple getVariables()
           
 boolean isDeclared(java.lang.String name)
          Tests if a variable has already been declared in this context or in any of its parents;
 boolean isFrozen()
          Checking if this context is "frozen".
 boolean isVariableContext()
           
 void makeCopyOf(ContextCore context)
           
 void removeAllMappings()
           
 void removeDecl(java.lang.String name)
          Removing a declaration from this context; Parent contextes are NOT considered; Does nothing if the variable "name" is not declared;
 boolean removeMapping(TupleMapping mapping)
          Removing a mapping.
 void removeValue(java.lang.String name)
          Removing a variable
 void setValue(java.lang.String name, ValueMember value)
          Setting a variable value.
 void setVariableContext(boolean b)
          A variable context mins that mainly variables will be used as values of the graph objects of a graph, so if a rule / match attribute context has an attribute condition, it cannot be evaluated and will get TRUE as result.
 
Methods inherited from class agg.attribute.impl.ManagedObject
getAttrManager, getManager
 
Methods inherited from class agg.attribute.impl.AttrObject
defaultToString, err, err, getInstRepr, log, log, log, logEnteredMethod, logPrintln, logPrintln, stdoutPrintOnEnter, stdoutPrintOnExit, toString, update, warn, warn, warn, warn
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mapStyle

protected int mapStyle
Kind of mapping in this context, PLAIN_MAP or MATCH_MAP.


parent

protected ContextCore parent
Parent context of this context, chain of inheritance.


mappings

protected java.util.Hashtable<ValueTuple,java.util.Vector<TupleMapping>> mappings
Table of mappings. (Hashtable of Vectors of TupleMapping, key is the target object)


conditions

protected CondTuple conditions
Conditions of this context.


variables

protected VarTuple variables
Variables and parameters of this context.


isFrozen

protected transient boolean isFrozen
Flag; when set, mapping removals are deferred.


delayedMappingRemovals

protected transient java.util.Vector<TupleMapping> delayedMappingRemovals
Container with deferred mapping removals.

Constructor Detail

ContextCore

public ContextCore(AttrTupleManager manager,
                   int mapStyle)
Creating a new root context.

Parameters:
mapStyle - The kind of mapping that is done within this context; it is one of:
-
'AttrMapping.PLAIN_MAP': In Graph Transform.: rule mapping
-
'AttrMapping.MATCH_MAP': In Graph Transformation: matching

ContextCore

public ContextCore(AttrTupleManager manager,
                   int mapStyle,
                   ContextCore parent)
Creating a new child context.

Parameters:
mapStyle - The kind of mapping that is allowed within this context; it is one of:
-
'AttrMapping.PLAIN_MAP': In Graph Transform.: rule mapping
-
'AttrMapping.MATCH_MAP': In Graph Transformation: matching
parent - The parent of the new context
Method Detail

makeCopyOf

public void makeCopyOf(ContextCore context)

dispose

public void dispose()
Description copied from interface: Disposable
Prepare myself for garbage collection.

Specified by:
dispose in interface Disposable

finalize

protected final void finalize()
Overrides:
finalize in class java.lang.Object

getErrorMsg

public java.lang.String getErrorMsg()

clearErrorMsg

public void clearErrorMsg()

getConditions

public CondTuple getConditions()

getVariables

public VarTuple getVariables()

isFrozen

public boolean isFrozen()
Checking if this context is "frozen".


freeze

public void freeze()
Switching on of the freeze mode; mapping removals are deferred until 'defreeze()' is called.


defreeze

public void defreeze()
Perform mapping removals which were delayed during the freeze mode.


setVariableContext

public void setVariableContext(boolean b)
A variable context mins that mainly variables will be used as values of the graph objects of a graph, so if a rule / match attribute context has an attribute condition, it cannot be evaluated and will get TRUE as result. This feature is mainly used for critical pair analysis, where the attribute conditions will be handled especially. Do not use this setting for common transformation.


isVariableContext

public boolean isVariableContext()
See Also:
agg.attribute.impl

getAllowedMapping

public int getAllowedMapping()
Getting the mapping style (match or plain).


addMapping

public void addMapping(TupleMapping mapping)
Adding a new mapping to this context.


getMapping

protected java.util.Hashtable<ValueTuple,java.util.Vector<TupleMapping>> getMapping()
returns all mappings


getMappingsToTarget

public java.util.Vector<TupleMapping> getMappingsToTarget(ValueTuple target)
Returns Vector of mappings (TupleMapping) to a target object.


removeMapping

public boolean removeMapping(TupleMapping mapping)
Removing a mapping.

Returns:
'true' if the mapping was contained in this context at all, 'false' otherwise.

removeAllMappings

public void removeAllMappings()

isDeclared

public boolean isDeclared(java.lang.String name)
Tests if a variable has already been declared in this context or in any of its parents;

Parameters:
name - The name of the variable
Returns:
'true' if "name" is declared, 'false' otherwise

addDecl

public boolean addDecl(AttrHandler handler,
                       java.lang.String type,
                       java.lang.String name)
Adding a new declaration; "name" is a key and must not have been previously used for a declaration in this context or any of its parents.

Parameters:
name - The name of the variable to declare
type - The type of the variable
Returns:
'true' on success, 'false' otherwise

removeDecl

public void removeDecl(java.lang.String name)
Removing a declaration from this context; Parent contextes are NOT considered; Does nothing if the variable "name" is not declared;

Parameters:
name - The name of the variable to remove

getDecl

public DeclMember getDecl(java.lang.String name)
                   throws NoSuchVariableException
Getting the declaration (type) of a variable;

Parameters:
name - The name of the variable
Returns:
Type of the specified variable
Throws:
NoSuchVariableException - If no variable 'name' is declared

canSetValue

public boolean canSetValue(java.lang.String name,
                           ValueMember value)
Checking if a variable can be set to a given value without violating the application conditions. Note: if the conditions are violated already, this method returns 'true' for any 'value', unless 'value' contradicts a previously set non-null value for the variable.


setValue

public void setValue(java.lang.String name,
                     ValueMember value)
              throws NoSuchVariableException
Setting a variable value.

Parameters:
name - Name of the variable to assign to
value - Value to assign
Throws:
NoSuchVariableException - If the name is not declared in this context.

removeValue

public void removeValue(java.lang.String name)
                 throws NoSuchVariableException
Removing a variable

Parameters:
name - Name of the variable to remove
Throws:
NoSuchVariableException - If the name is not declared in this context.

getValue

public ValueMember getValue(java.lang.String name)
Getting the value of a variable.

Parameters:
name - Name of the variable to get the value from
Throws:
NoSuchVariableException - If the name is not declared in this context.