int op = 4;
int op = (int) (rnd.nextDouble() *5.0);
  public void transform( MarkableBaseNode base, BranchNode variant, BranchNode total,                        MarkableBaseNode baseRoot ) {    boolean editNode = false;    // Decide if node should be edited    if( ! base.isMarked() ) {      _visitCount++;      editNode = rnd.nextDouble() > 0.7;    }    BranchNode n = null; // used by edit ops    boolean after = false;    MarkableBaseNode dest = null;    if( editNode ) {      int op = 4;// (int) (rnd.nextDouble() *5.0);      switch(op) {        case 0: // Delete node          System.err.println("DEL");          dest = getLargestDelTree(base);          if( dest == null ) {            System.err.println("-- Nothing suitable to del found");            break;          }          _checkNotMarked(dest);          dest.lock();          dest.lockSubtree();          editTrees(dest,null,null,false,false);          /*          n = base.getLeft().getFullMatch();          n.getParent().removeChild(n.getChildPos());          n = base.getRight().getFullMatch();          n.getParent().removeChild(n.getChildPos());          */          break;        case 1: // Insert node          System.err.println("INS");          org.xml.sax.helpers.AttributesImpl atts = new org.xml.sax.helpers.AttributesImpl();          atts.addAttribute("","","id","CDATA",             ""+(idCounter++) ); //  rnd.nextLong()+"@"+ System.currentTimeMillis());          XMLElementNode content = new XMLElementNode("editgen:insert",atts);          after = rnd.nextDouble() > 0.5;          base.lock(!after,after);          editTrees(null,base,new BranchNode( content),after,false);          /*                    base = after ? base : (base.hasLeftSibling() ?                                 (MarkableBaseNode) base.getLeftSibling() : base);          n = base.getLeft().getFullMatch();          n.getParent().addChild(n.getChildPos()+1,new BranchNode( content));          n = base.getRight().getFullMatch();          n.getParent().addChild(n.getChildPos()+1,new BranchNode( content));          */          break;        case 2: // Update node          System.err.println("UPD");          break; // N/A for now...        case 3: // Move subtree          System.err.println("MOV");          // Delete from base (src of move) (=delete code block)          base.lock();          dest = getRandomNode( baseRoot, true, base ); // NOTE! Dest must be fetched AFTER src is locked!          after = rnd.nextDouble() > 0.5;          dest.lock(!after,after);          // Text node move check          n = dest.getLeft().getFullMatch();          Node n2 = after ? n.getRightSibling() : n.getLeftSibling();          if( base.getContent() instanceof XMLTextNode &&              ( (n.getContent() instanceof XMLTextNode) ||               ( n2 != null && n2.getContent() instanceof XMLTextNode ))) {            // NOTE: Unfortunately we have locked the dst and src, so they are no            // longer eligable for other ops after the abort :( (unlocking is not trivial)            System.err.println("-- Abort: copying text node adjacent to other text node not possible");            break;          }          editTrees(base,dest,null,after,true);          /*          BranchNode l = base.getLeft().getFullMatch();          l.getParent().removeChild(l.getChildPos());          BranchNode r = base.getRight().getFullMatch();          r.getParent().removeChild(r.getChildPos());          // Insert at dest (=insert code block)          dest.lock(!after,after);          dest = after ? dest : (dest.hasLeftSibling() ?                                 (MarkableBaseNode) dest.getLeftSibling() : dest);          n = dest.getLeft().getFullMatch();          n.getParent().addChild(n.getChildPos()+1,l);          n = dest.getRight().getFullMatch();          n.getParent().addChild(n.getChildPos()+1,r);*/          break;        case 4: // Copy subtree          // NOTE: Will currently never copy as child of a node,          // if the node does not already have children (always inserts in childlist)          System.err.println("CPY");          // Lock src of copy          base.lock();          // Insert at dest (=insert code block)          dest = getRandomNode( baseRoot, true, base ); // NOTE! Dest must be fetched AFTER src is locked!          after = rnd.nextDouble() > 0.5;          dest.lock(!after,after);          n = dest.getLeft().getFullMatch();          n2 = after ? n.getRightSibling() : n.getLeftSibling();          if( base.getContent() instanceof XMLTextNode &&              ( (n.getContent() instanceof XMLTextNode) ||               ( n2 != null && n2.getContent() instanceof XMLTextNode ))) {            // NOTE: Unfortunately we have locked the dst and src, so they are no            // longer eligable for other ops after the abort :( (unlocking is not trivial)            System.err.println("-- Abort: copying text node adjacent to other text node not possible");            break;          }          editTrees(null,dest,base,after,true);/*          n.getParent().addChild(n.getChildPos()+offset,                                 clonedAndMatchedTree(base,true,false));          n = dest.getRight().getFullMatch();          n.getParent().addChild(n.getChildPos()+offset,                                 clonedAndMatchedTree(base,false,false));*/          break;      }    } // if edit node    // recurse    for( int i=0;i<base.getChildCount();i++)      transform((MarkableBaseNode) base.getChild(i),variant,total,baseRoot);  }