java.lang.Object
de.grogra.graph.GraphState
- Direct Known Subclasses:
DelegateGraphState
,GraphBase.State
,State
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
This class represents an object context. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
void
beginInstancing
(Object refNode, long id) boolean
checkBoolean
(Object object, boolean asNode, BooleanAttribute a, boolean value) byte
checkByte
(Object object, boolean asNode, ByteAttribute a, byte value) char
checkChar
(Object object, boolean asNode, CharAttribute a, char value) double
checkDouble
(Object object, boolean asNode, DoubleAttribute a, double value) float
checkFloat
(Object object, boolean asNode, FloatAttribute a, float value) int
checkInt
(Object object, boolean asNode, IntAttribute a, int value) long
checkLong
(Object object, boolean asNode, LongAttribute a, long value) <T> T
checkObject
(Object object, boolean asNode, ObjectAttribute<? extends T> a, T value) short
checkShort
(Object object, boolean asNode, ShortAttribute a, short value) abstract boolean
containsInTree
(Object object, boolean asNode) Tests whether an object is contained in the tree of the graph.protected abstract GraphState
createObjectState
(Object object, boolean asNode) static GraphState
Returns the graph state of thegraph
which is valid within the current thread.void
void
dispose()
void
protected void
finalize()
abstract void
fireAttributeChanged
(Object object, boolean asNode, Attribute a, FieldChain field, int[] indices) protected abstract void
fireEdgeChanged
(Object source, Object target, Object edge) static GraphState
get
(Graph graph, ThreadContext tc) Returns the graph state of thegraph
which is valid within the givenThreadContext
.boolean
getBoolean
(Object object, boolean asNode, BooleanAttribute a) Returns the value of attributea
forobject
in this graph state.boolean
getBooleanDefault
(Object object, boolean asNode, BooleanAttribute a, boolean defaultValue) Returns the value of attributea
forobject
in this graph state.byte
getByte
(Object object, boolean asNode, ByteAttribute a) Returns the value of attributea
forobject
in this graph state.byte
getByteDefault
(Object object, boolean asNode, ByteAttribute a, byte defaultValue) Returns the value of attributea
forobject
in this graph state.char
getChar
(Object object, boolean asNode, CharAttribute a) Returns the value of attributea
forobject
in this graph state.char
getCharDefault
(Object object, boolean asNode, CharAttribute a, char defaultValue) Returns the value of attributea
forobject
in this graph state.final ThreadContext
Returns theThreadContext
within which operations on this graph state are valid.double
getDouble
(Object object, boolean asNode, DoubleAttribute a) Returns the value of attributea
forobject
in this graph state.double
getDoubleDefault
(Object object, boolean asNode, DoubleAttribute a, double defaultValue) Returns the value of attributea
forobject
in this graph state.float
getFloat
(Object object, boolean asNode, FloatAttribute a) Returns the value of attributea
forobject
in this graph state.float
getFloatDefault
(Object object, boolean asNode, FloatAttribute a, float defaultValue) Returns the value of attributea
forobject
in this graph state.final Graph
getGraph()
Returns the graph of this graph state.int
int
getInt
(Object object, boolean asNode, IntAttribute a) Returns the value of attributea
forobject
in this graph state.int
getIntDefault
(Object object, boolean asNode, IntAttribute a, int defaultValue) Returns the value of attributea
forobject
in this graph state.long
getLong
(Object object, boolean asNode, LongAttribute a) Returns the value of attributea
forobject
in this graph state.long
getLongDefault
(Object object, boolean asNode, LongAttribute a, long defaultValue) Returns the value of attributea
forobject
in this graph state.<T> T
getObject
(Object object, boolean asNode, ObjectAttribute<T> a) <T> T
getObject
(Object object, boolean asNode, T placeIn, ObjectAttribute<T> a) Returns the value of attributea
forobject
in this graph state.<T> T
getObjectDefault
(Object object, boolean asNode, ObjectAttribute<? extends T> a, T defaultValue) Returns the value of attributea
forobject
in this graph state.short
getShort
(Object object, boolean asNode, ShortAttribute a) Returns the value of attributea
forobject
in this graph state.short
getShortDefault
(Object object, boolean asNode, ShortAttribute a, short defaultValue) Returns the value of attributea
forobject
in this graph state.getUserProperty
(int id) protected void
initialize
(Graph graph, ThreadContext ctx) void
instantiate
(Object object, boolean asNode, long id) void
instantiateEdge
(int edges, boolean edgeDirection, long id) void
moveToInstance
(int index) void
void
abstract void
setEdgeBits
(Object edge, int bits) void
setInstanceAttribute
(Attribute a, Object value) void
setObjectContext
(GraphState.ObjectContext newState) void
setObjectContext
(Object object, boolean asNode) setUserProperty
(int id, Object value)
-
Constructor Details
-
GraphState
protected GraphState()
-
-
Method Details
-
allocatePropertyId
public static int allocatePropertyId() -
initialize
-
dispose
public void dispose() -
finalize
protected void finalize() -
setUserProperty
-
getUserProperty
-
forContext
-
createDelegate
-
get
Returns the graph state of thegraph
which is valid within the givenThreadContext
.- Parameters:
graph
- a graphtc
- a thread context- Returns:
- the graph state for the context, or
null
if such a graph state has not yet been created
-
current
Returns the graph state of thegraph
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
Returns the graph of this graph state.- Returns:
- graph of this state
-
getContext
Returns theThreadContext
within which operations on this graph state are valid.- Returns:
ThreadContext
of this graph state
-
setObjectContext
-
getObjectContext
-
setObjectContext
-
createObjectState
-
setEdgeBits
-
fireAttributeChanged
public abstract void fireAttributeChanged(Object object, boolean asNode, Attribute a, FieldChain field, int[] indices) -
fireEdgeChanged
-
containsInTree
Tests whether an object is contained in the tree of the graph. The tree is defined byGraph.getTreePattern()
.- Parameters:
object
- the objectasNode
-true
ifobject
is a node,false
ifobject
is an edge- Returns:
true
iff the object is part of the tree
-
getInstancingPath
-
getInstancingPathIndex
public int getInstancingPathIndex() -
beginInstancing
-
endInstancing
public void endInstancing() -
instantiate
-
instantiateEdge
public void instantiateEdge(int edges, boolean edgeDirection, long id) -
deinstantiate
public void deinstantiate() -
setInstanceAttribute
-
moveToPreviousInstance
public void moveToPreviousInstance() -
moveToNextInstance
public void moveToNextInstance() -
moveToInstance
public void moveToInstance(int index) -
getObject
-
checkBoolean
-
getBooleanDefault
public boolean getBooleanDefault(Object object, boolean asNode, BooleanAttribute a, boolean defaultValue) Returns the value of attributea
forobject
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 bysetInstanceAttribute(Attribute, Object)
.- Parameters:
object
- the objectasNode
-true
ifobject
is a node,false
ifobject
is an edgea
- the attribute to readdefaultValue
- default value to return if the attribute is not defined onobject
- Returns:
- value of the attribute for the object, or
defaultValue
-
getBoolean
Returns the value of attributea
forobject
in this graph state. This method respects derived attributes and attribute values of instantiated objects which are set bysetInstanceAttribute(Attribute, Object)
.- Parameters:
object
- the objectasNode
-true
ifobject
is a node,false
ifobject
is an edgea
- the attribute to read- Returns:
- value of the attribute for the object
- Throws:
NoSuchKeyException
- if the attribute is not defined for the object
-
checkByte
-
getByteDefault
Returns the value of attributea
forobject
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 bysetInstanceAttribute(Attribute, Object)
.- Parameters:
object
- the objectasNode
-true
ifobject
is a node,false
ifobject
is an edgea
- the attribute to readdefaultValue
- default value to return if the attribute is not defined onobject
- Returns:
- value of the attribute for the object, or
defaultValue
-
getByte
Returns the value of attributea
forobject
in this graph state. This method respects derived attributes and attribute values of instantiated objects which are set bysetInstanceAttribute(Attribute, Object)
.- Parameters:
object
- the objectasNode
-true
ifobject
is a node,false
ifobject
is an edgea
- the attribute to read- Returns:
- value of the attribute for the object
- Throws:
NoSuchKeyException
- if the attribute is not defined for the object
-
checkShort
-
getShortDefault
Returns the value of attributea
forobject
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 bysetInstanceAttribute(Attribute, Object)
.- Parameters:
object
- the objectasNode
-true
ifobject
is a node,false
ifobject
is an edgea
- the attribute to readdefaultValue
- default value to return if the attribute is not defined onobject
- Returns:
- value of the attribute for the object, or
defaultValue
-
getShort
Returns the value of attributea
forobject
in this graph state. This method respects derived attributes and attribute values of instantiated objects which are set bysetInstanceAttribute(Attribute, Object)
.- Parameters:
object
- the objectasNode
-true
ifobject
is a node,false
ifobject
is an edgea
- the attribute to read- Returns:
- value of the attribute for the object
- Throws:
NoSuchKeyException
- if the attribute is not defined for the object
-
checkChar
-
getCharDefault
Returns the value of attributea
forobject
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 bysetInstanceAttribute(Attribute, Object)
.- Parameters:
object
- the objectasNode
-true
ifobject
is a node,false
ifobject
is an edgea
- the attribute to readdefaultValue
- default value to return if the attribute is not defined onobject
- Returns:
- value of the attribute for the object, or
defaultValue
-
getChar
Returns the value of attributea
forobject
in this graph state. This method respects derived attributes and attribute values of instantiated objects which are set bysetInstanceAttribute(Attribute, Object)
.- Parameters:
object
- the objectasNode
-true
ifobject
is a node,false
ifobject
is an edgea
- the attribute to read- Returns:
- value of the attribute for the object
- Throws:
NoSuchKeyException
- if the attribute is not defined for the object
-
checkInt
-
getIntDefault
Returns the value of attributea
forobject
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 bysetInstanceAttribute(Attribute, Object)
.- Parameters:
object
- the objectasNode
-true
ifobject
is a node,false
ifobject
is an edgea
- the attribute to readdefaultValue
- default value to return if the attribute is not defined onobject
- Returns:
- value of the attribute for the object, or
defaultValue
-
getInt
Returns the value of attributea
forobject
in this graph state. This method respects derived attributes and attribute values of instantiated objects which are set bysetInstanceAttribute(Attribute, Object)
.- Parameters:
object
- the objectasNode
-true
ifobject
is a node,false
ifobject
is an edgea
- the attribute to read- Returns:
- value of the attribute for the object
- Throws:
NoSuchKeyException
- if the attribute is not defined for the object
-
checkLong
-
getLongDefault
Returns the value of attributea
forobject
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 bysetInstanceAttribute(Attribute, Object)
.- Parameters:
object
- the objectasNode
-true
ifobject
is a node,false
ifobject
is an edgea
- the attribute to readdefaultValue
- default value to return if the attribute is not defined onobject
- Returns:
- value of the attribute for the object, or
defaultValue
-
getLong
Returns the value of attributea
forobject
in this graph state. This method respects derived attributes and attribute values of instantiated objects which are set bysetInstanceAttribute(Attribute, Object)
.- Parameters:
object
- the objectasNode
-true
ifobject
is a node,false
ifobject
is an edgea
- the attribute to read- Returns:
- value of the attribute for the object
- Throws:
NoSuchKeyException
- if the attribute is not defined for the object
-
checkFloat
-
getFloatDefault
Returns the value of attributea
forobject
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 bysetInstanceAttribute(Attribute, Object)
.- Parameters:
object
- the objectasNode
-true
ifobject
is a node,false
ifobject
is an edgea
- the attribute to readdefaultValue
- default value to return if the attribute is not defined onobject
- Returns:
- value of the attribute for the object, or
defaultValue
-
getFloat
Returns the value of attributea
forobject
in this graph state. This method respects derived attributes and attribute values of instantiated objects which are set bysetInstanceAttribute(Attribute, Object)
.- Parameters:
object
- the objectasNode
-true
ifobject
is a node,false
ifobject
is an edgea
- the attribute to read- Returns:
- value of the attribute for the object
- Throws:
NoSuchKeyException
- if the attribute is not defined for the object
-
checkDouble
-
getDoubleDefault
public double getDoubleDefault(Object object, boolean asNode, DoubleAttribute a, double defaultValue) Returns the value of attributea
forobject
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 bysetInstanceAttribute(Attribute, Object)
.- Parameters:
object
- the objectasNode
-true
ifobject
is a node,false
ifobject
is an edgea
- the attribute to readdefaultValue
- default value to return if the attribute is not defined onobject
- Returns:
- value of the attribute for the object, or
defaultValue
-
getDouble
Returns the value of attributea
forobject
in this graph state. This method respects derived attributes and attribute values of instantiated objects which are set bysetInstanceAttribute(Attribute, Object)
.- Parameters:
object
- the objectasNode
-true
ifobject
is a node,false
ifobject
is an edgea
- the attribute to read- Returns:
- value of the attribute for the object
- Throws:
NoSuchKeyException
- if the attribute is not defined for the object
-
checkObject
-
getObjectDefault
public <T> T getObjectDefault(Object object, boolean asNode, ObjectAttribute<? extends T> a, T defaultValue) Returns the value of attributea
forobject
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 bysetInstanceAttribute(Attribute, Object)
.- Parameters:
object
- the objectasNode
-true
ifobject
is a node,false
ifobject
is an edgea
- the attribute to readdefaultValue
- default value to return if the attribute is not defined onobject
- Returns:
- value of the attribute for the object, or
defaultValue
-
getObject
Returns the value of attributea
forobject
in this graph state. This method respects derived attributes and attribute values of instantiated objects which are set bysetInstanceAttribute(Attribute, Object)
.- Parameters:
object
- the objectasNode
-true
ifobject
is a node,false
ifobject
is an edgea
- the attribute to readplaceIn
- 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
-