01: /*
02: * @(#)getBeanProperty.java 1.2 04/12/06
03: *
04: * Copyright (c) 2002-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.beans;
10:
11: import pnuts.lang.*;
12: import pnuts.lang.Runtime;
13:
14: /*
15: * getBeanProperty(bean, property_name)
16: */
17: public class getBeanProperty extends PnutsFunction {
18:
19: public getBeanProperty() {
20: super ("getBeanProperty");
21: }
22:
23: public boolean defined(int narg) {
24: return (narg == 2);
25: }
26:
27: protected Object exec(Object[] args, Context context) {
28: int nargs = args.length;
29: if (nargs == 2) {
30: Object bean = args[0];
31: String property = (String) args[1];
32: return Runtime.getBeanProperty(context, bean, property);
33: } else {
34: undefined(args, context);
35: return null;
36: }
37: }
38:
39: public String toString() {
40: return "function getBeanProperty(bean, property_name)";
41: }
42: }
|