示例#1
0
  /** Builds query parameter line by figuring out what should be submitted */
  private StringBuilder buildParameterList(Method method, StringBuilder query) {
    for (Parameter p : ReflectionUtils.getParameters(method)) {
      QueryParameter qp = p.annotation(QueryParameter.class);
      if (qp != null) {
        String name = qp.value();
        if (name.length() == 0) name = p.name();
        if (name == null || name.length() == 0)
          continue; // unknown parameter name. we'll report the error when the form is submitted.

        RelativePath rp = p.annotation(RelativePath.class);
        if (rp != null) name = rp.value() + '/' + name;

        if (query.length() == 0) query.append("+qs(this)");

        if (name.equals("value")) {
          // The special 'value' parameter binds to the the current field
          query.append(".addThis()");
        } else {
          query.append(".nearBy('" + name + "')");
        }
        continue;
      }

      Method m = ReflectionUtils.getPublicMethodNamed(p.type(), "fromStapler");
      if (m != null) buildParameterList(m, query);
    }
    return query;
  }
示例#2
0
  private List<String> buildFillDependencies(Method method, List<String> depends) {
    for (Parameter p : ReflectionUtils.getParameters(method)) {
      QueryParameter qp = p.annotation(QueryParameter.class);
      if (qp != null) {
        String name = qp.value();
        if (name.length() == 0) name = p.name();
        if (name == null || name.length() == 0)
          continue; // unknown parameter name. we'll report the error when the form is submitted.

        RelativePath rp = p.annotation(RelativePath.class);
        if (rp != null) name = rp.value() + '/' + name;

        depends.add(name);
        continue;
      }

      Method m = ReflectionUtils.getPublicMethodNamed(p.type(), "fromStapler");
      if (m != null) buildFillDependencies(m, depends);
    }
    return depends;
  }