01: /*
02: * Database.java December 2003
03: *
04: * Copyright (C) 2003, Niall Gallagher <niallg@users.sf.net>
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation.
09: *
10: * This library 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 Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General
16: * Public License along with this library; if not, write to the
17: * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18: * Boston, MA 02111-1307 USA
19: */
20:
21: package simple.template;
22:
23: import java.util.Set;
24:
25: /**
26: * The <code>Database</code> interface is used to represent a source
27: * of data for a template. It also serves the purpose of providing
28: * a means to to share data between controllers. The database object
29: * contains a subset of the methods provided by a <code>Map</code>.
30: *
31: * @author Niall Gallagher
32: */
33: public interface Database {
34:
35: /**
36: * The <code>put</code> method is used to insert a mapping in
37: * the database that pairs the issued name with the issued
38: * value. The value can be referenced in future by its name.
39: *
40: * @param name this is the name of the value being inserted
41: * @param value this is the named value that is inserted
42: */
43: public void put(String name, Object value);
44:
45: /**
46: * The <code>get</code> method is used to retrieve the value
47: * mapped to the specified name. If a value does not exist
48: * matching the given name, then this returns null.
49: *
50: * @param name this is the name of the value to be retrieved
51: *
52: * @return returns the value if it exists or null otherwise
53: */
54: public Object get(String name);
55:
56: /**
57: * The <code>remove</code> method is used to remove the
58: * named value from the database. This method either removes
59: * the value or returns silently if the name does not exits.
60: *
61: * @param name this is the name of the value to be removed
62: */
63: public void remove(String name);
64:
65: /**
66: * To ascertain what mappings exist, the names of all values
67: * previously put into thhis database can be retrieved with
68: * this method. This will return a <code>Set</code> that
69: * contains the names of all the mappings added to this.
70: *
71: * @return this returns all the keys for existing mappings
72: */
73: public Set keySet();
74:
75: /**
76: * The <code>contains</code> method is used to determine if
77: * a mapping exists for the given name. This returns true if
78: * the mapping exists or false otherwise.
79: *
80: * @param name this is the name of the mapping to determine
81: *
82: * @return returns true if a mapping exists, false otherwise
83: */
84: public boolean contains(String name);
85: }
|