public static void main(String[] args) throws Exception {
Object value = new Object();
Expression expression = new Expression(value, Object.class, "new", null);
if (!value.equals(expression.getValue()))
throw new Error("the value is updated unexpectedly");
expression.execute();
if (value.equals(expression.getValue()))
throw new Error("the value is not updated as expected");
}
java类java.beans.Expression的实例源码
Test6707226.java 文件源码
项目:openjdk9
阅读 18
收藏 0
点赞 0
评论 0
TestEncoder.java 文件源码
项目:openjdk9
阅读 16
收藏 0
点赞 0
评论 0
@Override
public void writeExpression(Expression expression) {
if (this.expression == null) {
this.expression = expression;
}
super.writeExpression(expression);
}
Test5023552.java 文件源码
项目:openjdk9
阅读 24
收藏 0
点赞 0
评论 0
protected void initialize(XMLEncoder encoder) {
encoder.setPersistenceDelegate(Container.class, new PersistenceDelegate() {
protected Expression instantiate(Object oldInstance, Encoder out) {
Container container = (Container) oldInstance;
Component component = container.getComponent();
return new Expression(container, component, "create", new Object[] {component});
}
});
}
Test4936682.java 文件源码
项目:openjdk9
阅读 21
收藏 0
点赞 0
评论 0
protected void initialize(XMLEncoder encoder) {
encoder.setPersistenceDelegate(
OuterClass.InnerClass.class,
new DefaultPersistenceDelegate() {
protected Expression instantiate(Object oldInstance, Encoder out) {
OuterClass.InnerClass inner = (OuterClass.InnerClass) oldInstance;
OuterClass outer = inner.getOuter();
return new Expression(inner, outer, "getInner", new Object[0]);
}
}
);
}
Test4679556.java 文件源码
项目:openjdk9
阅读 23
收藏 0
点赞 0
评论 0
protected void initialize(XMLEncoder encoder) {
encoder.setPersistenceDelegate(C.class, new DefaultPersistenceDelegate() {
protected Expression instantiate(Object oldInstance, Encoder out) {
C c = (C) oldInstance;
return new Expression(c, c.getX(), "createC", new Object[] {});
}
});
}
ObjectUtil.java 文件源码
项目:oson
阅读 25
收藏 0
点赞 0
评论 0
@SuppressWarnings("unchecked")
public static <E,R> R getMethodValue(E obj, Method method, Object... args) {
R value = null;
try {
method.setAccessible(true);
value = (R) method.invoke(obj, args);
} catch (InvocationTargetException | IllegalAccessException | IllegalArgumentException e) {
// e.printStackTrace();
try {
if (obj != null) {
Expression expr = new Expression(obj, method.getName(), args);
expr.execute();
value = (R) expr.getValue();
}
if (value == null) {
value = (R) method.getDefaultValue();
}
} catch (Exception e1) {
// e1.printStackTrace();
}
}
return value;
}
ObjectElementHandler.java 文件源码
项目:jdk8u_jdk
阅读 20
收藏 0
点赞 0
评论 0
/**
* Creates the value of this element.
*
* @param type the base class
* @param args the array of arguments
* @return the value of this element
* @throws Exception if calculation is failed
*/
@Override
protected final ValueObject getValueObject(Class<?> type, Object[] args) throws Exception {
if (this.field != null) {
return ValueObjectImpl.create(FieldElementHandler.getFieldValue(getContextBean(), this.field));
}
if (this.idref != null) {
return ValueObjectImpl.create(getVariable(this.idref));
}
Object bean = getContextBean();
String name;
if (this.index != null) {
name = (args.length == 2)
? PropertyElementHandler.SETTER
: PropertyElementHandler.GETTER;
} else if (this.property != null) {
name = (args.length == 1)
? PropertyElementHandler.SETTER
: PropertyElementHandler.GETTER;
if (0 < this.property.length()) {
name += this.property.substring(0, 1).toUpperCase(ENGLISH) + this.property.substring(1);
}
} else {
name = (this.method != null) && (0 < this.method.length())
? this.method
: "new"; // NON-NLS: the constructor marker
}
Expression expression = new Expression(bean, name, args);
return ValueObjectImpl.create(expression.getValue());
}
Test6707226.java 文件源码
项目:jdk8u_jdk
阅读 16
收藏 0
点赞 0
评论 0
public static void main(String[] args) throws Exception {
Object value = new Object();
Expression expression = new Expression(value, Object.class, "new", null);
if (!value.equals(expression.getValue()))
throw new Error("the value is updated unexpectedly");
expression.execute();
if (value.equals(expression.getValue()))
throw new Error("the value is not updated as expected");
}
TestEncoder.java 文件源码
项目:jdk8u_jdk
阅读 16
收藏 0
点赞 0
评论 0
@Override
public void writeExpression(Expression expression) {
if (this.expression == null) {
this.expression = expression;
}
super.writeExpression(expression);
}
Test5023552.java 文件源码
项目:jdk8u_jdk
阅读 24
收藏 0
点赞 0
评论 0
protected void initialize(XMLEncoder encoder) {
encoder.setPersistenceDelegate(Container.class, new PersistenceDelegate() {
protected Expression instantiate(Object oldInstance, Encoder out) {
Container container = (Container) oldInstance;
Component component = container.getComponent();
return new Expression(container, component, "create", new Object[] {component});
}
});
}