Module graph

Class GraphState

java.lang.Object
de.grogra.graph.GraphState
Direct Known Subclasses:
DelegateGraphState, GraphBase.State, State

public abstract class GraphState extends Object
A GraphState provides a context to access and modify a Graph. It also contains state information for object instancing and object context. Each graph state is associated with a thread, most operations may only be performed when this thread is the current thread.
Author:
Ole Kniemeyer
See Also:
  • Constructor Details

    • GraphState

      protected GraphState()
  • Method Details

    • allocatePropertyId

      public static int allocatePropertyId()
    • initialize

      protected void initialize(Graph graph, ThreadContext ctx)
    • dispose

      public void dispose()
    • finalize

      protected void finalize()
      Overrides:
      finalize in class Object
    • setUserProperty

      public Object setUserProperty(int id, Object value)
    • getUserProperty

      public Object getUserProperty(int id)
    • forContext

      public GraphState forContext(ThreadContext tc)
    • createDelegate

      protected abstract GraphState createDelegate(ThreadContext tc)
    • get

      public static GraphState get(Graph graph, ThreadContext tc)
      Returns the graph state of the graph which is valid within the given ThreadContext.
      Parameters:
      graph - a graph
      tc - a thread context
      Returns:
      the graph state for the context, or null if such a graph state has not yet been created
    • current

      public static GraphState current(Graph graph)
      Returns the graph state of the graph which is valid within the current thread.
      Parameters:
      graph - a graph
      Returns:
      the graph state for current thread, or null if such a graph state has not yet been created
    • getGraph

      public final Graph getGraph()
      Returns the graph of this graph state.
      Returns:
      graph of this state
    • getContext

      public final ThreadContext getContext()
      Returns the ThreadContext within which operations on this graph state are valid.
      Returns:
      ThreadContext of this graph state
    • setObjectContext

      public void setObjectContext(Object object, boolean asNode)
    • getObjectContext

      public GraphState.ObjectContext getObjectContext()
    • setObjectContext

      public void setObjectContext(GraphState.ObjectContext newState)
    • createObjectState

      public GraphState.ObjectContext createObjectState(Object object, boolean asNode)
    • setEdgeBits

      public abstract void setEdgeBits(Object edge, int bits)
    • fireAttributeChanged

      public abstract void fireAttributeChanged(Object object, boolean asNode, Attribute a, FieldChain field, int[] indices)
    • fireEdgeChanged

      protected abstract void fireEdgeChanged(Object source, Object target, Object edge)
    • containsInTree

      public abstract boolean containsInTree(Object object, boolean asNode)
      Tests whether an object is contained in the tree of the graph. The tree is defined by Graph.getTreePattern().
      Parameters:
      object - the object
      asNode - true if object is a node, false if object is an edge
      Returns:
      true iff the object is part of the tree
    • getInstancingPath

      public Path getInstancingPath()
    • getInstancingPathIndex

      public int getInstancingPathIndex()
    • beginInstancing

      public void beginInstancing(Object refNode, long id)
    • endInstancing

      public void endInstancing()
    • instantiate

      public void instantiate(Object object, boolean asNode, long id)
    • instantiateEdge

      public void instantiateEdge(int edges, boolean edgeDirection, long id)
    • deinstantiate

      public void deinstantiate()
    • setInstanceAttribute

      public void setInstanceAttribute(Attribute a, Object value)
    • moveToPreviousInstance

      public void moveToPreviousInstance()
    • moveToNextInstance

      public void moveToNextInstance()
    • moveToInstance

      public void moveToInstance(int index)
    • getObject

      public <T> T getObject(Object object, boolean asNode, ObjectAttribute<T> a)
    • checkBoolean

      public boolean checkBoolean(Object object, boolean asNode, BooleanAttribute a, boolean value)
    • getBooleanDefault

      public boolean getBooleanDefault(Object object, boolean asNode, BooleanAttribute a, boolean defaultValue)
      Returns the value of attribute a for object in this graph state. If no such value is defined, defaultValue is used instead. This method respects derived attributes and attribute values of instantiated objects which are set by setInstanceAttribute(Attribute, Object).
      Parameters:
      object - the object
      asNode - true if object is a node, false if object is an edge
      a - the attribute to read
      defaultValue - default value to return if the attribute is not defined on object
      Returns:
      value of the attribute for the object, or defaultValue
    • getBoolean

      public boolean getBoolean(Object object, boolean asNode, BooleanAttribute a)
      Returns the value of attribute a for object in this graph state. This method respects derived attributes and attribute values of instantiated objects which are set by setInstanceAttribute(Attribute, Object).
      Parameters:
      object - the object
      asNode - true if object is a node, false if object is an edge
      a - the attribute to read
      Returns:
      value of the attribute for the object
      Throws:
      NoSuchKeyException - if the attribute is not defined for the object
    • checkByte

      public byte checkByte(Object object, boolean asNode, ByteAttribute a, byte value)
    • getByteDefault

      public byte getByteDefault(Object object, boolean asNode, ByteAttribute a, byte defaultValue)
      Returns the value of attribute a for object in this graph state. If no such value is defined, defaultValue is used instead. This method respects derived attributes and attribute values of instantiated objects which are set by setInstanceAttribute(Attribute, Object).
      Parameters:
      object - the object
      asNode - true if object is a node, false if object is an edge
      a - the attribute to read
      defaultValue - default value to return if the attribute is not defined on object
      Returns:
      value of the attribute for the object, or defaultValue
    • getByte

      public byte getByte(Object object, boolean asNode, ByteAttribute a)
      Returns the value of attribute a for object in this graph state. This method respects derived attributes and attribute values of instantiated objects which are set by setInstanceAttribute(Attribute, Object).
      Parameters:
      object - the object
      asNode - true if object is a node, false if object is an edge
      a - the attribute to read
      Returns:
      value of the attribute for the object
      Throws:
      NoSuchKeyException - if the attribute is not defined for the object
    • checkShort

      public short checkShort(Object object, boolean asNode, ShortAttribute a, short value)
    • getShortDefault

      public short getShortDefault(Object object, boolean asNode, ShortAttribute a, short defaultValue)
      Returns the value of attribute a for object in this graph state. If no such value is defined, defaultValue is used instead. This method respects derived attributes and attribute values of instantiated objects which are set by setInstanceAttribute(Attribute, Object).
      Parameters:
      object - the object
      asNode - true if object is a node, false if object is an edge
      a - the attribute to read
      defaultValue - default value to return if the attribute is not defined on object
      Returns:
      value of the attribute for the object, or defaultValue
    • getShort

      public short getShort(Object object, boolean asNode, ShortAttribute a)
      Returns the value of attribute a for object in this graph state. This method respects derived attributes and attribute values of instantiated objects which are set by setInstanceAttribute(Attribute, Object).
      Parameters:
      object - the object
      asNode - true if object is a node, false if object is an edge
      a - the attribute to read
      Returns:
      value of the attribute for the object
      Throws:
      NoSuchKeyException - if the attribute is not defined for the object
    • checkChar

      public char checkChar(Object object, boolean asNode, CharAttribute a, char value)
    • getCharDefault

      public char getCharDefault(Object object, boolean asNode, CharAttribute a, char defaultValue)
      Returns the value of attribute a for object in this graph state. If no such value is defined, defaultValue is used instead. This method respects derived attributes and attribute values of instantiated objects which are set by setInstanceAttribute(Attribute, Object).
      Parameters:
      object - the object
      asNode - true if object is a node, false if object is an edge
      a - the attribute to read
      defaultValue - default value to return if the attribute is not defined on object
      Returns:
      value of the attribute for the object, or defaultValue
    • getChar

      public char getChar(Object object, boolean asNode, CharAttribute a)
      Returns the value of attribute a for object in this graph state. This method respects derived attributes and attribute values of instantiated objects which are set by setInstanceAttribute(Attribute, Object).
      Parameters:
      object - the object
      asNode - true if object is a node, false if object is an edge
      a - the attribute to read
      Returns:
      value of the attribute for the object
      Throws:
      NoSuchKeyException - if the attribute is not defined for the object
    • checkInt

      public int checkInt(Object object, boolean asNode, IntAttribute a, int value)
    • getIntDefault

      public int getIntDefault(Object object, boolean asNode, IntAttribute a, int defaultValue)
      Returns the value of attribute a for object in this graph state. If no such value is defined, defaultValue is used instead. This method respects derived attributes and attribute values of instantiated objects which are set by setInstanceAttribute(Attribute, Object).
      Parameters:
      object - the object
      asNode - true if object is a node, false if object is an edge
      a - the attribute to read
      defaultValue - default value to return if the attribute is not defined on object
      Returns:
      value of the attribute for the object, or defaultValue
    • getInt

      public int getInt(Object object, boolean asNode, IntAttribute a)
      Returns the value of attribute a for object in this graph state. This method respects derived attributes and attribute values of instantiated objects which are set by setInstanceAttribute(Attribute, Object).
      Parameters:
      object - the object
      asNode - true if object is a node, false if object is an edge
      a - the attribute to read
      Returns:
      value of the attribute for the object
      Throws:
      NoSuchKeyException - if the attribute is not defined for the object
    • checkLong

      public long checkLong(Object object, boolean asNode, LongAttribute a, long value)
    • getLongDefault

      public long getLongDefault(Object object, boolean asNode, LongAttribute a, long defaultValue)
      Returns the value of attribute a for object in this graph state. If no such value is defined, defaultValue is used instead. This method respects derived attributes and attribute values of instantiated objects which are set by setInstanceAttribute(Attribute, Object).
      Parameters:
      object - the object
      asNode - true if object is a node, false if object is an edge
      a - the attribute to read
      defaultValue - default value to return if the attribute is not defined on object
      Returns:
      value of the attribute for the object, or defaultValue
    • getLong

      public long getLong(Object object, boolean asNode, LongAttribute a)
      Returns the value of attribute a for object in this graph state. This method respects derived attributes and attribute values of instantiated objects which are set by setInstanceAttribute(Attribute, Object).
      Parameters:
      object - the object
      asNode - true if object is a node, false if object is an edge
      a - the attribute to read
      Returns:
      value of the attribute for the object
      Throws:
      NoSuchKeyException - if the attribute is not defined for the object
    • checkFloat

      public float checkFloat(Object object, boolean asNode, FloatAttribute a, float value)
    • getFloatDefault

      public float getFloatDefault(Object object, boolean asNode, FloatAttribute a, float defaultValue)
      Returns the value of attribute a for object in this graph state. If no such value is defined, defaultValue is used instead. This method respects derived attributes and attribute values of instantiated objects which are set by setInstanceAttribute(Attribute, Object).
      Parameters:
      object - the object
      asNode - true if object is a node, false if object is an edge
      a - the attribute to read
      defaultValue - default value to return if the attribute is not defined on object
      Returns:
      value of the attribute for the object, or defaultValue
    • getFloat

      public float getFloat(Object object, boolean asNode, FloatAttribute a)
      Returns the value of attribute a for object in this graph state. This method respects derived attributes and attribute values of instantiated objects which are set by setInstanceAttribute(Attribute, Object).
      Parameters:
      object - the object
      asNode - true if object is a node, false if object is an edge
      a - the attribute to read
      Returns:
      value of the attribute for the object
      Throws:
      NoSuchKeyException - if the attribute is not defined for the object
    • checkDouble

      public double checkDouble(Object object, boolean asNode, DoubleAttribute a, double value)
    • getDoubleDefault

      public double getDoubleDefault(Object object, boolean asNode, DoubleAttribute a, double defaultValue)
      Returns the value of attribute a for object in this graph state. If no such value is defined, defaultValue is used instead. This method respects derived attributes and attribute values of instantiated objects which are set by setInstanceAttribute(Attribute, Object).
      Parameters:
      object - the object
      asNode - true if object is a node, false if object is an edge
      a - the attribute to read
      defaultValue - default value to return if the attribute is not defined on object
      Returns:
      value of the attribute for the object, or defaultValue
    • getDouble

      public double getDouble(Object object, boolean asNode, DoubleAttribute a)
      Returns the value of attribute a for object in this graph state. This method respects derived attributes and attribute values of instantiated objects which are set by setInstanceAttribute(Attribute, Object).
      Parameters:
      object - the object
      asNode - true if object is a node, false if object is an edge
      a - the attribute to read
      Returns:
      value of the attribute for the object
      Throws:
      NoSuchKeyException - if the attribute is not defined for the object
    • checkObject

      public <T> T checkObject(Object object, boolean asNode, ObjectAttribute<? extends T> a, T value)
    • getObjectDefault

      public <T> T getObjectDefault(Object object, boolean asNode, ObjectAttribute<? extends T> a, T defaultValue)
      Returns the value of attribute a for object in this graph state. If no such value is defined, defaultValue is used instead. This method respects derived attributes and attribute values of instantiated objects which are set by setInstanceAttribute(Attribute, Object).
      Parameters:
      object - the object
      asNode - true if object is a node, false if object is an edge
      a - the attribute to read
      defaultValue - default value to return if the attribute is not defined on object
      Returns:
      value of the attribute for the object, or defaultValue
    • getObject

      public <T> T getObject(Object object, boolean asNode, T placeIn, ObjectAttribute<T> a)
      Returns the value of attribute a for object in this graph state. This method respects derived attributes and attribute values of instantiated objects which are set by setInstanceAttribute(Attribute, Object).
      Parameters:
      object - the object
      asNode - true if object is a node, false if object is an edge
      a - the attribute to read
      placeIn - an instance for the result may be provided by the caller
      Returns:
      value of the attribute for the object
      Throws:
      NoSuchKeyException - if the attribute is not defined for the object