001: /*
002: * uDig - User Friendly Desktop Internet GIS client http://udig.refractions.net (C) 2004,
003: * Refractions Research Inc. This library is free software; you can redistribute it and/or modify it
004: * under the terms of the GNU Lesser General Public License as published by the Free Software
005: * Foundation; version 2.1 of the License. This library is distributed in the hope that it will be
006: * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
007: * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
008: */
009: package net.refractions.udig.project;
010:
011: /**
012: * Provide Temporary for shared collaboration between renderers and the user.
013: * <p>
014: * To emphais the tempoary nature we are not storing objects at this time, please see
015: * StyleBlackboard for the direction we wish to take this class. API should this interface be
016: * included?
017: * </p>
018: * Q: Should this class be cloneable? API explain the use of 'keys' and any uniqueness constraints
019: * (Set or List?) API X getX(key) ... should this be X get(key) and let the compiler firgure out
020: * which one to call based on the signature? API moreover, you might want to consider on 'Objects'
021: * and the use of <T> in the API, using generics to avoid multiple get and put methods. API looks
022: * alot like a Map ... either document a comparison or add an extends clause?
023: *
024: * @author Jody Garnett
025: * @since 0.7.0
026: */
027: public interface IBlackboard {
028: /**
029: * Adds a listener to the blackboard. Duplicates are not permitted.
030: *
031: * @param listener a listener that will be notified when the blackboard changes
032: * @return <tt>true</tt> if the collection changed as a result of the call.
033: */
034: boolean addListener(IBlackboardListener listener);
035:
036: /**
037: * Removes a listener
038: *
039: * @param listener the listener to be removed.
040: * @return <tt>true</tt> if the collection contained the specified
041: * element.
042: */
043: boolean removeListener(IBlackboardListener listener);
044:
045: /**
046: * Check if blackboard has an entry for key.
047: *
048: * @return <code>true</code> if a value is known for key
049: */
050: boolean contains(String key);
051:
052: /**
053: * Returns the object value of the given key.
054: *
055: * @param key the key
056: * @return the value, or null if the key was not found
057: */
058: public Object get(String key);
059:
060: /**
061: * Sets the value of the given key.
062: *
063: * @param key the key
064: * @param value the value
065: */
066: public void put(String key, Object value);
067:
068: /**
069: * Returns the floating point value of the given key.
070: *
071: * @param key the key
072: * @return the value, or <code>null</code> if the key was not found or was found but was not a
073: * floating point number
074: */
075: public Float getFloat(String key);
076:
077: /**
078: * Returns the integer value of the given key.
079: *
080: * @param key the key
081: * @return the value, or <code>null</code> if the key was not found or was found but was not
082: * an integer
083: */
084: public Integer getInteger(String key);
085:
086: /**
087: * Returns the string value of the given key.
088: *
089: * @param key the key
090: * @return the value, or <code>null</code> if the key was not found
091: */
092: public String getString(String key);
093:
094: /**
095: * Sets the value of the given key to the given floating point number.
096: *
097: * @param key the key
098: * @param value the value
099: */
100: public void putFloat(String key, float value);
101:
102: /**
103: * Sets the value of the given key to the given integer.
104: *
105: * @param key the key
106: * @param value the value
107: */
108: public void putInteger(String key, int value);
109:
110: /**
111: * Sets the value of the given key to the given string.
112: *
113: * @param key the key
114: * @param value the value
115: */
116: public void putString(String key, String value);
117:
118: /**
119: * Clear the contents of this blackboard.
120: * <p>
121: * This is a clear() method, not a dispose(), resource handling is not provided.
122: * </p>
123: * <p>
124: * It is not recommend that client code store *real* (such as Images) resources on the
125: * blackboard. This is not a ImageCache that will magically handle resource management for you.
126: * </p>
127: */
128: public void clear();
129:
130: /**
131: * Flush the contents of this blackboard.
132: * <p>
133: * This signals the blackboard to save any contents, and clear any cached object references.
134: * </p>
135: */
136: public void flush();
137: }
|