V
- the value's typepublic interface Index<V>
Values may be looked up by partial names.
All methods are synchronized: concurrent access from multiple threads is supported.
Modifier and Type | Method and Description |
---|---|
void |
add(V value,
long timestamp)
Adds a value to the cache.
|
void |
addIndexListener(@NotNull IndexListener<V> listener)
Adds an
IndexListener to be notified of changes. |
void |
beginUpdate()
Starts an update.
|
void |
clear()
Clears all values from the index.
|
void |
endUpdate()
Ends an update.
|
@NotNull java.util.Collection<V> |
findPartialName(@NotNull java.lang.String name)
Returns all matching values for a (possibly partial) key name.
|
@Nullable java.lang.String |
getName(V value)
Returns the name associated with a value.
|
boolean |
hasPending()
Returns whether at least one pending value exists.
|
void |
indexingFinished()
Should be called after indexing has finished.
|
boolean |
isModified()
Returns whether the state was modified since last save.
|
void |
load(@NotNull java.io.ObjectInputStream objectInputStream)
Restores the state from an
ObjectInputStream . |
void |
remove(V value)
Removes a value from the cache.
|
void |
removeIndexListener(@NotNull IndexListener<V> listener)
Removes an
IndexListener to be notified of changes. |
V |
removePending()
Returns one pending value.
|
void |
save(@NotNull java.io.ObjectOutputStream objectOutputStream)
Saves the state to an
ObjectOutputStream . |
void |
setName(V value,
long timestamp,
@NotNull java.lang.String name)
Associates a value with a name.
|
void |
setPending(V value)
Marks a value as pending.
|
int |
size()
Returns the number of values in this cache.
|
int size()
@NotNull @NotNull java.util.Collection<V> findPartialName(@NotNull @NotNull java.lang.String name)
name
- the partial name to look upvoid beginUpdate()
endUpdate()
should be called from only a single thread.void endUpdate()
added
since the last call to beginUpdate()
.
Must not be called unless a directly preceding call to beginUpdate()
was made.void add(@NotNull V value, long timestamp)
value
- the value to addtimestamp
- a timestamp associated with the valuevoid remove(@NotNull V value)
value
- the value to removevoid setPending(@NotNull V value)
value
- the value to mark pendingvoid setName(@NotNull V value, long timestamp, @NotNull @NotNull java.lang.String name)
value
- the value to associate with a nametimestamp
- the value's timestampname
- the name associated with the value@Nullable @Nullable java.lang.String getName(@NotNull V value)
value
- the valuenull
if the value does not exist or has no
associated name@Nullable V removePending()
null
if no pending values existboolean hasPending()
boolean isModified()
void addIndexListener(@NotNull @NotNull IndexListener<V> listener)
IndexListener
to be notified of changes.listener
- the index listener to addvoid removeIndexListener(@NotNull @NotNull IndexListener<V> listener)
IndexListener
to be notified of changes.listener
- the index listener to removevoid save(@NotNull @NotNull java.io.ObjectOutputStream objectOutputStream) throws java.io.IOException
ObjectOutputStream
. Pending maps are not
saved.objectOutputStream
- the object output stream to write tojava.io.IOException
- if an I/O error occursvoid load(@NotNull @NotNull java.io.ObjectInputStream objectInputStream) throws java.io.IOException
ObjectInputStream
. The previous state
is overwritten.objectInputStream
- the input stream to read fromjava.io.IOException
- if an I/O error occursvoid clear()
void indexingFinished()