public class AlgorithmState extends Serializer implements AlgorithmStateAttachment
Serializer.addInt(String, int)
/addSet(String, Set)
/...) to store the variables
that are used in the algorithm.Integer
, Float
,
Set
s, Matrix
s, WalkByID
s and so on.
Serializer.getInt(String, int)
/getSet(String, Set)
/...) and
assign the data to the algorithm variables.data
Constructor and Description |
---|
AlgorithmState(AlgorithmPlugin plugin,
int stepID)
Creates a new state.
|
Modifier and Type | Method and Description |
---|---|
<T> T |
addAttachment(java.lang.String key,
T attachment)
Attaches an object to the algorithm state.
|
<K extends java.io.Serializable,V extends java.io.Serializable> |
addMap(java.lang.String key,
java.util.Map<K,V> map)
Adds a map to the state.
|
<E extends Edge> |
addMatching(java.lang.String key,
MatchingByID<E> m)
Adds a matching to the state.
|
<E extends java.io.Serializable> |
addMatrix(java.lang.String key,
Matrix<E> matrix)
Adds a matrix to the state.
|
<V extends Vertex> |
addPath(java.lang.String key,
PathByID<V> p)
Adds a path to the state.
|
<E extends java.io.Serializable> |
addSet(java.lang.String key,
Set<E> set)
Adds a (mathematical) set to the state.
|
<V extends Vertex> |
addTrail(java.lang.String key,
TrailByID<V> t)
Adds a trail to the state.
|
<V extends Vertex> |
addWalk(java.lang.String key,
WalkByID<V> w)
Adds a walk to the state.
|
protected java.io.ObjectInputStream |
createObjectInputStream(java.io.ByteArrayInputStream bais)
Creates the object input stream that is used to unfreeze the data of the serializer.
|
boolean |
equals(AlgorithmState s)
Compares the specified state with this state and returns
true if the specified state
has the same step id and the same data (mapping of data key <-> data value) as this state. |
boolean |
equals(Serializer s)
Compares the specified serializer with this serializer and returns
true if the specified serializer
serializes the same data (mapping of data key <-> data value) as this serializer. |
<T> T |
getAttachment(java.lang.String key)
Gets an attachment of the algorithm state.
|
<T> T |
getAttachment(java.lang.String key,
T defValue)
Gets an attachment of the algorithm state.
|
<K,V> java.util.Map<K,V> |
getMap(java.lang.String key)
Gets a map for a given data key.
|
<K,V> java.util.Map<K,V> |
getMap(java.lang.String key,
java.util.Map<K,V> defValue)
Gets a map for a given data key.
|
<V extends Vertex,E extends Edge> |
getMatching(java.lang.String key,
Graph<V,E> graph)
Gets a matching for a given data key.
|
<V extends Vertex,E extends Edge> |
getMatching(java.lang.String key,
Graph<V,E> graph,
MatchingByID<E> defValue)
Gets a matching for a given data key.
|
<E extends java.io.Serializable> |
getMatrix(java.lang.String key)
Gets a matrix for a given data key.
|
<E extends java.io.Serializable> |
getMatrix(java.lang.String key,
Matrix<E> defValue)
Gets a matrix for a given data key.
|
<V extends Vertex,E extends Edge> |
getPath(java.lang.String key,
Graph<V,E> graph)
Gets a path for a given data key.
|
<V extends Vertex,E extends Edge> |
getPath(java.lang.String key,
Graph<V,E> graph,
PathByID<V> defValue)
Gets a path for a given data key.
|
<V extends Vertex,E extends Edge> |
getScene(java.lang.String key,
GraphScene<V,E> defValue)
Gets a scene for a given data key.
|
<E extends java.io.Serializable> |
getSet(java.lang.String key)
Gets a (mathematical) set for a given data key.
|
<E extends java.io.Serializable> |
getSet(java.lang.String key,
Set<E> defValue)
Gets a (mathematical) set for a given data key.
|
int |
getStepID()
Gets the id of the step whose state is stored.
|
<V extends Vertex,E extends Edge> |
getTrail(java.lang.String key,
Graph<V,E> graph)
Gets a trail for a given data key.
|
<V extends Vertex,E extends Edge> |
getTrail(java.lang.String key,
Graph<V,E> graph,
TrailByID<V> defValue)
Gets a trail for a given data key.
|
<V extends Vertex,E extends Edge> |
getWalk(java.lang.String key,
Graph<V,E> graph)
Gets a walk for a given data key.
|
<V extends Vertex,E extends Edge> |
getWalk(java.lang.String key,
Graph<V,E> graph,
WalkByID<V> defValue)
Gets a walk for a given data key.
|
addArray, addBoolean, addChar, addCollection, addData, addDouble, addFloat, addInt, addList, addObject, addSerializer, addString, areKeysOverrideable, checkKey, createObjectOutputStream, equals, freezeData, freezeData, getArray, getArray, getBoolean, getBoolean, getChar, getChar, getCollection, getCollection, getData, getData, getDouble, getDouble, getFloat, getFloat, getID, getInt, getInt, getList, getList, getName, getObject, getObject, getSerializer, getString, getString, keys, removeData, unfreezeData, unfreezeData
public AlgorithmState(AlgorithmPlugin plugin, int stepID) throws java.lang.IllegalArgumentException
stepID
- the id of the step whose state is storedjava.lang.IllegalArgumentException
- public final int getStepID()
public final <E extends java.io.Serializable> Set<E> addSet(java.lang.String key, Set<E> set) throws java.lang.IllegalArgumentException
key
- the data keyset
- the setjava.lang.IllegalArgumentException
- public final <E extends java.io.Serializable> Set<E> getSet(java.lang.String key)
key
- the data keynull
if the state does not contain a set with the given key and typepublic final <E extends java.io.Serializable> Set<E> getSet(java.lang.String key, Set<E> defValue)
key
- the data keydefValue
- the default return valuepublic final <E extends java.io.Serializable> Matrix<E> addMatrix(java.lang.String key, Matrix<E> matrix) throws java.lang.IllegalArgumentException
key
- the data keymatrix
- the matrixjava.lang.IllegalArgumentException
- public final <E extends java.io.Serializable> Matrix<E> getMatrix(java.lang.String key)
key
- the data keynull
if the state does not contain a matrix with the given key and typepublic final <E extends java.io.Serializable> Matrix<E> getMatrix(java.lang.String key, Matrix<E> defValue)
key
- the data keydefValue
- the default return valuepublic final <K extends java.io.Serializable,V extends java.io.Serializable> java.util.Map<K,V> addMap(java.lang.String key, java.util.Map<K,V> map) throws java.lang.IllegalArgumentException
key
- the data keymap
- the mapjava.lang.IllegalArgumentException
- public final <K,V> java.util.Map<K,V> getMap(java.lang.String key)
key
- the data keynull
if the state does not contain a map with the given key and typepublic final <K,V> java.util.Map<K,V> getMap(java.lang.String key, java.util.Map<K,V> defValue)
key
- the data keydefValue
- the default return valuepublic final <E extends Edge> MatchingByID<E> addMatching(java.lang.String key, MatchingByID<E> m) throws java.lang.IllegalArgumentException
key
- the data keym
- the matchingjava.lang.IllegalArgumentException
- public final <V extends Vertex,E extends Edge> MatchingByID<E> getMatching(java.lang.String key, Graph<V,E> graph) throws java.lang.IllegalArgumentException
key
- the data keygraph
- the graph its edges can be part of the matching (ensure that this is the one the matching uses when it was added to the state)null
if the state does not contain a matching with the given key and typejava.lang.IllegalArgumentException
- public final <V extends Vertex,E extends Edge> MatchingByID<E> getMatching(java.lang.String key, Graph<V,E> graph, MatchingByID<E> defValue) throws java.lang.IllegalArgumentException
key
- the data keygraph
- the graph its edges can be part of the matching (ensure that this is the one the matching uses when it was added to the state)defValue
- the default return valuejava.lang.IllegalArgumentException
- public final <V extends Vertex> WalkByID<V> addWalk(java.lang.String key, WalkByID<V> w) throws java.lang.IllegalArgumentException
key
- the data keyw
- the walkjava.lang.IllegalArgumentException
- public final <V extends Vertex,E extends Edge> WalkByID<V> getWalk(java.lang.String key, Graph<V,E> graph) throws java.lang.IllegalArgumentException
key
- the data keygraph
- the graph its edges can be part of the walk (ensure that this is the one the walk uses when it was added to the state)null
if the state does not contain a walk with the given key and typejava.lang.IllegalArgumentException
- public final <V extends Vertex,E extends Edge> WalkByID<V> getWalk(java.lang.String key, Graph<V,E> graph, WalkByID<V> defValue) throws java.lang.IllegalArgumentException
key
- the data keygraph
- the graph its edges can be part of the walk (ensure that this is the one the walk uses when it was added to the state)defValue
- the default return valuejava.lang.IllegalArgumentException
- public final <V extends Vertex> PathByID<V> addPath(java.lang.String key, PathByID<V> p) throws java.lang.IllegalArgumentException
key
- the data keyp
- the pathjava.lang.IllegalArgumentException
- public final <V extends Vertex,E extends Edge> PathByID<V> getPath(java.lang.String key, Graph<V,E> graph) throws java.lang.IllegalArgumentException
key
- the data keygraph
- the graph its edges can be part of the path (ensure that this is the one the path uses when it was added to the state)null
if the state does not contain a path with the given key and typejava.lang.IllegalArgumentException
- public final <V extends Vertex,E extends Edge> PathByID<V> getPath(java.lang.String key, Graph<V,E> graph, PathByID<V> defValue) throws java.lang.IllegalArgumentException
key
- the data keygraph
- the graph its edges can be part of the path (ensure that this is the one the path uses when it was added to the state)defValue
- the default return valuejava.lang.IllegalArgumentException
- public final <V extends Vertex> TrailByID<V> addTrail(java.lang.String key, TrailByID<V> t) throws java.lang.IllegalArgumentException
key
- the data keyt
- the trailjava.lang.IllegalArgumentException
- public final <V extends Vertex,E extends Edge> TrailByID<V> getTrail(java.lang.String key, Graph<V,E> graph) throws java.lang.IllegalArgumentException
key
- the data keygraph
- the graph its edges can be part of the trail (ensure that this is the one the trail uses when it was added to the state)null
if the state does not contain a trail with the given key and typejava.lang.IllegalArgumentException
- public final <V extends Vertex,E extends Edge> TrailByID<V> getTrail(java.lang.String key, Graph<V,E> graph, TrailByID<V> defValue) throws java.lang.IllegalArgumentException
key
- the data keygraph
- the graph its edges can be part of the trail (ensure that this is the one the trail uses when it was added to the state)defValue
- the default return valuejava.lang.IllegalArgumentException
- public <T> T addAttachment(java.lang.String key, T attachment) throws java.lang.IllegalArgumentException
AlgorithmState
is a mutable object storage meaning that changes to the object after the
object was added to the state cannot be made undone.addAttachment
in interface AlgorithmStateAttachment
key
- the keyattachment
- the object to attachjava.lang.IllegalArgumentException
- public <T> T getAttachment(java.lang.String key)
getAttachment
in interface AlgorithmStateAttachment
key
- the keynull
if the state does not contain an attachment with the given key and typepublic <T> T getAttachment(java.lang.String key, T defValue)
getAttachment
in interface AlgorithmStateAttachment
key
- key the keydefValue
- the default return valuepublic final <V extends Vertex,E extends Edge> GraphScene<V,E> getScene(java.lang.String key, GraphScene<V,E> defValue)
GraphScene.reverse()
to reverse a graph scene meaning to restore the visual appearance of a graph before the scene was recorded.key
- the data keydefValue
- the default return valuepublic boolean equals(Serializer s)
Serializer
true
if the specified serializer
serializes the same data (mapping of data key <-> data value) as this serializer.equals
in class Serializer
s
- the serializer that should be compared with this onetrue
if both are equal otherwise false
public boolean equals(AlgorithmState s)
true
if the specified state
has the same step id and the same data (mapping of data key <-> data value) as this state.s
- the state that should be compared with this onetrue
if both are equal otherwise false
protected java.io.ObjectInputStream createObjectInputStream(java.io.ByteArrayInputStream bais) throws java.io.IOException
Serializer
ObjectInputStream
.createObjectInputStream
in class Serializer
bais
- the byte array stream of the freezed datajava.io.IOException
-