new Expression(Object target, String methodName, Object[] arguments) : Expression « java.beans « Java by API






new Expression(Object target, String methodName, Object[] arguments)

  


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;
  }
}

   
    
  








Related examples in the same category

1.Expression: getValue()