/** * Creates a copy of this expression node, without copying children. */ @Override public Expression shallowCopy() { ASTObjPath copy = new ASTObjPath(id); copy.path = path; return copy; }
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 ASTObjPath(Object value) { super(ExpressionParserTreeConstants.JJTOBJPATH); setPath(value); }
case PROPERTY_PATH: t = jj_consume_token(PROPERTY_PATH); ASTObjPath jjtn001 = new ASTObjPath(JJTOBJPATH); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); jjtree.closeNodeScope(jjtn001, 0); jjtc001 = false; jjtn001.setPath(t.image); } finally { if (jjtc001) { jj_consume_token(25); t = jj_consume_token(PROPERTY_PATH); ASTObjPath jjtn002 = new ASTObjPath(JJTOBJPATH); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); jjtree.closeNodeScope(jjtn002, 0); jjtc002 = false; jjtn002.setPath(t.image); } finally { if (jjtc002) {
Object lastObject = new ASTObjPath(key).evaluate(entity);
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); } } } }
PathDescriptor getPathDescriptor(final ASTObjPath path) { PathDescriptor entry = pathCache.get(path.getPath()); if (entry == null) { String stringPath = (String) path.getOperand(0); final Object last = lastPathComponent(entity, stringPath); pathCache.put(path.getPath(), entry);
protected Object evaluateNode(Object o) throws Exception { return (o instanceof DataObject) ? ((DataObject) o).readNestedProperty(path) : (o instanceof Entity) ? evaluateEntityNode((Entity) o) : PropertyUtils.getProperty(o, path); }
case PROPERTY_PATH: t = jj_consume_token(PROPERTY_PATH); ASTObjPath jjtn001 = new ASTObjPath(JJTOBJPATH); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); jjtree.closeNodeScope(jjtn001, 0); jjtc001 = false; jjtn001.setPath(t.image); } finally { if (jjtc001) { jj_consume_token(65); t = jj_consume_token(PROPERTY_PATH); ASTObjPath jjtn002 = new ASTObjPath(JJTOBJPATH); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); jjtree.closeNodeScope(jjtn002, 0); jjtc002 = false; jjtn002.setPath(t.image); } finally { if (jjtc002) {
Object lastObject = new ASTObjPath(key).evaluate(entity);
@Override protected Object evaluateNode(Object o) throws Exception { return (o instanceof DataObject) ? ((DataObject) o).readNestedProperty(path) : (o instanceof Entity) ? evaluateEntityNode((Entity) o) : PropertyUtils.getProperty(o, path); }
/** * @param pathSpec a String "obj:" path. * @since 4.0 * @return a new "obj:" path expression for the specified String path. */ public static Expression pathExp(String pathSpec) { return new ASTObjPath(pathSpec); }
public ASTObjPath(Object value) { super(ExpressionParserTreeConstants.JJTOBJPATH); setPath(value); }
/** * Creates a copy of this expression node, without copying children. */ public Expression shallowCopy() { ASTObjPath copy = new ASTObjPath(id); copy.path = path; return copy; }
@Override public ASTPath getPathExp() { return new ASTObjPath(name); }
/** * @param path object path value * @return UPPER() call expression */ public static Expression upperExp(String path) { return new ASTUpper(new ASTObjPath(path)); }
/** * A convenience method to create an OBJ_PATH "greater than or equal to" expression. */ public static Expression greaterOrEqualExp(String pathSpec, Object value) { return new ASTGreaterOrEqual(new ASTObjPath(pathSpec), value); }
/** * A convenience shortcut for building BETWEEN expressions. */ public static Expression betweenExp(String pathSpec, Object value1, Object value2) { return new ASTBetween(new ASTObjPath(pathSpec), value1, value2); }
/** * A convenience shortcut for building NOT_BETWEEN expressions. */ public static Expression notBetweenExp(String pathSpec, Object value1, Object value2) { return new ASTNotBetween(new ASTObjPath(pathSpec), value1, value2); }
/** * A convenience method to create an OBJ_PATH "equal to" expression. */ public static Expression matchExp(String pathSpec, Object value) { return new ASTEqual(new ASTObjPath(pathSpec), value); }