01: /*
02: * @(#)mapput.java 1.2 04/12/06
03: *
04: * Copyright (c) 1997-2004 Sun Microsystems, Inc. All Rights Reserved.
05: *
06: * See the file "LICENSE.txt" for information on usage and redistribution
07: * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
08: */
09: package org.pnuts.lib;
10:
11: import pnuts.lang.*;
12: import java.util.*;
13:
14: public class mapput extends PnutsFunction {
15:
16: public mapput() {
17: super ("mapput");
18: }
19:
20: public boolean defined(int nargs) {
21: return nargs == 3;
22: }
23:
24: protected Object exec(Object[] args, Context context) {
25: if (args.length != 3) {
26: undefined(args, context);
27: }
28: Map map = (Map) args[0];
29: return map.put(args[1], args[2]);
30: }
31:
32: public String toString() {
33: return "function mapput(map, key, value)";
34: }
35: }
|