agg.attribute.impl
Class ContextView

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

public class ContextView
extends ManagedObject
implements AttrContext, SymbolTable

This is a view onto an underlying ContextCore class object; By this delegation, views with different access rights can share the same context; At this stage, just two access modes are implemented: "LeftRuleSide" and "RightRuleSide"; "RightRuleSide" access does not allow adding or removing of variable declarations;

See Also:
ContextCore, Serialized Form

Field Summary
protected  boolean canDeclareVar
          Describes the access mode.
protected  boolean canHaveEmptyValues
          Describes the access mode.
protected  boolean canUseComplexExpr
          Describes the access mode.
protected  boolean canUseInitialExpr
          Describes the access mode.
protected  ContextCore core
          Handle to the actual context core.
 
Fields inherited from class agg.attribute.impl.ManagedObject
manager
 
Fields inherited from class agg.attribute.impl.AttrObject
classHandlerExpr, classObject, classString, initialized
 
Constructor Summary
ContextView(AttrTupleManager manager, AttrContext source, boolean leftRuleSide)
          Returns a new view which shares another view's context and has the specified access mode;
ContextView(AttrTupleManager manager, ContextCore source)
          Returns a new view for the specified context.
ContextView(AttrTupleManager manager, int mapStyle)
          Creates a new root context and returns a full access view for it;
ContextView(AttrTupleManager manager, int mapStyle, AttrContext parent)
          Creates a new child context and returns a full access view for it;
 
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 before;
 void addMapping(TupleMapping mapping)
          Adding another Mapped pair to the actual 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 copyAttrContext(AttrContext context)
           
 void defreeze()
          Perform mapping removals which were delayed during the freeze mode.
 void dispose()
          Prepare myself for garbage collection.
 boolean doesAllowComplexExpressions()
          Query if we're on the right rule side.
 boolean doesAllowEmptyValues()
          Query if we're on the left rule side.
 boolean doesAllowInitialExpressions()
          Query if we're on the left or right rule side.
 boolean doesAllowNewVariables()
          Query if we're on the left rule side.
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).
 AttrConditionTuple getConditions()
           
 java.lang.String getErrorMsg()
           
 HandlerExpr getExpr(java.lang.String name)
          Implementing the SymbolTable interface for value retrieval.
 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.
 int getMapStyle()
           
 HandlerType getType(java.lang.String name)
          Implementing the SymbolTable interface for type retrieval.
 AttrVariableTuple 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 isVariableContext()
           
 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 Mapped pair from the actual context.
 void removeValue(java.lang.String name)
          Removing the value of the specified variable name from this context;
 void setAllowComplexExpr(boolean isAllowed)
           
 void setAllowEmptyValues(boolean isAllowed)
           
 void setAllowInitialExpr(boolean isAllowed)
           
 void setAllowVarDeclarations(boolean isAllowed)
           
 void setAttrContext(AttrContext source)
          Maybe a distributed graph wants to set an attribute context
 void setValue(java.lang.String name, ValueMember value)
          Appending a value to a variable; This will be the current value until a new value will be appended or this one removed
 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

core

protected ContextCore core
Handle to the actual context core.


canDeclareVar

protected boolean canDeclareVar
Describes the access mode.


canUseComplexExpr

protected boolean canUseComplexExpr
Describes the access mode.


canHaveEmptyValues

protected boolean canHaveEmptyValues
Describes the access mode.


canUseInitialExpr

protected boolean canUseInitialExpr
Describes the access mode.

Constructor Detail

ContextView

public ContextView(AttrTupleManager manager,
                   int mapStyle)
Creates a new root context and returns a full access view for it;

Parameters:
manager - The calling Attribute Manager
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

ContextView

public ContextView(AttrTupleManager manager,
                   int mapStyle,
                   AttrContext parent)
Creates a new child context and returns a full access view for it;

Parameters:
manager - The calling Attribute Manager
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 view whose context is to be the parent for this view's context

ContextView

public ContextView(AttrTupleManager manager,
                   AttrContext source,
                   boolean leftRuleSide)
Returns a new view which shares another view's context and has the specified access mode;

Parameters:
manager - The calling Attribute Manager
source - The view to share the context with
leftRuleSide - Convenience parameter, sets access control appropriately.

ContextView

public ContextView(AttrTupleManager manager,
                   ContextCore source)
Returns a new view for the specified context.

Parameters:
manager - The calling Attribute Manager
source - The context to view at.
Method Detail

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()

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

getConditions

public AttrConditionTuple getConditions()
Specified by:
getConditions in interface AttrContext

getVariables

public AttrVariableTuple getVariables()
Specified by:
getVariables in interface AttrContext

getMappingsToTarget

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


doesAllowComplexExpressions

public boolean doesAllowComplexExpressions()
Query if we're on the right rule side.

Specified by:
doesAllowComplexExpressions in interface AttrContext

doesAllowInitialExpressions

public boolean doesAllowInitialExpressions()
Query if we're on the left or right rule side.


doesAllowNewVariables

public boolean doesAllowNewVariables()
Query if we're on the left rule side.

Specified by:
doesAllowNewVariables in interface AttrContext

doesAllowEmptyValues

public boolean doesAllowEmptyValues()
Query if we're on the left rule side.

Specified by:
doesAllowEmptyValues in interface AttrContext

setAllowVarDeclarations

public void setAllowVarDeclarations(boolean isAllowed)
Specified by:
setAllowVarDeclarations in interface AttrContext

setAllowComplexExpr

public void setAllowComplexExpr(boolean isAllowed)
Specified by:
setAllowComplexExpr in interface AttrContext

setAllowInitialExpr

public void setAllowInitialExpr(boolean isAllowed)

setAllowEmptyValues

public void setAllowEmptyValues(boolean isAllowed)
Specified by:
setAllowEmptyValues in interface AttrContext

setAttrContext

public void setAttrContext(AttrContext source)
Maybe a distributed graph wants to set an attribute context

Specified by:
setAttrContext in interface AttrContext
Parameters:
source - the object to take the information from

copyAttrContext

public void copyAttrContext(AttrContext context)

freeze

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

Specified by:
freeze in interface AttrContext

defreeze

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

Specified by:
defreeze in interface AttrContext

getType

public HandlerType getType(java.lang.String name)
Implementing the SymbolTable interface for type retrieval.

Specified by:
getType in interface AttrContext
Specified by:
getType in interface SymbolTable
Parameters:
name - Identifier's name
Returns:
Identifier's type
See Also:
SymbolTable

getExpr

public HandlerExpr getExpr(java.lang.String name)
Implementing the SymbolTable interface for value retrieval.

Specified by:
getExpr in interface AttrContext
Specified by:
getExpr in interface SymbolTable
Parameters:
name - Identifier's name
Returns:
Identifier's value as expression
See Also:
SymbolTable

getAllowedMapping

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


addMapping

public void addMapping(TupleMapping mapping)
Adding another Mapped pair to the actual context.


getMapping

public java.util.Hashtable<ValueTuple,java.util.Vector<TupleMapping>> getMapping()
returns all Mappings


removeMapping

public boolean removeMapping(TupleMapping mapping)
Removing a Mapped pair from the actual context.


removeAllMappings

public void removeAllMappings()
Specified by:
removeAllMappings in interface AttrContext

getMapStyle

public int getMapStyle()

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)
                throws ContextRestrictedException
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 before;

Parameters:
name - The name of the variable to declare
type - The type of the variable
Returns:
'true' on success, 'false' otherwise
Throws:
ContextRestrictedException - If this view is restricted

removeDecl

public void removeDecl(java.lang.String name)
                throws ContextRestrictedException
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
Throws:
ContextRestrictedException - If this view is restricted

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
Appending a value to a variable; This will be the current value until a new value will be appended or this one removed

Parameters:
name - The name of the variable
value - The value to append to the variable
Throws:
NoSuchVariableException - If no variable 'name' is declared

removeValue

public void removeValue(java.lang.String name)
                 throws NoSuchVariableException
Removing the value of the specified variable name from this context;

Parameters:
name - The name of the variable
Throws:
NoSuchVariableException - If no variable 'name' is declared
WrongContextException - If the value was not assigned in this context