Esempio n. 1
0
  private Action<?> walk(AmObject cobj) {

    Action<?> action = visitor.preorderVisit(cobj, context);
    if (action == null) action = Action.next();

    final AmObject walkObj = extractWalkObject(cobj, action);
    if (walkObj != null) {
      // walk children
      UpdatingIterator it = getChildrenOf(walkObj);
      context.getAmParents().addLast(walkObj);
      while (it.hasNext()) {
        AmObject child = it.next();
        Action<?> childAction = walk(child);
        processAction(childAction, it);
      }
      context.getAmParents().removeLast();
    }

    Action<?> postAction =
        visitor.postorderVisit(walkObj != null ? walkObj : cobj, context, action);
    if (postAction == null) postAction = Action.next;

    action = action.mergeWith(postAction);
    return action;
  }
Esempio n. 2
0
 private void processAction(Action<?> action, UpdatingIterator parentIterator) {
   if (action.act == Action.Act.next || action.act == Action.Act.nextSibling) {
     // do nothing
   } else if (action.act == Action.Act.remove) {
     parentIterator.remove();
   } else if (action.act == Action.Act.replace) {
     AmObject replacement = action.getReplaceWith();
     parentIterator.set(replacement);
   } else throw new AssertionError(action);
 }