Пример #1
0
  /**
   * Returns an Iterable instance over expression path components based on this entity.
   *
   * @since 3.0
   */
  @Override
  @SuppressWarnings("unchecked")
  public Iterable<PathComponent<ObjAttribute, ObjRelationship>> resolvePath(
      final Expression pathExp, final Map aliasMap) {

    if (pathExp.getType() == Expression.OBJ_PATH) {

      return new Iterable<PathComponent<ObjAttribute, ObjRelationship>>() {

        public Iterator iterator() {
          return new PathComponentIterator(
              ObjEntity.this, (String) pathExp.getOperand(0), aliasMap);
        }
      };
    }

    throw new ExpressionException(
        "Invalid expression type: '" + pathExp.expName() + "',  OBJ_PATH is expected.");
  }
Пример #2
0
  @Override
  public Iterator<CayenneMapEntry> resolvePathComponents(Expression pathExp)
      throws ExpressionException {

    // resolve DB_PATH if we can
    if (pathExp.getType() == Expression.DB_PATH) {
      if (getDbEntity() == null) {
        throw new ExpressionException(
            "Can't resolve DB_PATH '" + pathExp + "', DbEntity is not set.");
      }

      return getDbEntity().resolvePathComponents(pathExp);
    }

    if (pathExp.getType() == Expression.OBJ_PATH) {
      return new PathIterator((String) pathExp.getOperand(0));
    }

    throw new ExpressionException(
        "Invalid expression type: '" + pathExp.expName() + "',  OBJ_PATH is expected.");
  }