/* * Created on Sep 9, 2003 * * To change the template for this generated file go to * Window>Preferences>Java>Code Generation>Code and Comments */ /** * @author Gong Jun * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ import org.apache.commons.jxpath.*; import java.util.*; import edu.neu.ccs.demeter.dj.*; public class Main { public static void main(String[] args) { A a = new A(); ArrayList RightD = new ArrayList(); ArrayList AllDFromC = new ArrayList(); System.out.println("****Begin output JXPath***"); JXPathContext context = JXPathContext.newContext(a); context.setLenient(true); // Iterator RDIt = context.iterate("//b/descendant-or-self::node()[not(@name='c')]"); Iterator AllDFromB_it = context.iterate("//b//d"); Iterator AllDFromC_it = context.iterate("//c//d"); while(AllDFromC_it.hasNext()) AllDFromC.add(AllDFromC_it.next()); while(AllDFromB_it.hasNext()){ boolean tag = true; D tmp1 = (D) AllDFromB_it.next(); AllDFromC_it = AllDFromC.iterator(); while(AllDFromC_it.hasNext()){ D tmp2 = (D) AllDFromC_it.next(); if(tmp1.equals(tmp2)) { tag = false; break; } } if(tag) RightD.add(tmp1); } System.out.println("List size = "+RightD.size()); Iterator RDIt = RightD.iterator(); while(RDIt.hasNext()){ System.out.println(RDIt.next()); } System.out.println("*********Start DJ*********"); ClassGraph cg = new ClassGraph(true,false); TraversalGraph tg = new TraversalGraph("from A via B bypassing C to D",cg); List result = tg.gather(a); System.out.println("List size = " + result.size()); Iterator ResultIt = result.iterator(); while(ResultIt.hasNext()){ System.out.println((D) ResultIt.next()); } } }