Exemple #1
0
  @Override
  public boolean equals(Object o) {
    if (!(o instanceof Node)) {
      return false;
    }
    if (o == this) {
      return true;
    }
    Node other = (Node) o;

    if ((operator == null) != (other.getOperator() == null)) {
      return false;
    }
    if (operator != null && !other.getOperator().equals(operator)) {
      return false;
    }
    if (internalNodes.size() != other.getInternalNodes().size()) {
      return false;
    }
    for (int i = 0; i < internalNodes.size(); i++) {
      if (!internalNodes.get(i).equals(other.getInternalNodes().get(i))) {
        return false;
      }
    }

    return true;
  }
Exemple #2
0
  @Override
  public String toString() {
    StringBuilder builder = new StringBuilder();

    builder.append('#');
    builder.append(operator);

    if (parameters.containsKey("default")) {
      String value = parameters.get("default");
      builder.append(':');
      builder.append(escapeAsNecessary(value));
    }

    Map<String, List<Value>> parameterMap = parameters.value().map();

    if (parameterMap != null) {
      for (String key : parameterMap.keySet()) {
        if (key.equals("default")) {
          continue;
        }
        String value = parameterMap.get(key).get(0).toString();

        builder.append(':');
        builder.append(escapeAsNecessary(key));
        builder.append('=');
        builder.append(escapeAsNecessary(value));
      }
    }

    if (internalNodes.size() == 0) {
      builder.append("()");
    } else {
      builder.append("( ");
      for (Node child : internalNodes) {
        builder.append(child.toString());
        builder.append(' ');
      }
      builder.append(")");
    }

    return builder.toString();
  }
  public StructuredIterator createIterator(Node node) throws Exception {
    ArrayList<StructuredIterator> internalIterators = new ArrayList<StructuredIterator>();

    for (Node internalNode : node.getInternalNodes()) {
      StructuredIterator internalIterator = createIterator(internalNode);
      internalIterators.add(internalIterator);
    }

    StructuredIterator iterator = index.getIterator(node);
    if (iterator == null) {
      iterator = featureFactory.getIterator(node, internalIterators);
    }

    return iterator;
  }