代码：

代码 1：

import java.beans.Expression;

import java.beans.Statement;

public class ProDemo {

public static void main(String[] args){

Object o = new MyBean();

try {

// 取得 prop1 的值

Expression expr = new Expression(o, "getProp1", new Object[0]);

expr.execute();

String s = (String)expr.getValue();

// 设置 prop1 的值

Statement stmt = new Statement(o, "setProp1", new Object[]{"new string"});

stmt.execute();

// 取得 prop2 的值

expr = new Expression(o, "getProp2", new Object[0]);

expr.execute();

int i = ((Integer)expr.getValue()).intValue();

// 设置 prop2 的值

stmt = new Statement(o, "setProp2", new Object[]{new Integer(123)});

stmt.execute();

// 取得 prop1 的值

expr = new Expression(o, "getProp3", new Object[0]);

expr.execute();

byte[] bytes = (byte[])expr.getValue();

// 设置 prop1 的值

stmt = new Statement(o, "setProp3", new Object[]{new byte[]{0x12, 0x23}});

stmt.execute();

} catch (Exception e) {

}

}

}

代码2：

public class MyBean {

//属 prop1

String prop1;

public String getProp1() {

return prop1;

}

public void setProp1(String s) {

prop1 = s;

}

// 属性 prop2

int prop2;

public int getProp2() {

return prop2;

}

public void setProp2(int i) {

prop2 = i;

}

// 属性 prop3

byte[] prop3;

public byte[] getProp3() {

return prop3;

}

public void setProp3(byte[] bytes) {

prop3 = bytes;

}

}