You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by st...@apache.org on 2004/08/18 15:19:41 UTC

cvs commit: jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core Test.java

stefan      2004/08/18 06:19:41

  Modified:    proposals/jcrri/src/org/apache/slide/jcr/core Test.java
  Log:
  #0000 misc
  
  Revision  Changes    Path
  1.14      +60 -3     jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/Test.java
  
  Index: Test.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/Test.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Test.java	2 Aug 2004 16:21:05 -0000	1.13
  +++ Test.java	18 Aug 2004 13:19:41 -0000	1.14
  @@ -25,15 +25,13 @@
   import javax.jcr.nodetype.NodeTypeManager;
   import javax.jcr.util.TraversingItemVisitor;
   import java.io.*;
  -import java.util.Calendar;
  -import java.util.Properties;
  +import java.util.*;
   
   public class Test {
       private static Logger log = Logger.getLogger(Test.class);
       private static final String LOG_CONFIG_FILE_NAME = "log4j.properties";
   
       public static void main(String[] args) throws Exception {
  -
   	//String factoryHomeDir = System.getProperty("user.dir");
   	String factoryHomeDir = new File("../work").getCanonicalPath();
   
  @@ -66,6 +64,65 @@
   	t.setNamespacePrefix("bla", "http://www.jcp.org/jcr/nt/1.0");
   	ntName = root.getProperty("jcr:primaryType").getString();
   	t.setNamespacePrefix("nt", "http://www.jcp.org/jcr/nt/1.0");
  +
  +
  +	
  +
  +	TreeMap descendants = new TreeMap(new Comparator() {
  +	    public int compare(Object o1, Object o2) {
  +		Path p1 = (Path) o1;
  +		Path p2 = (Path) o2;
  +		if (p1.equals(p2)) {
  +		    return 0;
  +		}
  +		try {
  +		    if (p1.isAncestorOf(p2)) {
  +			return -1;
  +		    } else if (p1.isDescendantOf(p2)) {
  +			return 1;
  +		    }
  +		} catch (MalformedPathException mpe) {
  +		    log.warn("inconsistent hierarchy state", mpe);
  +		}
  +		// the 2 paths are not on the same graph;
  +		// do string comparison of individual path elements
  +		Path.PathElement[] pea1 = p1.getElements();
  +		Path.PathElement[] pea2 = p2.getElements();
  +		for (int i = 0; i < pea1.length; i++) {
  +		    if (i >= pea2.length) {
  +			return 1;
  +		    }
  +		    String s1 = pea1[i].toString();
  +		    String s2 = pea2[i].toString();
  +		    int result = s1.compareTo(s2);
  +		    if (result != 0) {
  +			return result;
  +		    }
  +		}
  +		return 0;
  +	    }
  +	});
  +
  +	String[] paths = new String[] {
  +	    "/b/f/m",
  +	    "/b",
  +	    "/a/d/j",
  +	    "/a/c",
  +	    "/a/d/i",
  +	    "/b/e",
  +	    "/b/f/m",
  +	};
  +	for (int pi = 0; pi < paths.length; pi++) {
  +	    descendants.put(Path.create(paths[pi], (NamespaceResolver) wsp.getNamespaceRegistry(), true), paths[pi]);
  +	}
  +	Iterator piter = descendants.values().iterator();
  +	while (piter.hasNext()) {
  +	    System.out.println(piter.next());
  +	}
  +
  +
  +
  +
   
   	System.out.println("initial...");
   	System.out.println();
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org