01: /*
02: * @(#)decodeBean.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 java.beans.*;
13: import java.io.*;
14:
15: /*
16: * decodeBean(inputStream)
17: */
18: public class decodeBean extends PnutsFunction {
19:
20: public decodeBean() {
21: super ("decodeBean");
22: }
23:
24: public boolean defined(int nargs) {
25: return nargs == 1;
26: }
27:
28: protected Object exec(Object[] args, Context context) {
29: int nargs = args.length;
30: if (nargs == 1) {
31: InputStream input = (InputStream) args[0];
32: XMLDecoder dec = new XMLDecoder(input);
33: return dec.readObject();
34: } else {
35: undefined(args, context);
36: return null;
37: }
38: }
39:
40: public String toString() {
41: return "function decodeBean(inputStream)";
42: }
43: }
|