Path: blob/master/src/java.scripting/share/classes/javax/script/Bindings.java
41149 views
/*1* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.script;26import java.util.Map;2728/**29* A mapping of key/value pairs, all of whose keys are30* {@code Strings}.31*32* @author Mike Grogan33* @since 1.634*/35public interface Bindings extends Map<String, Object> {36/**37* Set a named value.38*39* @param name The name associated with the value.40* @param value The value associated with the name.41*42* @return The value previously associated with the given name.43* Returns null if no value was previously associated with the name.44*45* @throws NullPointerException if the name is null.46* @throws IllegalArgumentException if the name is empty String.47*/48public Object put(String name, Object value);4950/**51* Adds all the mappings in a given {@code Map} to this {@code Bindings}.52* @param toMerge The {@code Map} to merge with this one.53*54* @throws NullPointerException55* if toMerge map is null or if some key in the map is null.56* @throws IllegalArgumentException57* if some key in the map is an empty String.58*/59public void putAll(Map<? extends String, ? extends Object> toMerge);6061/**62* Returns {@code true} if this map contains a mapping for the specified63* key. More formally, returns {@code true} if and only if64* this map contains a mapping for a key {@code k} such that65* {@code (key==null ? k==null : key.equals(k))}. (There can be66* at most one such mapping.)67*68* @param key key whose presence in this map is to be tested.69* @return {@code true} if this map contains a mapping for the specified70* key.71*72* @throws NullPointerException if key is null73* @throws ClassCastException if key is not String74* @throws IllegalArgumentException if key is empty String75*/76public boolean containsKey(Object key);7778/**79* Returns the value to which this map maps the specified key. Returns80* {@code null} if the map contains no mapping for this key. A return81* value of {@code null} does not <i>necessarily</i> indicate that the82* map contains no mapping for the key; it's also possible that the map83* explicitly maps the key to {@code null}. The {@code containsKey}84* operation may be used to distinguish these two cases.85*86* <p>More formally, if this map contains a mapping from a key87* {@code k} to a value {@code v} such that88* {@code (key==null ? k==null : key.equals(k))},89* then this method returns {@code v}; otherwise90* it returns {@code null}. (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, or94* {@code null} if the map contains no mapping for this key.95*96* @throws NullPointerException if key is null97* @throws ClassCastException if key is not String98* @throws IllegalArgumentException if key is empty String99*/100public Object get(Object key);101102/**103* Removes the mapping for this key from this map if it is present104* (optional operation). More formally, if this map contains a mapping105* from key {@code k} to value {@code v} such that106* {@code (key==null ? k==null : key.equals(k))}, that mapping107* 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, or110* {@code null} if the map contained no mapping for this key. (A111* {@code null} return can also indicate that the map previously112* associated {@code null} with the specified key if the implementation113* supports {@code null} values.) The map will not contain a mapping for114* 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 {@code null}118* if there was no mapping for key.119*120* @throws NullPointerException if key is null121* @throws ClassCastException if key is not String122* @throws IllegalArgumentException if key is empty String123*/124public Object remove(Object key);125}126127128