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. package org.apache.tools.ant.types.selectors.modifiedselector;
  18. import java.util.Iterator;
  19. /**
  20. * A Cache let the user store key-value-pairs in a permanent manner and access
  21. * them.
  22. * It is possible that a client uses get() before load() therefore the
  23. * implementation must ensure that no error occurred because of the wrong
  24. * <i>order</i>.
  25. * The implementing class should implement a useful toString() method.
  26. *
  27. * @version 2003-09-13
  28. * @since Ant 1.6
  29. */
  30. public interface Cache {
  31. /**
  32. * Checks its prerequisites.
  33. * @return <i>true</i> if all is ok, otherwise <i>false</i>.
  34. */
  35. boolean isValid();
  36. /** Deletes the cache. If file based the file has to be deleted also. */
  37. void delete();
  38. /** Loads the cache, must handle not existing cache. */
  39. void load();
  40. /** Saves modification of the cache. */
  41. void save();
  42. /**
  43. * Returns a value for a given key from the cache.
  44. * @param key the key
  45. * @return the stored value
  46. */
  47. Object get(Object key);
  48. /**
  49. * Saves a key-value-pair in the cache.
  50. * @param key the key
  51. * @param value the value
  52. */
  53. void put(Object key, Object value);
  54. /**
  55. * Returns an iterator over the keys in the cache.
  56. * @return An iterator over the keys.
  57. */
  58. Iterator iterator();
  59. }