Exemplo n.º 1
0
  private Trail handleDefaultChild(Trail trail, Node node, EvaluationContext context) {

    // "The defaultChild missing value strategy requires the presence of the defaultChild attribute
    // in every non-leaf Node"
    String defaultChild = node.getDefaultChild();
    if (defaultChild == null) {
      throw new InvalidFeatureException(node);
    }

    trail.addMissingLevel();

    List<Node> children = node.getNodes();
    for (int i = 0, max = children.size(); i < max; i++) {
      Node child = children.get(i);

      String id = child.getId();
      if (id != null && (id).equals(defaultChild)) {
        // The predicate of the referenced Node is not evaluated
        return handleTrue(trail, child, context);
      }
    }

    // "Only Nodes which are immediate children of the respective Node can be referenced"
    throw new InvalidFeatureException(node);
  }