01: /*
02: * @(#)isArray.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.Context;
12: import pnuts.lang.PnutsFunction;
13:
14: public class isArray extends PnutsFunction {
15:
16: public isArray() {
17: super ("isArray");
18: }
19:
20: public boolean defined(int narg) {
21: return (narg == 1);
22: }
23:
24: protected Object exec(Object[] args, Context context) {
25: if (args.length == 1) {
26: Object obj = args[0];
27: return new Boolean(obj instanceof Object[]
28: || obj instanceof int[] || obj instanceof char[]
29: || obj instanceof boolean[]
30: || obj instanceof byte[] || obj instanceof double[]
31: || obj instanceof long[] || obj instanceof short[]
32: || obj instanceof float[]);
33: } else {
34: undefined(args, context);
35: return null;
36: }
37: }
38:
39: public String toString() {
40: return "function isArray(obj)";
41: }
42: }
|