cvs -q diff -u
Index: XMLFileSystem.java
===================================================================
RCS file: /cvs/openide/src/org/openide/filesystems/XMLFileSystem.java,v
retrieving revision 1.52
diff -u -r1.52 XMLFileSystem.java
--- XMLFileSystem.java 28 Jan 2002 14:08:17 -0000 1.52
+++ XMLFileSystem.java 20 Feb 2002 10:01:12 -0000
@@ -104,6 +104,7 @@
DTD_MAP.put ("-//NetBeans//DTD Filesystem 1.1//EN", "org/openide/filesystems/filesystem1_1.dtd");//NOI18N
}
+
/** Constructor. Creates new XMLFileSystem */
public XMLFileSystem() {
Impl impl = new Impl (this);
@@ -202,6 +203,7 @@
}
private synchronized void setXmlUrls (URL[] urls, boolean validate) throws IOException, PropertyVetoException {
+long time = System.currentTimeMillis();
ResourceElem rootElem;
String oldDisplayName = getDisplayName ();
if (urls.length == 0) {
@@ -241,7 +243,12 @@
handler.urlContext = act;
xp.parse(act.toString());
}
+time = System.currentTimeMillis() - time;
+System.err.println("Parsing took " + time + "ms");
+time = System.currentTimeMillis();
refreshChildrenInAtomicAction ((AbstractFolder)getRoot (),rootElem );
+time = System.currentTimeMillis() - time;
+System.err.println("Notifying took " + time + "ms");
} catch (IOException iox) {
urlsToXml = origUrls;
throw iox;
@@ -250,11 +257,87 @@
ExternalUtil.copyAnnotation (x,e);
throw x;
} finally {
+ writeOut(rootElem);
rootElem = null;
}
firePropertyChange (PROP_DISPLAY_NAME, oldDisplayName, getDisplayName ());
}
+
+ private String space(int n) {
+ return " ".substring(0,2*n);
+ }
+
+ private void writeOut(ResourceElem root) throws IOException {
+ Writer wr = new OutputStreamWriter(new FileOutputStream("/tmp/all.xml"));
+ wr.write("\n");
+ wr.write("\n");
+ writeFolder(wr,root,1);
+ wr.write("\n");
+ wr.flush();
+ wr.close();
+ }
+
+ private void writeFolder( Writer wr, ResourceElem elem, int depth) throws IOException {
+ if(elem.children == null) return;
+ Iterator it = new TreeSet(elem.children.keySet()).iterator();
+
+ while(it.hasNext()) {
+ String name = (String)it.next();
+ ResourceElem child = (ResourceElem)elem.children.get(name);
+
+ if(child.isFolder()) {
+ wr.write(space(depth) + "\n");
+ }
+ writeFolder(wr, child, depth+1);
+ wr.write(space(depth) + "\n");
+ } else {
+ String uri = child.getURI();
+ boolean empty = true;
+ if(uri != null) {
+ wr.write(space(depth) + "\n");
+ }
+ } else {
+ empty &= writeAttrs(wr, child.getAttr(false), depth+1);
+ }
+ if(empty) {
+ wr.write("/>\n");
+ } else {
+ wr.write(space(depth) + "\n");
+ }
+ }
+ }
+
+ }
+
+ private boolean writeAttrs( Writer wr, XMLMapAttr attrs, int depth) throws IOException {
+ if (attrs == null) return true; // empty attrs
+
+ Iterator attri = new TreeSet(attrs.map.keySet()).iterator();
+ if(!attri.hasNext()) return true;
+
+ wr.write(">\n");
+ while(attri.hasNext()) {
+ String aname = (String)attri.next();
+ XMLMapAttr.Attr a = (XMLMapAttr.Attr)attrs.map.get(aname);
+ wr.write(space(depth) + "\n");
+ }
+
+ return false;
+ }
+
/**
* @return if value of lastModified should be cached
*/