jdk/src/java.scripting/share/classes/javax/script/Bindings.java
author chegar
Sun, 17 Aug 2014 15:54:13 +0100
changeset 25859 3317bb8137f4
parent 5506 jdk/src/share/classes/javax/script/Bindings.java@202f599c92aa
child 32769 c9520bbd6754
permissions -rw-r--r--
8054834: Modular Source Code Reviewed-by: alanb, chegar, ihse, mduigou Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, chris.hegarty@oracle.com, erik.joelsson@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, magnus.ihse.bursie@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, paul.sandoz@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.script;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * A mapping of key/value pairs, all of whose keys are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * <code>Strings</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * @author Mike Grogan
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
public interface Bindings extends Map<String, Object> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
     * Set a named value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
     * @param name The name associated with the value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
     * @param value The value associated with the name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
     * @return The value previously associated with the given name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
     * Returns null if no value was previously associated with the name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
     * @throws NullPointerException if the name is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     * @throws IllegalArgumentException if the name is empty String.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    public Object put(String name, Object value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * Adds all the mappings in a given <code>Map</code> to this <code>Bindings</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * @param toMerge The <code>Map</code> to merge with this one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * @throws NullPointerException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     *         if toMerge map is null or if some key in the map is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * @throws IllegalArgumentException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     *         if some key in the map is an empty String.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    public void putAll(Map<? extends String, ? extends Object> toMerge);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * Returns <tt>true</tt> if this map contains a mapping for the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * key.  More formally, returns <tt>true</tt> if and only if
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * this map contains a mapping for a key <tt>k</tt> such that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * <tt>(key==null ? k==null : key.equals(k))</tt>.  (There can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * at most one such mapping.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * @param key key whose presence in this map is to be tested.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * @return <tt>true</tt> if this map contains a mapping for the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     *         key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * @throws NullPointerException if key is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * @throws ClassCastException if key is not String
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * @throws IllegalArgumentException if key is empty String
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    public boolean containsKey(Object key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * Returns the value to which this map maps the specified key.  Returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * <tt>null</tt> if the map contains no mapping for this key.  A return
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * value of <tt>null</tt> does not <i>necessarily</i> indicate that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * map contains no mapping for the key; it's also possible that the map
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * explicitly maps the key to <tt>null</tt>.  The <tt>containsKey</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * operation may be used to distinguish these two cases.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * <p>More formally, if this map contains a mapping from a key
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * <tt>k</tt> to a value <tt>v</tt> such that <tt>(key==null ? k==null :
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * key.equals(k))</tt>, then this method returns <tt>v</tt>; otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * it returns <tt>null</tt>.  (There can be at most one such mapping.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @param key key whose associated value is to be returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @return the value to which this map maps the specified key, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     *         <tt>null</tt> if the map contains no mapping for this key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @throws NullPointerException if key is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * @throws ClassCastException if key is not String
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @throws IllegalArgumentException if key is empty String
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    public Object get(Object key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * Removes the mapping for this key from this map if it is present
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * (optional operation).   More formally, if this map contains a mapping
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * from key <tt>k</tt> to value <tt>v</tt> such that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * <code>(key==null ?  k==null : key.equals(k))</code>, that mapping
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * is removed.  (The map can contain at most one such mapping.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * <p>Returns the value to which the map previously associated the key, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * <tt>null</tt> if the map contained no mapping for this key.  (A
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * <tt>null</tt> return can also indicate that the map previously
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * associated <tt>null</tt> with the specified key if the implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * supports <tt>null</tt> values.)  The map will not contain a mapping for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * the specified  key once the call returns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @param key key whose mapping is to be removed from the map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * @return previous value associated with specified key, or <tt>null</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     *         if there was no mapping for key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * @throws NullPointerException if key is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * @throws ClassCastException if key is not String
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * @throws IllegalArgumentException if key is empty String
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    public Object remove(Object key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
}