11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package javax.script; 27 import java.util.Map; 28 29 /** 30 * A mapping of key/value pairs, all of whose keys are 31 * <code>Strings</code>. 32 * 33 * @author Mike Grogan 34 * @since 1.6 35 */ 36 public interface Bindings extends Map<String, Object> { 37 /** 38 * Set a named value. 39 * 40 * @param name The name associated with the value. 41 * @param value The value associated with the name. 42 * 43 * @return The value previously associated with the given name. 44 * Returns null if no value was previously associated with the name. 45 * 46 * @throws NullPointerException if the name is null. 47 * @throws IllegalArgumentException if the name is empty String. 48 */ 49 public Object put(String name, Object value); 50 51 /** 52 * Adds all the mappings in a given <code>Map</code> to this <code>Bindings</code>. 53 * @param toMerge The <code>Map</code> to merge with this one. 54 * 55 * @throws NullPointerException 56 * if toMerge map is null or if some key in the map is null. 57 * @throws IllegalArgumentException 58 * if some key in the map is an empty String. 59 */ 60 public void putAll(Map<? extends String, ? extends Object> toMerge); 61 62 /** 63 * Returns <tt>true</tt> if this map contains a mapping for the specified 64 * key. More formally, returns <tt>true</tt> if and only if 65 * this map contains a mapping for a key <tt>k</tt> such that 66 * <tt>(key==null ? k==null : key.equals(k))</tt>. (There can be 67 * at most one such mapping.) 68 * 69 * @param key key whose presence in this map is to be tested. 70 * @return <tt>true</tt> if this map contains a mapping for the specified 71 * key. 72 * 73 * @throws NullPointerException if key is null 74 * @throws ClassCastException if key is not String 75 * @throws IllegalArgumentException if key is empty String 76 */ 77 public boolean containsKey(Object key); 78 79 /** 80 * Returns the value to which this map maps the specified key. Returns 81 * <tt>null</tt> if the map contains no mapping for this key. A return 82 * value of <tt>null</tt> does not <i>necessarily</i> indicate that the 83 * map contains no mapping for the key; it's also possible that the map 84 * explicitly maps the key to <tt>null</tt>. The <tt>containsKey</tt> 85 * operation may be used to distinguish these two cases. 86 * 87 * <p>More formally, if this map contains a mapping from a key 88 * <tt>k</tt> to a value <tt>v</tt> such that <tt>(key==null ? k==null : 89 * key.equals(k))</tt>, then this method returns <tt>v</tt>; otherwise 90 * it returns <tt>null</tt>. (There can be at most one such mapping.) 91 * 92 * @param key key whose associated value is to be returned. 93 * @return the value to which this map maps the specified key, or 94 * <tt>null</tt> if the map contains no mapping for this key. 95 * 96 * @throws NullPointerException if key is null 97 * @throws ClassCastException if key is not String 98 * @throws IllegalArgumentException if key is empty String 99 */ 100 public Object get(Object key); 101 102 /** 103 * Removes the mapping for this key from this map if it is present 104 * (optional operation). More formally, if this map contains a mapping 105 * from key <tt>k</tt> to value <tt>v</tt> such that 106 * <code>(key==null ? k==null : key.equals(k))</code>, that mapping 107 * is removed. (The map can contain at most one such mapping.) 108 * 109 * <p>Returns the value to which the map previously associated the key, or 110 * <tt>null</tt> if the map contained no mapping for this key. (A 111 * <tt>null</tt> return can also indicate that the map previously 112 * associated <tt>null</tt> with the specified key if the implementation 113 * supports <tt>null</tt> values.) The map will not contain a mapping for 114 * the specified key once the call returns. 115 * 116 * @param key key whose mapping is to be removed from the map. 117 * @return previous value associated with specified key, or <tt>null</tt> 118 * if there was no mapping for key. 119 * 120 * @throws NullPointerException if key is null 121 * @throws ClassCastException if key is not String 122 * @throws IllegalArgumentException if key is empty String 123 */ 124 public Object remove(Object key); 125 } | 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package javax.script; 27 import java.util.Map; 28 29 /** 30 * A mapping of key/value pairs, all of whose keys are 31 * {@code Strings}. 32 * 33 * @author Mike Grogan 34 * @since 1.6 35 */ 36 public interface Bindings extends Map<String, Object> { 37 /** 38 * Set a named value. 39 * 40 * @param name The name associated with the value. 41 * @param value The value associated with the name. 42 * 43 * @return The value previously associated with the given name. 44 * Returns null if no value was previously associated with the name. 45 * 46 * @throws NullPointerException if the name is null. 47 * @throws IllegalArgumentException if the name is empty String. 48 */ 49 public Object put(String name, Object value); 50 51 /** 52 * Adds all the mappings in a given {@code Map} to this {@code Bindings}. 53 * @param toMerge The {@code Map} to merge with this one. 54 * 55 * @throws NullPointerException 56 * if toMerge map is null or if some key in the map is null. 57 * @throws IllegalArgumentException 58 * if some key in the map is an empty String. 59 */ 60 public void putAll(Map<? extends String, ? extends Object> toMerge); 61 62 /** 63 * Returns {@code true} if this map contains a mapping for the specified 64 * key. More formally, returns {@code true} if and only if 65 * this map contains a mapping for a key {@code k} such that 66 * {@code (key==null ? k==null : key.equals(k))}. (There can be 67 * at most one such mapping.) 68 * 69 * @param key key whose presence in this map is to be tested. 70 * @return {@code true} if this map contains a mapping for the specified 71 * key. 72 * 73 * @throws NullPointerException if key is null 74 * @throws ClassCastException if key is not String 75 * @throws IllegalArgumentException if key is empty String 76 */ 77 public boolean containsKey(Object key); 78 79 /** 80 * Returns the value to which this map maps the specified key. Returns 81 * {@code null} if the map contains no mapping for this key. A return 82 * value of {@code null} does not <i>necessarily</i> indicate that the 83 * map contains no mapping for the key; it's also possible that the map 84 * explicitly maps the key to {@code null}. The {@code containsKey} 85 * operation may be used to distinguish these two cases. 86 * 87 * <p>More formally, if this map contains a mapping from a key 88 * {@code k} to a value {@code v} such that 89 * {@code (key==null ? k==null : key.equals(k))}, 90 * then this method returns {@code v}; otherwise 91 * it returns {@code null}. (There can be at most one such mapping.) 92 * 93 * @param key key whose associated value is to be returned. 94 * @return the value to which this map maps the specified key, or 95 * {@code null} if the map contains no mapping for this key. 96 * 97 * @throws NullPointerException if key is null 98 * @throws ClassCastException if key is not String 99 * @throws IllegalArgumentException if key is empty String 100 */ 101 public Object get(Object key); 102 103 /** 104 * Removes the mapping for this key from this map if it is present 105 * (optional operation). More formally, if this map contains a mapping 106 * from key {@code k} to value {@code v} such that 107 * {@code (key==null ? k==null : key.equals(k))}, that mapping 108 * is removed. (The map can contain at most one such mapping.) 109 * 110 * <p>Returns the value to which the map previously associated the key, or 111 * {@code null} if the map contained no mapping for this key. (A 112 * {@code null} return can also indicate that the map previously 113 * associated {@code null} with the specified key if the implementation 114 * supports {@code null} values.) The map will not contain a mapping for 115 * the specified key once the call returns. 116 * 117 * @param key key whose mapping is to be removed from the map. 118 * @return previous value associated with specified key, or {@code null} 119 * if there was no mapping for key. 120 * 121 * @throws NullPointerException if key is null 122 * @throws ClassCastException if key is not String 123 * @throws IllegalArgumentException if key is empty String 124 */ 125 public Object remove(Object key); 126 } |