![]() |
Gridarta Editor
|
An index of values. More...
Public Member Functions | |
void | add (@NotNull V value, long timestamp) |
Adds a value to the cache. More... | |
void | addIndexListener (@NotNull IndexListener< V > listener) |
Adds an IndexListener to be notified of changes. More... | |
void | beginUpdate () |
Starts an update. More... | |
void | clear () |
Clears all values from the index. More... | |
void | endUpdate () |
Ends an update. More... | |
Collection< V > | findPartialName (@NotNull String name) |
Returns all matching values for a (possibly partial) key name. More... | |
String | getName (@NotNull V value) |
Returns the name associated with a value. More... | |
boolean | hasPending () |
Returns whether at least one pending value exists. More... | |
void | indexingFinished () |
Should be called after indexing has finished. More... | |
boolean | isModified () |
Returns whether the state was modified since last save. More... | |
void | load (@NotNull ObjectInputStream objectInputStream) throws IOException |
Restores the state from an ObjectInputStream. More... | |
void | remove (@NotNull V value) |
Removes a value from the cache. More... | |
void | removeIndexListener (@NotNull IndexListener< V > listener) |
Removes an IndexListener to be notified of changes. More... | |
V | removePending () |
Returns one pending value. More... | |
void | save (@NotNull ObjectOutputStream objectOutputStream) throws IOException |
Saves the state to an ObjectOutputStream. More... | |
void | setName (@NotNull V value, long timestamp, @NotNull String name) |
Associates a value with a name. More... | |
void | setPending (@NotNull V value) |
Marks a value as pending. More... | |
int | size () |
Returns the number of values in this cache. More... | |
An index of values.
Values are associated with a timestamp and zero or one name. The timestamp is used to mark values as pending whenever they have changed. Pending values may be retrieved for re-indexing.
Values may be looked up by partial names.
All methods are synchronized: concurrent access from multiple threads is supported.
<V> | the value's type |
Definition at line 41 of file Index.java.
void net.sf.gridarta.model.index.Index< V >.add | ( | @NotNull V | value, |
long | timestamp | ||
) |
Adds a value to the cache.
Newly added values and existing values for which the new timestamp does not match the old timestamp are marked as pending.
value | the value to add |
timestamp | a timestamp associated with the value |
Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.
Referenced by net.sf.gridarta.model.index.MapsIndexTest.test1(), net.sf.gridarta.model.index.MapsIndexTest.testFind1(), net.sf.gridarta.model.index.MapsIndexTest.testListener(), and net.sf.gridarta.model.index.MapsIndexTest.testTransaction().
void net.sf.gridarta.model.index.Index< V >.addIndexListener | ( | @NotNull IndexListener< V > | listener | ) |
Adds an IndexListener to be notified of changes.
listener | the index listener to add |
Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.
Referenced by net.sf.gridarta.model.index.MapsIndexTest.testListener().
void net.sf.gridarta.model.index.Index< V >.beginUpdate | ( | ) |
Starts an update.
Updates do not nest. This function and {} should be called from only a single thread.
Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.
Referenced by net.sf.gridarta.model.index.MapsIndexTest.testTransaction().
void net.sf.gridarta.model.index.Index< V >.clear | ( | ) |
Clears all values from the index.
Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.
void net.sf.gridarta.model.index.Index< V >.endUpdate | ( | ) |
Ends an update.
Removes all values from the index that were not {added} since the last call to #beginUpdate()}. Must not be called unless a directly preceding call to beginUpdate() was made.
Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.
Referenced by net.sf.gridarta.model.index.MapsIndexTest.testTransaction().
Collection<V> net.sf.gridarta.model.index.Index< V >.findPartialName | ( | @NotNull String | name | ) |
Returns all matching values for a (possibly partial) key name.
name | the partial name to look up |
Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.
String net.sf.gridarta.model.index.Index< V >.getName | ( | @NotNull V | value | ) |
Returns the name associated with a value.
value | the value |
Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.
boolean net.sf.gridarta.model.index.Index< V >.hasPending | ( | ) |
Returns whether at least one pending value exists.
Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.
void net.sf.gridarta.model.index.Index< V >.indexingFinished | ( | ) |
Should be called after indexing has finished.
Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.
boolean net.sf.gridarta.model.index.Index< V >.isModified | ( | ) |
Returns whether the state was modified since last save.
Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.
void net.sf.gridarta.model.index.Index< V >.load | ( | @NotNull ObjectInputStream | objectInputStream | ) | throws IOException |
Restores the state from an ObjectInputStream.
The previous state is overwritten.
objectInputStream | the input stream to read from |
IOException | if an I/O error occurs |
Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.
void net.sf.gridarta.model.index.Index< V >.remove | ( | @NotNull V | value | ) |
Removes a value from the cache.
Does nothing if the values does not exist.
value | the value to remove |
Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.
Referenced by net.sf.gridarta.model.index.MapsIndexTest.test1(), and net.sf.gridarta.model.index.MapsIndexTest.testListener().
void net.sf.gridarta.model.index.Index< V >.removeIndexListener | ( | @NotNull IndexListener< V > | listener | ) |
Removes an IndexListener to be notified of changes.
listener | the index listener to remove |
Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.
V net.sf.gridarta.model.index.Index< V >.removePending | ( | ) |
Returns one pending value.
Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.
void net.sf.gridarta.model.index.Index< V >.save | ( | @NotNull ObjectOutputStream | objectOutputStream | ) | throws IOException |
Saves the state to an ObjectOutputStream.
Pending maps are not saved.
objectOutputStream | the object output stream to write to |
IOException | if an I/O error occurs |
Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.
void net.sf.gridarta.model.index.Index< V >.setName | ( | @NotNull V | value, |
long | timestamp, | ||
@NotNull String | name | ||
) |
Associates a value with a name.
Adds the value if it does not exist.
value | the value to associate with a name |
timestamp | the value's timestamp |
name | the name associated with the value |
Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.
Referenced by net.sf.gridarta.model.index.MapsIndexTest.testFind1(), net.sf.gridarta.model.index.MapsIndexTest.testListener(), and net.sf.gridarta.model.index.MapsIndexTest.testTransaction().
void net.sf.gridarta.model.index.Index< V >.setPending | ( | @NotNull V | value | ) |
Marks a value as pending.
The value is added if it does not exist.
value | the value to mark pending |
Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.
Referenced by net.sf.gridarta.model.index.MapsIndexTest.test1().
int net.sf.gridarta.model.index.Index< V >.size | ( | ) |
Returns the number of values in this cache.
Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.