de.grogra.graph
public abstract class GraphState extends java.lang.Object
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.Graph| Modifier and Type | Class and Description |
|---|---|
static class |
GraphState.ObjectContext
This class represents an object context.
|
| Modifier | Constructor and Description |
|---|---|
protected |
GraphState() |
| Modifier and Type | Method and Description |
|---|---|
static int |
allocatePropertyId() |
void |
beginInstancing(java.lang.Object refNode,
long id) |
boolean |
checkBoolean(java.lang.Object object,
boolean asNode,
BooleanAttribute a,
boolean value) |
byte |
checkByte(java.lang.Object object,
boolean asNode,
ByteAttribute a,
byte value) |
char |
checkChar(java.lang.Object object,
boolean asNode,
CharAttribute a,
char value) |
double |
checkDouble(java.lang.Object object,
boolean asNode,
DoubleAttribute a,
double value) |
float |
checkFloat(java.lang.Object object,
boolean asNode,
FloatAttribute a,
float value) |
int |
checkInt(java.lang.Object object,
boolean asNode,
IntAttribute a,
int value) |
long |
checkLong(java.lang.Object object,
boolean asNode,
LongAttribute a,
long value) |
<T> T |
checkObject(java.lang.Object object,
boolean asNode,
ObjectAttribute<? extends T> a,
T value) |
short |
checkShort(java.lang.Object object,
boolean asNode,
ShortAttribute a,
short value) |
abstract boolean |
containsInTree(java.lang.Object object,
boolean asNode)
Tests whether an object is contained in the tree of the graph.
|
protected abstract GraphState |
createDelegate(ThreadContext tc) |
GraphState.ObjectContext |
createObjectState(java.lang.Object object,
boolean asNode) |
static GraphState |
current(Graph graph)
Returns the graph state of the
graph which is
valid within the current thread. |
void |
deinstantiate() |
void |
dispose() |
void |
endInstancing() |
protected void |
finalize() |
abstract void |
fireAttributeChanged(java.lang.Object object,
boolean asNode,
Attribute a,
FieldChain field,
int[] indices) |
protected abstract void |
fireEdgeChanged(java.lang.Object source,
java.lang.Object target,
java.lang.Object edge) |
GraphState |
forContext(ThreadContext tc) |
static GraphState |
get(Graph graph,
ThreadContext tc)
Returns the graph state of the
graph which is
valid within the given ThreadContext. |
boolean |
getBoolean(java.lang.Object object,
boolean asNode,
BooleanAttribute a)
Returns the value of attribute
a for object
in this graph state. |
boolean |
getBooleanDefault(java.lang.Object object,
boolean asNode,
BooleanAttribute a,
boolean defaultValue)
Returns the value of attribute
a for object
in this graph state. |
byte |
getByte(java.lang.Object object,
boolean asNode,
ByteAttribute a)
Returns the value of attribute
a for object
in this graph state. |
byte |
getByteDefault(java.lang.Object object,
boolean asNode,
ByteAttribute a,
byte defaultValue)
Returns the value of attribute
a for object
in this graph state. |
char |
getChar(java.lang.Object object,
boolean asNode,
CharAttribute a)
Returns the value of attribute
a for object
in this graph state. |
char |
getCharDefault(java.lang.Object object,
boolean asNode,
CharAttribute a,
char defaultValue)
Returns the value of attribute
a for object
in this graph state. |
ThreadContext |
getContext()
Returns the
ThreadContext within which operations
on this graph state are valid. |
double |
getDouble(java.lang.Object object,
boolean asNode,
DoubleAttribute a)
Returns the value of attribute
a for object
in this graph state. |
double |
getDoubleDefault(java.lang.Object object,
boolean asNode,
DoubleAttribute a,
double defaultValue)
Returns the value of attribute
a for object
in this graph state. |
float |
getFloat(java.lang.Object object,
boolean asNode,
FloatAttribute a)
Returns the value of attribute
a for object
in this graph state. |
float |
getFloatDefault(java.lang.Object object,
boolean asNode,
FloatAttribute a,
float defaultValue)
Returns the value of attribute
a for object
in this graph state. |
Graph |
getGraph()
Returns the graph of this graph state.
|
Path |
getInstancingPath() |
int |
getInstancingPathIndex() |
int |
getInt(java.lang.Object object,
boolean asNode,
IntAttribute a)
Returns the value of attribute
a for object
in this graph state. |
int |
getIntDefault(java.lang.Object object,
boolean asNode,
IntAttribute a,
int defaultValue)
Returns the value of attribute
a for object
in this graph state. |
long |
getLong(java.lang.Object object,
boolean asNode,
LongAttribute a)
Returns the value of attribute
a for object
in this graph state. |
long |
getLongDefault(java.lang.Object object,
boolean asNode,
LongAttribute a,
long defaultValue)
Returns the value of attribute
a for object
in this graph state. |
<T> T |
getObject(java.lang.Object object,
boolean asNode,
ObjectAttribute<T> a) |
<T> T |
getObject(java.lang.Object object,
boolean asNode,
T placeIn,
ObjectAttribute<T> a)
Returns the value of attribute
a for object
in this graph state. |
GraphState.ObjectContext |
getObjectContext() |
<T> T |
getObjectDefault(java.lang.Object object,
boolean asNode,
ObjectAttribute<? extends T> a,
T defaultValue)
Returns the value of attribute
a for object
in this graph state. |
short |
getShort(java.lang.Object object,
boolean asNode,
ShortAttribute a)
Returns the value of attribute
a for object
in this graph state. |
short |
getShortDefault(java.lang.Object object,
boolean asNode,
ShortAttribute a,
short defaultValue)
Returns the value of attribute
a for object
in this graph state. |
java.lang.Object |
getUserProperty(int id) |
protected void |
initialize(Graph graph,
ThreadContext ctx) |
void |
instantiate(java.lang.Object object,
boolean asNode,
long id) |
void |
instantiateEdge(int edges,
boolean edgeDirection,
long id) |
void |
moveToInstance(int index) |
void |
moveToNextInstance() |
void |
moveToPreviousInstance() |
abstract void |
setEdgeBits(java.lang.Object edge,
int bits) |
void |
setInstanceAttribute(Attribute a,
java.lang.Object value) |
void |
setObjectContext(GraphState.ObjectContext newState) |
void |
setObjectContext(java.lang.Object object,
boolean asNode) |
java.lang.Object |
setUserProperty(int id,
java.lang.Object value) |
public static int allocatePropertyId()
public void beginInstancing(java.lang.Object refNode,
long id)
public boolean checkBoolean(java.lang.Object object,
boolean asNode,
BooleanAttribute a,
boolean value)
public byte checkByte(java.lang.Object object,
boolean asNode,
ByteAttribute a,
byte value)
public char checkChar(java.lang.Object object,
boolean asNode,
CharAttribute a,
char value)
public double checkDouble(java.lang.Object object,
boolean asNode,
DoubleAttribute a,
double value)
public float checkFloat(java.lang.Object object,
boolean asNode,
FloatAttribute a,
float value)
public int checkInt(java.lang.Object object,
boolean asNode,
IntAttribute a,
int value)
public long checkLong(java.lang.Object object,
boolean asNode,
LongAttribute a,
long value)
public <T> T checkObject(java.lang.Object object,
boolean asNode,
ObjectAttribute<? extends T> a,
T value)
public short checkShort(java.lang.Object object,
boolean asNode,
ShortAttribute a,
short value)
public abstract boolean containsInTree(java.lang.Object object,
boolean asNode)
Graph.getTreePattern().object - the objectasNode - true if object is a node,
false if object is an edgetrue iff the object is part of the treeprotected abstract GraphState createDelegate(ThreadContext tc)
public GraphState.ObjectContext createObjectState(java.lang.Object object, boolean asNode)
public static GraphState current(Graph graph)
graph which is
valid within the current thread.graph - a graphnull if such
a graph state has not yet been createdpublic void deinstantiate()
public void dispose()
public void endInstancing()
protected void finalize()
finalize in class java.lang.Objectpublic abstract void fireAttributeChanged(java.lang.Object object,
boolean asNode,
Attribute a,
FieldChain field,
int[] indices)
protected abstract void fireEdgeChanged(java.lang.Object source,
java.lang.Object target,
java.lang.Object edge)
public GraphState forContext(ThreadContext tc)
public static GraphState get(Graph graph, ThreadContext tc)
graph which is
valid within the given ThreadContext.graph - a graphtc - a thread contextnull if such
a graph state has not yet been createdpublic boolean getBoolean(java.lang.Object object,
boolean asNode,
BooleanAttribute a)
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).object - the objectasNode - true if object is a node,
false if object is an edgea - the attribute to readNoSuchKeyException - if the attribute is not defined for the objectpublic boolean getBooleanDefault(java.lang.Object object,
boolean asNode,
BooleanAttribute a,
boolean defaultValue)
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).object - the objectasNode - true if object is a node,
false if object is an edgea - the attribute to readdefaultValue - default value to return if the attribute is not defined
on objectdefaultValuepublic byte getByte(java.lang.Object object,
boolean asNode,
ByteAttribute a)
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).object - the objectasNode - true if object is a node,
false if object is an edgea - the attribute to readNoSuchKeyException - if the attribute is not defined for the objectpublic byte getByteDefault(java.lang.Object object,
boolean asNode,
ByteAttribute a,
byte defaultValue)
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).object - the objectasNode - true if object is a node,
false if object is an edgea - the attribute to readdefaultValue - default value to return if the attribute is not defined
on objectdefaultValuepublic char getChar(java.lang.Object object,
boolean asNode,
CharAttribute a)
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).object - the objectasNode - true if object is a node,
false if object is an edgea - the attribute to readNoSuchKeyException - if the attribute is not defined for the objectpublic char getCharDefault(java.lang.Object object,
boolean asNode,
CharAttribute a,
char defaultValue)
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).object - the objectasNode - true if object is a node,
false if object is an edgea - the attribute to readdefaultValue - default value to return if the attribute is not defined
on objectdefaultValuepublic final ThreadContext getContext()
ThreadContext within which operations
on this graph state are valid.ThreadContext of this graph statepublic double getDouble(java.lang.Object object,
boolean asNode,
DoubleAttribute a)
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).object - the objectasNode - true if object is a node,
false if object is an edgea - the attribute to readNoSuchKeyException - if the attribute is not defined for the objectpublic double getDoubleDefault(java.lang.Object object,
boolean asNode,
DoubleAttribute a,
double defaultValue)
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).object - the objectasNode - true if object is a node,
false if object is an edgea - the attribute to readdefaultValue - default value to return if the attribute is not defined
on objectdefaultValuepublic float getFloat(java.lang.Object object,
boolean asNode,
FloatAttribute a)
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).object - the objectasNode - true if object is a node,
false if object is an edgea - the attribute to readNoSuchKeyException - if the attribute is not defined for the objectpublic float getFloatDefault(java.lang.Object object,
boolean asNode,
FloatAttribute a,
float defaultValue)
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).object - the objectasNode - true if object is a node,
false if object is an edgea - the attribute to readdefaultValue - default value to return if the attribute is not defined
on objectdefaultValuepublic final Graph getGraph()
public Path getInstancingPath()
public int getInstancingPathIndex()
public int getInt(java.lang.Object object,
boolean asNode,
IntAttribute a)
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).object - the objectasNode - true if object is a node,
false if object is an edgea - the attribute to readNoSuchKeyException - if the attribute is not defined for the objectpublic int getIntDefault(java.lang.Object object,
boolean asNode,
IntAttribute a,
int defaultValue)
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).object - the objectasNode - true if object is a node,
false if object is an edgea - the attribute to readdefaultValue - default value to return if the attribute is not defined
on objectdefaultValuepublic long getLong(java.lang.Object object,
boolean asNode,
LongAttribute a)
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).object - the objectasNode - true if object is a node,
false if object is an edgea - the attribute to readNoSuchKeyException - if the attribute is not defined for the objectpublic long getLongDefault(java.lang.Object object,
boolean asNode,
LongAttribute a,
long defaultValue)
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).object - the objectasNode - true if object is a node,
false if object is an edgea - the attribute to readdefaultValue - default value to return if the attribute is not defined
on objectdefaultValuepublic <T> T getObject(java.lang.Object object,
boolean asNode,
ObjectAttribute<T> a)
public <T> T getObject(java.lang.Object object,
boolean asNode,
T placeIn,
ObjectAttribute<T> a)
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).object - the objectasNode - true if object is a node,
false if object is an edgea - the attribute to readplaceIn - an instance for the result may be provided by the callerNoSuchKeyException - if the attribute is not defined for the objectpublic GraphState.ObjectContext getObjectContext()
public <T> T getObjectDefault(java.lang.Object object,
boolean asNode,
ObjectAttribute<? extends T> a,
T defaultValue)
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).object - the objectasNode - true if object is a node,
false if object is an edgea - the attribute to readdefaultValue - default value to return if the attribute is not defined
on objectdefaultValuepublic short getShort(java.lang.Object object,
boolean asNode,
ShortAttribute a)
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).object - the objectasNode - true if object is a node,
false if object is an edgea - the attribute to readNoSuchKeyException - if the attribute is not defined for the objectpublic short getShortDefault(java.lang.Object object,
boolean asNode,
ShortAttribute a,
short defaultValue)
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).object - the objectasNode - true if object is a node,
false if object is an edgea - the attribute to readdefaultValue - default value to return if the attribute is not defined
on objectdefaultValuepublic java.lang.Object getUserProperty(int id)
protected void initialize(Graph graph, ThreadContext ctx)
public void instantiate(java.lang.Object object,
boolean asNode,
long id)
public void instantiateEdge(int edges,
boolean edgeDirection,
long id)
public void moveToInstance(int index)
public void moveToNextInstance()
public void moveToPreviousInstance()
public abstract void setEdgeBits(java.lang.Object edge,
int bits)
public void setInstanceAttribute(Attribute a, java.lang.Object value)
public void setObjectContext(GraphState.ObjectContext newState)
public void setObjectContext(java.lang.Object object,
boolean asNode)
public java.lang.Object setUserProperty(int id,
java.lang.Object value)