|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface TimelineIndex
A utility for ordering nodes in a timeline. You add nodes to the timeline and
then you can query for nodes given a time period, w/ or w/o lower/upper
bounds, for example "Give me all nodes before this given timestamp" or
"Give me all nodes between these two timestamps".
Please note that the timestamps don't need to represent actual points in
time, any long
that identifies the indexed Node
and
defines its global order is fine.
Method Summary | |
---|---|
void |
addNode(Node nodeToAdd,
long timestamp)
Adds a node to this timeline with the given timestamp . |
void |
delete()
Deletes this timeline. |
Iterable<Node> |
getAllNodes()
Returns all added nodes in this timeline ordered by increasing timestamp. |
Iterable<Node> |
getAllNodes(Long startTimestampOrNull,
Long endTimestampOrNull)
Convenience method which you can use getAllNodes() ,
getAllNodesAfter(long) , getAllNodesBefore(long) and
getAllNodesBetween(long, long) in a single method. |
Iterable<Node> |
getAllNodesAfter(long timestamp)
Returns all the nodes after (exclusive) timestamp ordered by
increasing timestamp. |
Iterable<Node> |
getAllNodesBefore(long timestamp)
Returns all the nodes before (exclusive) timestamp ordered by
increasing timestamp. |
Iterable<Node> |
getAllNodesBetween(long startTimestamp,
long endTimestamp)
Returns all the nodes after (exclusive) afterTimestamp and before
(exclusive) beforeTimestamp ordered by increasing timestamp. |
Node |
getFirstNode()
Returns the first node in the timeline, that is the node with the lowest timestamp or null if there's no nodes in the timeline. |
Node |
getLastNode()
Returns the last node in the timeline, that is the node with the highest timestamp or null if there's no nodes in the timeline. |
Iterable<Node> |
getNodes(long timestamp)
Returns nodes which were added with the given timestamp . |
long |
getTimestampForNode(Node node)
Will return the timestamp for node if it has been added to this
timeline. |
void |
removeNode(Node nodeToRemove)
Removes a node from the timeline. |
Method Detail |
---|
Node getLastNode()
null
if there's no nodes in the timeline.
null
if timeline is
empty.Node getFirstNode()
null
if there's no nodes in the timeline.
null
if timeline is
empty.void removeNode(Node nodeToRemove)
nodeToRemove
isn't added in this timeline.
nodeToRemove
- the node to remove from this timeline
IllegalArgumentException
- if null
node or node not
connected to this timeline.void addNode(Node nodeToAdd, long timestamp)
timestamp
.
nodeToAdd
- the node to add to this timeline.timestamp
- the timestamp to use
IllegalArgumentException
- if already added to this timeline or
null
node.Iterable<Node> getNodes(long timestamp)
timestamp
.
timestamp
- the timestamp to get nodes for.
timestamp
.Iterable<Node> getAllNodes()
Iterable<Node> getAllNodesAfter(long timestamp)
timestamp
ordered by
increasing timestamp.
timestamp
- the timestamp value, nodes with greater timestamp value
will be returned.
timestamp
ordered by
increasing timestamp.Iterable<Node> getAllNodesBefore(long timestamp)
timestamp
ordered by
increasing timestamp.
timestamp
- the timestamp value, nodes with lesser timestamp value
will be returned.
timestamp
ordered by
increasing timestamp.Iterable<Node> getAllNodesBetween(long startTimestamp, long endTimestamp)
afterTimestamp
and before
(exclusive) beforeTimestamp
ordered by increasing timestamp.
startTimestamp
- the start timestamp, nodes with greater timestamp
value will be returned.endTimestamp
- the end timestamp, nodes with lesser timestamp value
will be returned.
Iterable<Node> getAllNodes(Long startTimestampOrNull, Long endTimestampOrNull)
getAllNodes()
,
getAllNodesAfter(long)
, getAllNodesBefore(long)
and
getAllNodesBetween(long, long)
in a single method.
startTimestampOrNull
- the start timestamp, nodes with greater
timestamp value will be returned. Will be ignored if null
.endTimestampOrNull
- the end timestamp, nodes with lesser timestamp
value will be returned. Will be ignored if null
.
startTimestampOrNull
and/or endTimestampOrNull
(where null
means no restriction).long getTimestampForNode(Node node)
node
if it has been added to this
timeline. If node
hasn't been added to this timeline a runtime
exception will be thrown.
node
- the node to return the timestamp for.
node
.void delete()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |