示例#1
0
  public String toString() {
    StringBuilder b = new StringBuilder();
    switch (kind) {
      case Name:
        b.append(name);
        break;
      case Function:
        if (function == Function.Item) b.append("[");
        else {
          b.append(name);
          b.append("(");
        }
        boolean first = true;
        for (ExpressionNode n : parameters) {
          if (first) first = false;
          else b.append(", ");
          b.append(n.toString());
        }
        if (function == Function.Item) b.append("]");
        else {
          b.append(")");
        }
        break;
      case Constant:
        b.append(Utilities.escapeJava(constant));
        break;
      case Group:
        b.append("(");
        b.append(group.toString());
        b.append(")");
    }
    if (inner != null) {
      b.append(".");
      b.append(inner.toString());
    }
    if (operation != null) {
      b.append(" ");
      b.append(operation.toCode());
      b.append(" ");
      b.append(opNext.toString());
    }

    return b.toString();
  }
示例#2
0
  public String check() {

    switch (kind) {
      case Name:
        if (Utilities.noString(name)) return "No Name provided @ " + location();
        break;

      case Function:
        if (function == null) return "No Function id provided @ " + location();
        for (ExpressionNode n : parameters) {
          String msg = n.check();
          if (msg != null) return msg;
        }

        break;

      case Constant:
        if (Utilities.noString(constant)) return "No Constant provided @ " + location();
        break;

      case Group:
        if (group == null) return "No Group provided @ " + location();
        else {
          String msg = group.check();
          if (msg != null) return msg;
        }
    }
    if (inner != null) {
      String msg = inner.check();
      if (msg != null) return msg;
    }
    if (operation == null) {

      if (opNext != null) return "Next provided when it shouldn't be @ " + location();
    } else {
      if (opNext == null) return "No Next provided @ " + location();
      else opNext.check();
    }
    return null;
  }
示例#3
0
  private void write(StringBuilder b) {

    switch (kind) {
      case Name:
        b.append(name);
        break;
      case Constant:
        b.append(constant);
        break;
      case Function:
        b.append(function.toCode());
        b.append('(');
        boolean f = true;
        for (ExpressionNode n : parameters) {
          if (f) f = false;
          else b.append(", ");
          n.write(b);
        }
        b.append(')');

        break;
      case Group:
        b.append('(');
        group.write(b);
        b.append(')');
    }

    if (inner != null) {
      b.append('.');
      inner.write(b);
    }
    if (operation != null) {
      b.append(' ');
      b.append(operation.toCode());
      b.append(' ');
      opNext.write(b);
    }
  }