01: /*
02: * @(#)getResource.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.PnutsFunction;
12: import pnuts.lang.Context;
13: import pnuts.lang.Pnuts;
14:
15: public class getResource extends PnutsFunction {
16: public getResource() {
17: super ("getResource");
18: }
19:
20: public boolean defined(int nargs) {
21: return nargs == 1;
22: }
23:
24: protected Object exec(Object[] args, Context context) {
25: if (args.length == 1) {
26: return Pnuts.getResource((String) args[0], context);
27: } else {
28: undefined(args, context);
29: return null;
30: }
31: }
32:
33: public String toString() {
34: return "function getResource(name)";
35: }
36: }
|