Gridarta Editor
Index.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2015 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.model.index;
21 
22 import java.io.IOException;
23 import java.io.ObjectInputStream;
24 import java.io.ObjectOutputStream;
25 import java.util.Collection;
26 import org.jetbrains.annotations.NotNull;
27 import org.jetbrains.annotations.Nullable;
28 
41 public interface Index<V> {
42 
47  int size();
48 
54  @NotNull
55  Collection<V> findPartialName(@NotNull String name);
56 
61  void beginUpdate();
62 
69  void endUpdate();
70 
78  void add(@NotNull V value, long timestamp);
79 
85  void remove(@NotNull V value);
86 
91  void setPending(@NotNull V value);
92 
99  void setName(@NotNull V value, long timestamp, @NotNull String name);
100 
107  @Nullable
108  String getName(@NotNull V value);
109 
114  @Nullable
115  V removePending();
116 
121  boolean hasPending();
122 
127  boolean isModified();
128 
133  void addIndexListener(@NotNull IndexListener<V> listener);
134 
139  void removeIndexListener(@NotNull IndexListener<V> listener);
140 
147  void save(@NotNull ObjectOutputStream objectOutputStream) throws IOException;
148 
155  void load(@NotNull ObjectInputStream objectInputStream) throws IOException;
156 
160  void clear();
161 
165  void indexingFinished();
166 
167 }
void removeIndexListener(@NotNull IndexListener< V > listener)
Removes an IndexListener to be notified of changes.
V removePending()
Returns one pending value.
void add(@NotNull V value, long timestamp)
Adds a value to the cache.
An index of values.
Definition: Index.java:41
Interface for listeners interested in Index related events.
boolean isModified()
Returns whether the state was modified since last save.
boolean hasPending()
Returns whether at least one pending value exists.
void setPending(@NotNull V value)
Marks a value as pending.
String getName(@NotNull V value)
Returns the name associated with a value.
void indexingFinished()
Should be called after indexing has finished.
void setName(@NotNull V value, long timestamp, @NotNull String name)
Associates a value with a name.
void addIndexListener(@NotNull IndexListener< V > listener)
Adds an IndexListener to be notified of changes.
void load(@NotNull ObjectInputStream objectInputStream)
Restores the state from an ObjectInputStream.
void save(@NotNull ObjectOutputStream objectOutputStream)
Saves the state to an ObjectOutputStream.
void endUpdate()
Ends an update.
int size()
Returns the number of values in this cache.
Collection< V > findPartialName(@NotNull String name)
Returns all matching values for a (possibly partial) key name.
void beginUpdate()
Starts an update.
void clear()
Clears all values from the index.