1 | /*
|
---|
2 | * Copyright 2003-2004 The Apache Software Foundation
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | *
|
---|
16 | */
|
---|
17 |
|
---|
18 | package org.apache.tools.ant.types.selectors.modifiedselector;
|
---|
19 |
|
---|
20 |
|
---|
21 | import java.util.Iterator;
|
---|
22 |
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * A Cache let the user store key-value-pairs in a permanent manner and access
|
---|
26 | * them.
|
---|
27 | * It is possible that a client uses get() before load() therefore the
|
---|
28 | * implementation must ensure that no error occurred because of the wrong
|
---|
29 | * <i>order</i>.
|
---|
30 | * The implementing class should implement a useful toString() method.
|
---|
31 | *
|
---|
32 | * @version 2003-09-13
|
---|
33 | * @since Ant 1.6
|
---|
34 | */
|
---|
35 | public interface Cache {
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * Checks its prerequisites.
|
---|
39 | * @return <i>true</i> if all is ok, otherwise <i>false</i>.
|
---|
40 | */
|
---|
41 | boolean isValid();
|
---|
42 |
|
---|
43 | /** Deletes the cache. If file based the file has to be deleted also. */
|
---|
44 | void delete();
|
---|
45 |
|
---|
46 | /** Loads the cache, must handle not existing cache. */
|
---|
47 | void load();
|
---|
48 |
|
---|
49 | /** Saves modification of the cache. */
|
---|
50 | void save();
|
---|
51 |
|
---|
52 | /**
|
---|
53 | * Returns a value for a given key from the cache.
|
---|
54 | * @param key the key
|
---|
55 | * @return the stored value
|
---|
56 | */
|
---|
57 | Object get(Object key);
|
---|
58 |
|
---|
59 | /**
|
---|
60 | * Saves a key-value-pair in the cache.
|
---|
61 | * @param key the key
|
---|
62 | * @param value the value
|
---|
63 | */
|
---|
64 | void put(Object key, Object value);
|
---|
65 |
|
---|
66 | /**
|
---|
67 | * Returns an iterator over the keys in the cache.
|
---|
68 | * @return An iterator over the keys.
|
---|
69 | */
|
---|
70 | Iterator iterator();
|
---|
71 | }
|
---|