/** * Helper method to evaluate path expression with Cayenne Entity. */ protected Object evaluateEntityNode(Entity entity) { Iterator path = entity.resolvePathComponents(this); Object next = null; while (path.hasNext()) { next = path.next(); } return next; }
/** * Convenience method returning the last component in the path iterator. * * @since 1.1 * @see #resolvePathComponents(Expression) */ public Object lastPathComponent(Expression pathExp) { Object last = null; Iterator it = resolvePathComponents(pathExp); while (it.hasNext()) { last = it.next(); } return last; }
/** * Helper method to evaluate path expression with Cayenne Entity. */ protected CayenneMapEntry evaluateEntityNode(Entity entity) { Iterator<CayenneMapEntry> path = entity.resolvePathComponents(this); CayenneMapEntry next = null; while (path.hasNext()) { next = path.next(); } return next; }
void validateOrdering( QueryDescriptor query, Entity root, Ordering ordering, ValidationResult validationResult) { // validate paths in ordering String path = ordering.getSortSpecString(); Iterator<CayenneMapEntry> it = root.resolvePathComponents(path); while (it.hasNext()) { try { it.next(); } catch (ExpressionException e) { addFailure(validationResult, query, "Invalid ordering path: '%s'", path); } } }
ASTNode evaluateWithObject(ASTStack stack, Object bean) { // push property value on stack try { // for DataObjects it should be faster to read property via // dataObject methods instead of reflection // for entities the whole meaning is different - we should return // an iterator over attributes/relationships... stack.push((bean instanceof DataObject) ? ((DataObject) bean) .readNestedProperty(propertyPath) : (bean instanceof Entity) ? ((Entity) bean).resolvePathComponents(pathExp) : PropertyUtils.getProperty(bean, propertyPath)); } catch (Exception ex) { String beanClass = (bean != null) ? bean.getClass().getName() : "<null>"; String msg = "Error reading property '" + beanClass + "." + propertyPath + "'."; throw new ExpressionException(msg, ex); } return nextNode; }
Iterator<CayenneMapEntry> path = root.resolvePathComponents(ex); while (path.hasNext()) { path.next();