Source Code : Getting and Setting a Property of a Bean
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Getting and Setting a Property of a Bean
import java.beans.Expression;
import java.beans.Statement;
public class Main {
public static void main(String[] argv) throws Exception {
Object o = new MyBean();
// Get the value of prop1
Expression expr = new Expression(o, "getProp1", new Object[0]);
expr.execute();
String s = (String) expr.getValue();
// Set the value of prop1
Statement stmt = new Statement(o, "setProp1", new Object[] { "new string" });
stmt.execute();
}
}
class MyBean {
String prop1;
public String getProp1() {
return prop1;
}
public void setProp1(String s) {
prop1 = s;
}
int prop2;
public int getProp2() {
return prop2;
}
public void setProp2(int i) {
prop2 = i;
}
byte[] prop3;
public byte[] getProp3() {
return prop3;
}
public void setProp3(byte[] bytes) {
prop3 = bytes;
}
}
Thank with us