KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > script > Bindings


1 /*
2  * @(#)Bindings.java 1.5 06/04/07 20:59:45
3  *
4  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTAIL. Use is subject to license terms.
6  */

7
8 package javax.script;
9 import java.util.Map JavaDoc;
10
11 /**
12  * A mapping of key/value pairs, all of whose keys are
13  * <code>Strings</code>.
14  *
15  * @version 1.0
16  * @author Mike Grogan
17  * @since 1.6
18  */

19 public interface Bindings extends Map JavaDoc<String JavaDoc, Object JavaDoc> {
20     /**
21      * Set a named value.
22      *
23      * @param name The name associated with the value.
24      * @param value The value associated with the name.
25      *
26      * @return The value previously associated with the given name.
27      * Returns null if no value was previously associated with the name.
28      *
29      * @throws NullPointerException if the name is null.
30      * @throws IllegalArgumentException if the name is empty String.
31      */

32     public Object JavaDoc put(String JavaDoc name, Object JavaDoc value);
33     
34     /**
35      * Adds all the mappings in a given <code>Map</code> to this <code>Bindings</code>.
36      * @param toMerge The <code>Map</code> to merge with this one.
37      *
38      * @throws NullPointerException
39      * if toMerge map is null or if some key in the map is null.
40      * @throws IllegalArgumentException
41      * if some key in the map is an empty String.
42      */

43     public void putAll(Map JavaDoc<? extends String JavaDoc, ? extends Object JavaDoc> toMerge);
44
45     /**
46      * Returns <tt>true</tt> if this map contains a mapping for the specified
47      * key. More formally, returns <tt>true</tt> if and only if
48      * this map contains a mapping for a key <tt>k</tt> such that
49      * <tt>(key==null ? k==null : key.equals(k))</tt>. (There can be
50      * at most one such mapping.)
51      *
52      * @param key key whose presence in this map is to be tested.
53      * @return <tt>true</tt> if this map contains a mapping for the specified
54      * key.
55      *
56      * @throws NullPointerException if key is null
57      * @throws ClassCastException if key is not String
58      * @throws IllegalArgumentException if key is empty String
59      */

60     public boolean containsKey(Object JavaDoc key);
61
62     /**
63      * Returns the value to which this map maps the specified key. Returns
64      * <tt>null</tt> if the map contains no mapping for this key. A return
65      * value of <tt>null</tt> does not <i>necessarily</i> indicate that the
66      * map contains no mapping for the key; it's also possible that the map
67      * explicitly maps the key to <tt>null</tt>. The <tt>containsKey</tt>
68      * operation may be used to distinguish these two cases.
69      *
70      * <p>More formally, if this map contains a mapping from a key
71      * <tt>k</tt> to a value <tt>v</tt> such that <tt>(key==null ? k==null :
72      * key.equals(k))</tt>, then this method returns <tt>v</tt>; otherwise
73      * it returns <tt>null</tt>. (There can be at most one such mapping.)
74      *
75      * @param key key whose associated value is to be returned.
76      * @return the value to which this map maps the specified key, or
77      * <tt>null</tt> if the map contains no mapping for this key.
78      *
79      * @throws NullPointerException if key is null
80      * @throws ClassCastException if key is not String
81      * @throws IllegalArgumentException if key is empty String
82      */

83     public Object JavaDoc get(Object JavaDoc key);
84
85     /**
86      * Removes the mapping for this key from this map if it is present
87      * (optional operation). More formally, if this map contains a mapping
88      * from key <tt>k</tt> to value <tt>v</tt> such that
89      * <code>(key==null ? k==null : key.equals(k))</code>, that mapping
90      * is removed. (The map can contain at most one such mapping.)
91      *
92      * <p>Returns the value to which the map previously associated the key, or
93      * <tt>null</tt> if the map contained no mapping for this key. (A
94      * <tt>null</tt> return can also indicate that the map previously
95      * associated <tt>null</tt> with the specified key if the implementation
96      * supports <tt>null</tt> values.) The map will not contain a mapping for
97      * the specified key once the call returns.
98      *
99      * @param key key whose mapping is to be removed from the map.
100      * @return previous value associated with specified key, or <tt>null</tt>
101      * if there was no mapping for key.
102      *
103      * @throws NullPointerException if key is null
104      * @throws ClassCastException if key is not String
105      * @throws IllegalArgumentException if key is empty String
106      */

107     public Object JavaDoc remove(Object JavaDoc key);
108 }
109
Popular Tags