public Element transform(ElementPathBlock el) { PathBlock before = el.getPattern(); PathBlock after = TransformDeduplicatePatterns.deduplicate(before); Element result; if(after.equals(before)) { result = el; } else { ElementPathBlock tmp = new ElementPathBlock(); tmp.getPattern().addAll(after); result = tmp; } return result; } }
public Element transform(ElementPathBlock el) { PathBlock before = el.getPattern(); PathBlock after = TransformDeduplicatePatterns.deduplicate(before); Element result; if(after.equals(before)) { result = el; } else { ElementPathBlock tmp = new ElementPathBlock(); tmp.getPattern().addAll(after); result = tmp; } return result; } }
currentPathBlock.addAll(epb.getPattern()) ; continue ;
/** Insert into a group, skip initial empty subgroups; recombining ElementPathBlock */ private static void insertIntoGroup(ElementGroup eg, Element e) { // Skip initial empty subgroup. if ( emptyGroup(e) && eg.isEmpty() ) return ; // Empty group. if ( eg.isEmpty() ) { eg.addElement(e); return ; } Element eltTop = eg.getLast() ; if ( ! ( eltTop instanceof ElementPathBlock ) ) { // Not working on a ElementPathBlock - no need to group-of-one // when inserting ElementPathBlock. e = unwrapGroupOfOnePathBlock(e) ; eg.addElement(e); return ; } if ( ! ( e instanceof ElementPathBlock ) ) { eg.addElement(e); return ; } // Combine. ElementPathBlock currentPathBlock = (ElementPathBlock)eltTop ; ElementPathBlock newPathBlock = (ElementPathBlock)e ; currentPathBlock.getPattern().addAll(newPathBlock.getPattern()); }