void injectValue(Object source, Object value) { if (!getPath().contains(ObjEntity.PATH_SEPARATOR)) { try { if (source instanceof DataObject) { ((DataObject) source).writeProperty(getPath(), value); } else { PropertyUtils.setProperty(source, getPath(), value); } } catch (CayenneRuntimeException ex) { LOGGER.warn("Failed to inject value " + value + " on path " + getPath() + " to " + source, ex); } } } }
public void injectValue(Object o) { // try to inject value, if one of the operands is scalar, and other is a // path Node[] args = new Node[] { jjtGetChild(0), jjtGetChild(1) }; int scalarIndex = -1; if (args[0] instanceof ASTScalar) { scalarIndex = 0; } else if (args[1] instanceof ASTScalar) { scalarIndex = 1; } if (scalarIndex != -1 && args[1 - scalarIndex] instanceof ASTObjPath) { // inject ASTObjPath path = (ASTObjPath) args[1 - scalarIndex]; try { path.injectValue(o, evaluateChild(scalarIndex, o)); } catch (Exception ex) { LOGGER.warn("Failed to inject value " + " on path " + path.getPath() + " to " + o, ex); } } } }