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-2023 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 }
name
name
Definition: ArchetypeTypeSetParserTest-ignoreDefaultAttribute1-result.txt:2
net.sf.gridarta.model.index.Index.size
int size()
Returns the number of values in this cache.
net.sf.gridarta.model.index.Index.load
void load(@NotNull ObjectInputStream objectInputStream)
Restores the state from an ObjectInputStream.
net.sf.gridarta.model.index.Index.isModified
boolean isModified()
Returns whether the state was modified since last save.
net.sf.gridarta.model.index.Index.hasPending
boolean hasPending()
Returns whether at least one pending value exists.
net.sf.gridarta.model.index.Index.endUpdate
void endUpdate()
Ends an update.
net.sf.gridarta.model.index.Index.save
void save(@NotNull ObjectOutputStream objectOutputStream)
Saves the state to an ObjectOutputStream.
net.sf.gridarta.model.index.Index.clear
void clear()
Clears all values from the index.
net.sf.gridarta.model.index.Index.findPartialName
Collection< V > findPartialName(@NotNull String name)
Returns all matching values for a (possibly partial) key name.
net.sf.gridarta.model.index.Index.setPending
void setPending(@NotNull V value)
Marks a value as pending.
net.sf.gridarta.model.index.Index.getName
String getName(@NotNull V value)
Returns the name associated with a value.
net.sf.gridarta.model.index.Index.removeIndexListener
void removeIndexListener(@NotNull IndexListener< V > listener)
Removes an IndexListener to be notified of changes.
net.sf.gridarta.model.index.Index.removePending
V removePending()
Returns one pending value.
net.sf.gridarta.model.index.Index.addIndexListener
void addIndexListener(@NotNull IndexListener< V > listener)
Adds an IndexListener to be notified of changes.
net.sf.gridarta.model.index.IndexListener
Interface for listeners interested in Index related events.
Definition: IndexListener.java:30
net.sf.gridarta.model.index.Index
An index of values.
Definition: Index.java:41
net.sf.gridarta.model.index.Index.add
void add(@NotNull V value, long timestamp)
Adds a value to the cache.
net.sf.gridarta.model.index.Index.beginUpdate
void beginUpdate()
Starts an update.
net.sf.gridarta.model.index.Index.indexingFinished
void indexingFinished()
Should be called after indexing has finished.
net.sf.gridarta.model.index.Index.setName
void setName(@NotNull V value, long timestamp, @NotNull String name)
Associates a value with a name.