Gridarta Editor
net.sf.gridarta.model.index.Index< V > Interface Template Reference

An index of values. More...

+ Inheritance diagram for net.sf.gridarta.model.index.Index< V >:
+ Collaboration diagram for net.sf.gridarta.model.index.Index< V >:

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...
 
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...
 

Detailed Description

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.

Parameters
<V>the value's type
Author
Andreas Kirschbaum

Definition at line 41 of file Index.java.

Member Function Documentation

◆ add()

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.

Parameters
valuethe value to add
timestampa 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().

+ Here is the caller graph for this function:

◆ addIndexListener()

void net.sf.gridarta.model.index.Index< V >.addIndexListener ( @NotNull IndexListener< V >  listener)

Adds an IndexListener to be notified of changes.

Parameters
listenerthe index listener to add

Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.

Referenced by net.sf.gridarta.model.index.MapsIndexTest.testListener().

+ Here is the caller graph for this function:

◆ beginUpdate()

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().

+ Here is the caller graph for this function:

◆ clear()

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 >.

◆ endUpdate()

◆ findPartialName()

Collection<V> net.sf.gridarta.model.index.Index< V >.findPartialName ( @NotNull String  name)

Returns all matching values for a (possibly partial) key name.

Parameters
namethe partial name to look up
Returns
the matching values

Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.

◆ getName()

String net.sf.gridarta.model.index.Index< V >.getName ( @NotNull V  value)

Returns the name associated with a value.

Parameters
valuethe value
Returns
the name or
null
if the value does not exist or has no associated name

Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.

◆ hasPending()

boolean net.sf.gridarta.model.index.Index< V >.hasPending ( )

Returns whether at least one pending value exists.

Returns
whether at least one pending value exists

Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.

◆ indexingFinished()

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 >.

◆ isModified()

boolean net.sf.gridarta.model.index.Index< V >.isModified ( )

Returns whether the state was modified since last save.

Returns
whether the state was modified

Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.

◆ load()

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.

Parameters
objectInputStreamthe input stream to read from
Exceptions
IOExceptionif an I/O error occurs

Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.

◆ remove()

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.

Parameters
valuethe 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().

+ Here is the caller graph for this function:

◆ removeIndexListener()

void net.sf.gridarta.model.index.Index< V >.removeIndexListener ( @NotNull IndexListener< V >  listener)

Removes an IndexListener to be notified of changes.

Parameters
listenerthe index listener to remove

Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.

◆ removePending()

V net.sf.gridarta.model.index.Index< V >.removePending ( )

Returns one pending value.

Returns
a pending value or
null
if no pending values exist

Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.

◆ save()

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.

Parameters
objectOutputStreamthe object output stream to write to
Exceptions
IOExceptionif an I/O error occurs

Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.

◆ setName()

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.

Parameters
valuethe value to associate with a name
timestampthe value's timestamp
namethe 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().

+ Here is the caller graph for this function:

◆ setPending()

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.

Parameters
valuethe value to mark pending

Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.

Referenced by net.sf.gridarta.model.index.MapsIndexTest.test1().

+ Here is the caller graph for this function:

◆ size()

Returns the number of values in this cache.

Returns
the number of values

Implemented in net.sf.gridarta.model.index.AbstractIndex< V extends Serializable >.


The documentation for this interface was generated from the following file: