incubator-depot-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject svn commit: rev 6920 - in incubator/depot/trunk/common/src/java/org/apache/depot/common/util: . classpath classpath/listener cli collection debug dom envsafe io note throwable
Date Sat, 28 Feb 2004 22:23:07 GMT
Author: mmay
Date: Sat Feb 28 14:23:06 2004
New Revision: 6920

Added:
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/IndentWriter.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/Registry.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/SystemUtils.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/Triple.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/Tuple.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/PathContext.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/PathPart.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/PathSet.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/PathWalker.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/listener/
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/listener/DirectoryListener.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/listener/DropListener.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/listener/FileContentsListener.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/listener/FileListener.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/listener/JarListener.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/listener/ManifestListener.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/listener/NameFilter.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/cli/
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/cli/CommandLine.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/cli/CommandLineParser.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/cli/Option.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/cli/Options.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/cli/ParseException.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/collection/
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/collection/EntityList.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/collection/EntryCollection.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/debug/
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/debug/DebugUtils.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/debug/Dumpable.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/dom/
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/dom/DOMConsumer.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/dom/DOMProducer.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/dom/DOMUtils.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/envsafe/
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/envsafe/ClassLoaderContext.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/envsafe/RelativelySafe.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/io/
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/io/IOUtils.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/note/
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/note/Annotation.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/note/AnnotationIterator.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/note/AnnotationScratchpad.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/throwable/
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/throwable/PortableError.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/throwable/PortableException.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/throwable/PortableRuntimeException.java
   incubator/depot/trunk/common/src/java/org/apache/depot/common/util/throwable/PortableThrowable.java
Log:
Moved from version

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/IndentWriter.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/IndentWriter.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,348 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util;
+
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.util.Stack;
+
+
+/**
+ * @author chalko
+ *
+ *	A PrintWriter that provides line indentations.
+ *
+ */
+public class IndentWriter extends PrintWriter {
+	private int m_indentLevel = 0;
+	private int m_defaultIndent = 4;
+	private String m_indentString = "";
+	private StringBuffer m_indentBuffer = new StringBuffer();
+	//TODO:  make static, but thread safe
+	private Stack m_lastLevelStack = new Stack();
+	private StringBuffer m_buffer = new StringBuffer();
+	private boolean m_indented = false;
+
+	/**
+	 * Constructor for IndentWriter.
+	 * @param out
+	 */
+	public IndentWriter(Writer out) {
+		super(out);
+	}
+
+	/**
+	 * Constructor for IndentWriter.
+	 * @param out
+	 * @param autoFlush
+	 */
+	public IndentWriter(Writer out, boolean autoFlush) {
+		super(out, autoFlush);
+	}
+
+	/**
+	 * Constructor for IndentWriter.
+	 * @param out
+	 */
+	public IndentWriter(OutputStream out) {
+		super(out);
+	}
+
+	/**
+	 * Constructor for IndentWriter.
+	 * @param out
+	 * @param autoFlush
+	 */
+	public IndentWriter(OutputStream out, boolean autoFlush) {
+		super(out, autoFlush);
+	}
+
+	/**
+	 * Returns the indentLevel.
+	 * @return int
+	 */
+	public int getIndent() {
+		return m_indentLevel;
+	}
+
+	/**
+	 * Sets the indentLevel.
+	 * @param indentLevel The indentLevel to set
+	 */
+	private void setIndent(int indent) {
+		this.m_indentLevel = Math.max(0, indent);
+		while (m_indentBuffer.length() < indent) {
+			m_indentBuffer.append("                                            ");
+		}
+		m_indentString = m_indentBuffer.substring(0, indent);
+		// clear lastLevel greater than what we are at
+		while (!m_lastLevelStack.isEmpty()
+			&& ((Integer) m_lastLevelStack.peek()).intValue() > m_indentLevel) {
+			m_lastLevelStack.pop();
+		}
+	}
+
+	/**
+	 * Increase the indent level by the defaultIndent.  
+     * Remembers the current indent level for later undenting.
+	 */
+
+	public void indent() {
+		m_lastLevelStack.push(new Integer(m_indentLevel));
+		setIndent(m_indentLevel + m_defaultIndent);
+	}
+
+	/**
+	 * Restores the previos indent level.
+	 */
+
+	public void undent() {
+		if (!m_lastLevelStack.isEmpty()) {
+			Integer i = (Integer) m_lastLevelStack.pop();
+			setIndent(i.intValue());
+		} else {
+			setIndent(0);
+		}
+	}
+	private void writeIndentIfNeeded() {
+		if (!m_indented) {
+			m_indented = true;
+			super.write(m_indentString);
+
+		}
+
+	}
+
+	/**
+	 * Returns the defaultIndent.
+	 * @return int
+	 */
+	public int getDefaultIndent() {
+		return m_defaultIndent;
+	}
+
+	/**
+	 * Sets the defaultIndent.
+	 * @param defaultIndent The defaultIndent to set
+	 */
+	public void setDefaultIndent(int defaultIndent) {
+		this.m_defaultIndent = Math.max(1, defaultIndent);
+	}
+
+	/**
+	 * @see java.io.Writer#write(char[], int, int)
+	 */
+	public void write(char[] cbuf, int off, int len) {
+		super.write(cbuf, off, len);
+		writeIndentIfNeeded();
+	}
+
+	/**
+	 * @see java.io.Writer#write(char[])
+	 */
+	public void write(char[] cbuf) {
+		super.write(cbuf);
+		writeIndentIfNeeded();
+	}
+
+	/**
+	 * @see java.io.Writer#write(int)
+	 */
+	public void write(int c) {
+		super.write(c);
+		writeIndentIfNeeded();
+	}
+
+	/**
+	 * @see java.io.Writer#write(String, int, int)
+	 */
+	public void write(String str, int off, int len) {
+		super.write(str, off, len);
+		writeIndentIfNeeded();
+	}
+
+	/**
+	 * @see java.io.Writer#write(String)
+	 */
+	public void write(String str) {
+		super.write(str);
+		writeIndentIfNeeded();
+	}
+
+	/**
+	 * @see java.io.PrintWriter#println(boolean)
+	 */
+	public void println(boolean x) {
+		writeIndentIfNeeded();
+		super.println(x);
+		m_indented = false;
+	}
+
+	/**
+	 * @see java.io.PrintWriter#println(char)
+	 */
+	public void println(char x) {
+		writeIndentIfNeeded();
+		super.println(x);
+		m_indented = false;
+	}
+
+	/**
+	 * @see java.io.PrintWriter#println(char[])
+	 */
+	public void println(char[] x) {
+		writeIndentIfNeeded();
+		super.println(x);
+		m_indented = false;
+	}
+
+	/**
+	 * @see java.io.PrintWriter#println(double)
+	 */
+	public void println(double x) {
+		writeIndentIfNeeded();
+		super.println(x);
+		m_indented = false;
+	}
+
+	/**
+	 * @see java.io.PrintWriter#println(float)
+	 */
+	public void println(float x) {
+		writeIndentIfNeeded();
+		super.println(x);
+		m_indented = false;
+	}
+
+	/**
+	 * @see java.io.PrintWriter#println(int)
+	 */
+	public void println(int x) {
+		writeIndentIfNeeded();
+		super.println(x);
+		m_indented = false;
+	}
+
+	/**
+	 * @see java.io.PrintWriter#println(long)
+	 */
+	public void println(long x) {
+		writeIndentIfNeeded();
+		super.println(x);
+		m_indented = false;
+	}
+
+	/**
+	 * @see java.io.PrintWriter#println(Object)
+	 */
+	public void println(Object x) {
+		writeIndentIfNeeded();
+		super.println(x);
+		m_indented = false;
+	}
+
+	/**
+	 * @see java.io.PrintWriter#println(String)
+	 */
+	public void println(String x) {
+		writeIndentIfNeeded();
+		super.println(x);
+		m_indented = false;
+	}
+	/**
+	 * @see java.io.PrintWriter#println()
+	 */
+	public void println() {
+		writeIndentIfNeeded();
+		super.println();
+		m_indented = false;
+	}
+
+	/**
+	 * @see java.io.PrintWriter#print(boolean)
+	 */
+	public void print(boolean b) {
+		writeIndentIfNeeded();
+		super.print(b);
+	}
+
+	/**
+	 * @see java.io.PrintWriter#print(char)
+	 */
+	public void print(char c) {
+		writeIndentIfNeeded();
+		super.print(c);
+	}
+
+	/**
+	 * @see java.io.PrintWriter#print(char[])
+	 */
+	public void print(char[] s) {
+		writeIndentIfNeeded();
+		super.print(s);
+	}
+
+	/**
+	 * @see java.io.PrintWriter#print(double)
+	 */
+	public void print(double d) {
+		writeIndentIfNeeded();
+		super.print(d);
+	}
+
+	/**
+	 * @see java.io.PrintWriter#print(float)
+	 */
+	public void print(float f) {
+		writeIndentIfNeeded();
+		super.print(f);
+	}
+
+	/**
+	 * @see java.io.PrintWriter#print(int)
+	 */
+	public void print(int i) {
+		writeIndentIfNeeded();
+		super.print(i);
+	}
+
+	/**
+	 * @see java.io.PrintWriter#print(long)
+	 */
+	public void print(long l) {
+		writeIndentIfNeeded();
+		super.print(l);
+	}
+
+	/**
+	 * @see java.io.PrintWriter#print(Object)
+	 */
+	public void print(Object obj) {
+		writeIndentIfNeeded();
+		super.print(obj);
+	}
+
+	/**
+	 * @see java.io.PrintWriter#print(String)
+	 */
+	public void print(String s) {
+		writeIndentIfNeeded();
+		super.print(s);
+	}
+
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/Registry.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/Registry.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,103 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+
+package org.apache.depot.common.util;
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.TreeMap;
+
+import org.apache.depot.common.DepotError;
+import org.apache.depot.common.util.debug.DebugUtils;
+import org.apache.depot.common.util.debug.Dumpable;
+
+/**
+ * @author ajack. 
+ */
+public class Registry implements Dumpable {
+	private TreeMap m_contents = null;
+	private boolean m_uniqueContents = false;
+
+	public Registry() {
+		m_uniqueContents = false;
+		m_contents = new TreeMap();
+	}
+
+	public Registry(boolean uniqueContents) {
+		m_uniqueContents = uniqueContents;
+		m_contents = new TreeMap();
+	}
+
+	protected void put(Object entry) {
+		put(entry, entry);
+	}
+
+	protected void put(Object key, Object entry) {
+		if (m_uniqueContents && m_contents.containsKey(key)) {
+			throw new DepotError(
+				"Can't have same item twice. Entry: " + key + " : " + entry);
+		}
+		m_contents.put(key, entry);
+	}
+
+	public Iterator iterator() {
+		return m_contents.values().iterator();
+	}
+
+	protected Object get(Object key) {
+		return m_contents.get(key);
+	}
+
+	public boolean hasEntries() {
+		return !m_contents.isEmpty();
+	}
+
+	public void dump(PrintWriter out, int depth, boolean verbose) {
+		final String indent = DebugUtils.getIndent(depth);
+		final String indent1 = DebugUtils.getIndent(depth + 1);
+
+		out.print(indent);
+		out.println("Registry :" + SystemUtils.getShortName(getClass()));
+		
+		if (hasEntries()) {
+			out.print(indent1);
+			out.println("(");
+				
+			for (Iterator i = iterator(); i.hasNext();) {
+				DebugUtils.dump(out,depth+2,verbose,(Object) i.next());
+			}
+			
+			out.print(indent1);
+			out.println(")");
+		}
+	}
+	//
+	//	public int compareTo(Object other) {
+	//		int comparison = -1;
+	//		String name = getClass().getName();
+	//		String otherName = other.getClass().getName();
+	//		comparison = name.compareTo(otherName);
+	//		return comparison;
+	//	}
+
+	public Object[] toArray() {
+		return m_contents.entrySet().toArray();
+	}
+
+	public int size() {
+		return m_contents.size();
+	}
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/SystemUtils.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/SystemUtils.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,94 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util;
+
+import java.io.File;
+import java.io.PrintWriter;
+
+/**
+ * @author ajack
+ */
+public class SystemUtils {
+
+	public static final String g_pathSeparator;
+
+	static {
+
+		// :TODO: --- BTW: Add forceLog --- to stderr if not logging..
+
+		g_pathSeparator = getSystemProperty("path.separator");
+	}
+
+	public static File getCWD() {
+		File cwd = null;
+
+		try {
+			cwd = new File(getSystemProperty("user.dir"));
+		}
+		catch (Exception e) {
+			// World of hurt...
+			// :TODO:
+		}
+
+		return cwd;
+	}
+
+	public static String getSystemProperty(String key) {
+		String value = null;
+
+		try {
+			value = System.getProperty(key);
+		}
+		catch (SecurityException se) {
+			// World of hurt...
+			// :TODO:
+		}
+
+		return value;
+	}
+
+	public static String getShortName(Object obj) {
+		return getShortName(obj.getClass().getName());
+	}
+
+	public static String getShortName(Class clazz) {
+		return getShortName(clazz.getName());
+	}
+
+	public static String getShortName(String name) {
+		String shortName = null;
+
+		int periodPos = name.lastIndexOf('.');
+
+		if (-1 != periodPos)
+			shortName = name.substring(periodPos + 1);
+		else
+			shortName = name;
+
+		return shortName;
+	}
+
+	public static PrintWriter getSystemOut() {
+		//:TODO: Singleton?
+		return new PrintWriter(System.out, true);
+	}
+
+	public static PrintWriter getSystemErr() {
+		//:TODO: Singleton?
+		return new PrintWriter(System.err, true);
+	}
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/Triple.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/Triple.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,44 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util;
+
+/**
+ * @author ajack
+ */
+public class Triple extends Tuple {
+    private Object m_third = null;
+
+    public Triple(Object first, Object second, Object third) {
+        super(first,second);
+        
+        m_third = third;
+    }
+
+	/**
+	 * @return
+	 */
+	public Object getThird() {
+		return m_third;
+	}
+
+	/**
+	 * @param object
+	 */
+	public void setThird(Object object) {
+		m_third = object;
+	}
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/Tuple.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/Tuple.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,62 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util;
+
+/**
+ * @author ajack
+ */
+public class Tuple {
+    private Object m_first = null;
+    private Object m_second = null;
+
+    public Tuple(Object first, Object second) {
+        m_first = first;
+        m_second = second;
+    }
+
+    /**
+     * Returns the first.
+     * @return Object
+     */
+    public Object getFirst() {
+        return m_first;
+    }
+
+    /**
+     * Returns the second.
+     * @return Object
+     */
+    public Object getSecond() {
+        return m_second;
+    }
+
+    /**
+     * Sets the first.
+     * @param first The first to set
+     */
+    public void setFirst(Object first) {
+        m_first = first;
+    }
+
+    /**
+     * Sets the second.
+     * @param second The second to set
+     */
+    public void setSecond(Object second) {
+        m_second = second;
+    }
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/PathContext.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/PathContext.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,162 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.classpath;
+
+import java.io.PrintWriter;
+
+import org.apache.depot.common.util.debug.DebugUtils;
+import org.apache.depot.common.util.debug.Dumpable;
+import org.apache.depot.common.util.dom.DOMProducer;
+import org.apache.depot.common.util.dom.DOMUtils;
+import org.apache.depot.common.util.envsafe.ClassLoaderContext;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * @author arb_jack
+ */
+public class PathContext implements Dumpable, DOMProducer {
+	private PathSet m_pathSet = null;
+	private ClassLoaderContext m_loaderContext = null;
+
+	public PathContext() {
+		m_pathSet = PathSet.getClasspath();
+		
+		m_loaderContext = new ClassLoaderContext(ClassLoader.getSystemClassLoader());		
+		classInit();
+	}
+
+	public PathContext(PathSet pathSet) {
+		m_pathSet = pathSet;
+		m_loaderContext = new ClassLoaderContext(ClassLoader.getSystemClassLoader());
+		classInit();
+	}
+
+	public PathContext(ClassLoader classloader) {
+		m_pathSet = PathSet.getClasspath();
+		m_loaderContext = new ClassLoaderContext(classloader);
+
+		classInit();
+	}
+
+	public PathContext(PathSet pathSet, ClassLoader classloader) {
+		m_pathSet = pathSet;
+		m_loaderContext = new ClassLoaderContext(classloader);
+		
+		classInit();
+	}
+
+	private void classInit() {
+	}
+
+	/**
+	 * @return
+	 */
+	public PathSet getPathSet() {
+		return m_pathSet;
+	}
+
+	/**
+	 * @return
+	 */
+	public ClassLoaderContext getClassLoaderContext() {
+		return m_loaderContext;
+	}
+
+	/**
+	 * @return
+	 */
+	public ClassLoader getClassLoader() {
+		return m_loaderContext.getClassLoader();
+	}
+
+	/* 
+	 * @see java.lang.Object#equals(java.lang.Object)
+	 */
+	public boolean equals(Object other) {
+		boolean equal = false;
+
+		if (other instanceof PathContext) {
+			PathContext otherPathContext = (PathContext) other;
+
+			//:TODO: Compare hierarchies also ???...
+			equal = otherPathContext.m_loaderContext.equals(m_loaderContext);
+
+			if (equal)
+				equal = otherPathContext.m_pathSet.equals(m_pathSet);
+		}
+		else
+			throw new IllegalArgumentException(
+				"Not a PathContext: " + other.getClass().getName());
+
+		return equal;
+	}
+
+	/* 
+	 * @see java.lang.Object#hashCode()
+	 */
+	public int hashCode() {
+		return m_pathSet.hashCode() + m_loaderContext.hashCode();
+	}
+
+	public void dump(PrintWriter out, int depth, boolean verbose) {
+		dumpClassLoader(out, depth, m_loaderContext.getClassLoader());
+		m_pathSet.dump(out, depth, verbose);
+	}
+
+	
+	private void dumpClassLoader(
+		PrintWriter out,
+		int depth,
+		ClassLoader classloader) {
+
+		String indent = DebugUtils.getIndent(depth);
+
+		out.print(indent);
+		out.print(classloader.getClass().getName());
+		out.print(" : ");
+		out.println(classloader.toString());
+
+		if (null != classloader.getParent()) {
+			dumpClassLoader(out, depth + 1, classloader.getParent());
+		}
+	}
+
+	public void produceDOM(Document document, Element element) {
+		Element pc = DOMUtils.insertElement(document,element,"PathContext");
+		produceClassloaderDOM(document, pc, m_loaderContext.getClassLoader());
+		m_pathSet.produceDOM(document, pc);
+	}
+
+	private void produceClassloaderDOM(
+		Document document,
+		Element element,
+		ClassLoader classloader) {
+
+		Element cl = DOMUtils.insertElement(document, element, "Classloader");
+		DOMUtils.insertAttribute(
+			document,
+			cl,
+			"type",
+			classloader.getClass().getName());
+		DOMUtils.insertText(document, cl, classloader.toString());
+
+		if (null != classloader.getParent()) {
+			produceClassloaderDOM(document, cl, classloader.getParent());
+		}
+	}
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/PathPart.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/PathPart.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,79 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.classpath;
+
+import java.io.File;
+
+/**
+ * @author ajack
+ */
+public class PathPart {
+
+	private File m_part = null;
+
+	public PathPart(String base, String part) {
+		m_part = new File(base, part);
+	}
+
+	public PathPart(File part) {
+		m_part = part;
+	}
+
+	public PathPart(String part) {
+		m_part = new File(part);
+	}
+
+	/**
+	 * Returns the part.
+	 * @return String
+	 */
+	public File getPart() {
+		return m_part;
+	}
+
+	/**
+	 * Sets the part.
+	 * @param part The part to set
+	 */
+	public void setPart(File file) {
+		m_part = file;
+	}
+
+	public String toString() {
+		return m_part.getAbsolutePath();
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#equals(java.lang.Object)
+	 */
+	public boolean equals(Object obj) {
+		boolean equal = false;
+
+		if (obj instanceof PathPart) {
+			equal = m_part.equals(((PathPart) obj).m_part);
+		}
+
+		return equal;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#hashCode()
+	 */
+	public int hashCode() {
+		return m_part.hashCode();
+	}
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/PathSet.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/PathSet.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,266 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.classpath;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.apache.depot.common.log.Logger;
+import org.apache.depot.common.util.SystemUtils;
+import org.apache.depot.common.util.collection.EntityList;
+import org.apache.depot.common.util.dom.DOMUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * @author ajack
+ */
+public class PathSet extends EntityList {
+
+	private boolean m_changed = false;
+	private String m_baseDir = null;
+
+	public static PathSet getClasspath() {
+
+		PathSet boot = PathSet.getSystemBootClasspath();
+		PathSet sys = PathSet.getSystemClasspath();
+
+		PathSet combo = new PathSet("SystemAndBootClasspaths");
+
+		boot.uniqifyOnDemand();
+		combo.addAll(boot);
+
+		sys.uniqifyOnDemand();
+		combo.addAll(sys);
+
+		return combo;
+	}
+
+	public static PathSet getSystemClasspath() {
+		String classPath = SystemUtils.getSystemProperty("java.class.path");
+
+		Logger.getLogger().debug("Class Path: " + classPath);
+
+		return new PathSet("SystemClasspath", classPath);
+	}
+
+	public static PathSet getSystemBootClasspath() {
+		String bootClassPath =
+			SystemUtils.getSystemProperty("sun.boot.class.path");
+
+		Logger.getLogger().debug("Boot Class Path: " + bootClassPath);
+
+		return new PathSet("BootClasspath", bootClassPath);
+	}
+
+	public PathSet(String id) {
+		super(id);
+		m_baseDir = getCurrentWorkingDirectory();
+	}
+
+	public PathSet(String id, String path) {
+		super(id);
+		m_baseDir = getCurrentWorkingDirectory();
+		importPath(path);
+	}
+
+	public PathSet(String id, String baseDir, String path) {
+		super(id);
+		m_baseDir = baseDir;
+		importPath(path);
+	}
+
+	/**
+	 * @param id
+	 * @param initialCapacity
+	 */
+	public PathSet(String id, int initialCapacity) {
+		super(id, initialCapacity);
+		m_baseDir = getCurrentWorkingDirectory();
+	}
+
+	public PathSet(String id, Collection collection) {
+		super(id);
+		m_baseDir = getCurrentWorkingDirectory();
+
+		for (Iterator iterator = collection.iterator(); iterator.hasNext();) {
+			add(iterator.next());
+		}
+	}
+
+	private String getCurrentWorkingDirectory() {
+		String cwd = SystemUtils.getSystemProperty("user.dir");
+		return cwd;
+	}
+
+	public void importPath(String path) {
+		for (StringTokenizer tokens =
+			new StringTokenizer(path, SystemUtils.g_pathSeparator);
+			tokens.hasMoreTokens();
+			) {
+			add(tokens.nextToken());
+		}
+	}
+
+	public void importPathSet(PathSet pathSet) {
+		for (Iterator iterator = pathSet.iterator(); iterator.hasNext();) {
+			add(iterator.next());
+		}
+	}
+
+	public List sanitize() {
+		List dropList = new ArrayList();
+		for (Iterator iter = iterator(); iter.hasNext();) {
+			PathPart pathPart = (PathPart) iter.next();
+			try {
+				//:TODO: From base?
+				File partFile = pathPart.getPart();
+
+				if (!partFile.exists() || !partFile.canRead()) {
+					dropList.add(pathPart);
+				}
+			}
+			catch (Exception e) {
+				dropList.add(pathPart);
+			}
+		}
+
+		//
+		// Drop those dodgy ones...
+		//
+		for (Iterator di = dropList.iterator(); di.hasNext();) {
+			PathPart pathPart = (PathPart) di.next();
+			remove(pathPart);
+		}
+
+		return dropList;
+	}
+
+	public Iterator iterator() {
+		//
+		// Atempt to remove duplicates
+		//
+		if (m_changed)
+			uniqifyOnDemand();
+
+		return super.iterator();
+	}
+
+	public void uniqifyOnDemand() {
+		if (m_changed) {
+
+			// Must have more than one to need doing...
+			if (size() > 1)
+				uniqify();
+
+			m_changed = false;
+		}
+	}
+
+	/**
+	 * Make a unqiue set of contents, removing duplicates.
+	 */
+	public void uniqify() {
+		EntityList newParts = new EntityList("PathSet");
+
+		//
+		// Remove duplicates, but preserve order..
+		//
+		HashSet set = new HashSet();
+
+		for (Iterator i = super.iterator(); i.hasNext();) {
+			PathPart part = (PathPart) i.next();
+
+			if (!set.contains(part)) {
+				newParts.add(part);
+				set.add(part);
+			}
+			else
+				Logger.getLogger().debug("Drop duplicate: " + part);
+		}
+
+		clear();
+		addAll(newParts);
+	}
+
+	//:TODO: Allow a "strong check" (uniquify/order) to see if two of
+	// these are the same, could save a lot of performance... 
+
+	//:TODO: add hash and equal, hmm - -they done for me?
+	// what about (1) uniqify (2) sort (3) compare...
+
+	public boolean add(Object partObject) {
+		PathPart part = null;
+
+		if (partObject instanceof PathPart)
+			part = (PathPart) partObject;
+		if (partObject instanceof File)
+			part = new PathPart((File)partObject);
+		if (partObject instanceof String)
+			part = new PathPart((String)partObject);
+
+		m_changed = true;
+
+		return super.add(part);
+	}
+
+	/* (non-Javadoc)
+	 * @see java.util.List#add(int, java.lang.Object)
+	 */
+	public void add(int posn, Object partObject) {
+		PathPart part = null;
+
+		if (partObject instanceof PathPart)
+			part = (PathPart) partObject;
+		if (partObject instanceof File)
+			part = new PathPart((File)partObject);
+		if (partObject instanceof String)
+			part = new PathPart((String)partObject);
+
+		m_changed = true;
+
+		super.add(posn, part);
+	}
+
+	/* (non-Javadoc)
+	 * @see java.util.Collection#addAll(java.util.Collection)
+	 */
+	public boolean addAll(Collection arg0) {
+		m_changed = true;
+		return super.addAll(arg0);
+	}
+
+	/* (non-Javadoc)
+	 * @see java.util.List#addAll(int, java.util.Collection)
+	 */
+	public boolean addAll(int arg0, Collection arg1) {
+		m_changed = true;
+		return super.addAll(arg0, arg1);
+	}
+	
+
+	public void produceDOM(Document document, Element element) {
+		Element ps = DOMUtils.insertElement(document,element,"PathSet");
+		DOMUtils.insertAttribute(document,ps,"name",getName());
+		DOMUtils.produceDOM(document, ps, iterator());
+	}
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/PathWalker.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/PathWalker.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,612 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+
+package org.apache.depot.common.util.classpath;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.apache.depot.common.log.Logger;
+import org.apache.depot.common.util.Tuple;
+import org.apache.depot.common.util.classpath.listener.DirectoryListener;
+import org.apache.depot.common.util.classpath.listener.DropListener;
+import org.apache.depot.common.util.classpath.listener.FileContentsListener;
+import org.apache.depot.common.util.classpath.listener.FileListener;
+import org.apache.depot.common.util.classpath.listener.JarListener;
+import org.apache.depot.common.util.classpath.listener.ManifestListener;
+import org.apache.depot.common.util.classpath.listener.NameFilter;
+
+//
+// :TODO: Load the JAR using the current classloader (to get right one)
+//
+
+/**
+ *
+ * @author Adam R. B. Jack. 
+ */
+public class PathWalker {
+
+	private final static File ROOT = new File("/");
+
+	//
+	//
+	//
+	private PathSet m_pathSet = null;
+
+	//
+	// Listeners
+	//
+	private ArrayList m_fileListeners = null;
+	private ArrayList m_fileContentsListeners = null;
+	private ArrayList m_directoryListeners = null;
+	private ArrayList m_jarListeners = null;
+	private ArrayList m_manifestListeners = null;
+
+	private ArrayList m_dropListeners = null;
+
+	/**
+	 * @param base -- $CWD for this activity
+	 * @param pathSet
+	 */
+	public PathWalker(PathSet pathSet) {
+		m_pathSet = pathSet;
+		initialize();
+	}
+
+	private void initialize() {
+	}
+
+	public void registerListener(Object listener) {
+		registerListener(listener, null);
+	}
+
+	public void registerListener(Object listener, Object context) {
+		if (listener instanceof ManifestListener)
+			registerManifestListener((ManifestListener) listener, context);
+
+		if (listener instanceof JarListener)
+			registerJarListener((JarListener) listener, context);
+
+		if (listener instanceof FileListener)
+			registerFileListener((FileListener) listener, context);
+
+		if (listener instanceof FileContentsListener)
+			registerFileContentsListener(
+				(FileContentsListener) listener,
+				context);
+
+		if (listener instanceof DirectoryListener)
+			registerDirectoryListener((DirectoryListener) listener, context);
+
+		if (listener instanceof DropListener)
+			registerDropListener((DropListener) listener, context);
+	}
+
+	public void registerFileListener(
+		FileListener fileListener,
+		Object context) {
+		if (null == m_fileListeners)
+			m_fileListeners = new ArrayList();
+
+		m_fileListeners.add(new Tuple(fileListener, context));
+	}
+
+	public void registerFileContentsListener(
+		FileContentsListener fileContentsListener,
+		Object context) {
+		if (null == m_fileContentsListeners)
+			m_fileContentsListeners = new ArrayList();
+
+		m_fileContentsListeners.add(new Tuple(fileContentsListener, context));
+	}
+
+	public void registerDirectoryListener(
+		DirectoryListener dirListener,
+		Object context) {
+		if (null == m_directoryListeners)
+			m_directoryListeners = new ArrayList();
+
+		m_directoryListeners.add(new Tuple(dirListener, context));
+	}
+
+	public void registerDropListener(
+		DropListener dropListener,
+		Object context) {
+		if (null == m_dropListeners)
+			m_dropListeners = new ArrayList();
+
+		m_dropListeners.add(new Tuple(dropListener, context));
+	}
+
+	public void registerManifestListener(
+		ManifestListener manifestListener,
+		Object context) {
+		if (null == m_manifestListeners)
+			m_manifestListeners = new ArrayList();
+
+		m_manifestListeners.add(new Tuple(manifestListener, context));
+	}
+
+	public void registerJarListener(JarListener jarListener, Object context) {
+		if (null == m_jarListeners)
+			m_jarListeners = new ArrayList();
+
+		m_jarListeners.add(new Tuple(jarListener, context));
+	}
+
+	/**
+	 * 
+	 */
+	public void walk() {
+
+//		System.out.println("Walk the path....");
+
+		// Anything to do?
+		if ((null == m_fileListeners)
+			&& (null == m_fileContentsListeners)
+			&& (null == m_manifestListeners)
+			&& (null == m_directoryListeners)
+			&& (null == m_jarListeners))
+			return;
+
+		//
+		// Sanitize the pathset
+		// :TODO: Bad Side Effect?
+		//
+		List dropList = m_pathSet.sanitize();
+		if (null != m_dropListeners)
+			processDrops(dropList);
+
+		boolean searchJarContents =
+			(null != m_fileListeners)
+				|| (null != m_fileContentsListeners)
+				|| (null != m_manifestListeners)
+				|| (null != m_directoryListeners);
+
+		boolean searchDirContents =
+			(null != m_fileListeners) || (null != m_fileContentsListeners);
+
+		for (Iterator parts = m_pathSet.iterator(); parts.hasNext();) {
+			PathPart pathPart = (PathPart) parts.next();
+			//
+			//    Get an abstract file for this.
+			//
+			//    Todo -- Hmm, load via class loader?
+			//
+			File file = pathPart.getPart();
+			String fileName = file.getAbsolutePath();
+
+//			System.out.println("File:" + file);
+
+			if (file.exists()) {
+				if (file.isFile()) {
+					//
+					// Process This file
+					//
+					if (fileName.endsWith(".jar")) {
+						processJar(file, fileName);
+
+						if (searchJarContents)
+							walkIntoJAR(file);
+					}
+					else
+						processFile(file, ROOT, fileName);
+				}
+				else {
+					//
+					// Process This file
+					//
+					processDirectory(file, fileName);
+
+					if (searchDirContents)
+						walkIntoDirectory(file);
+				}
+			}
+			else {
+				//:TODO: add a "sanitize" path -- someday, this is too
+				// verbose...
+				Logger.getLogger().debug(
+					"Invalid part in path [" + file + "]");
+			}
+		}
+	}
+
+	private void walkIntoJAR(File jar) {
+//		System.out.println("Walk JAR: " + jar);
+
+		try {
+			JarFile jf = new JarFile(jar);
+
+			Manifest manifest = jf.getManifest();
+
+			if ((null != manifest) && (null != m_manifestListeners)) {
+				//System.out.println("Process Manifest: " + manifest);
+				processManifest(jar, manifest);
+			}
+
+			if (null != m_fileListeners) {
+				for (Enumeration e = jf.entries(); e.hasMoreElements();) {
+
+					JarEntry entry = (JarEntry) e.nextElement();
+
+					//System.out.println("Entry: " + entry);
+
+					File entryFile = new File(entry.getName());
+
+					if (null != m_fileListeners)
+						processFile(entryFile, ROOT, "JAR:" + jar.getName());
+
+					if (null != m_fileContentsListeners) {
+
+						if (!filter(entry.getName(),
+							m_fileContentsListeners)) {
+							InputStream contents = null;
+							try {
+								contents = jf.getInputStream(entry);
+
+								processFileContents(
+									entryFile,
+									ROOT,
+									contents,
+									"JAR:" + jar.getName());
+							}
+							finally {
+								if (null != contents)
+									try {
+										contents.close();
+									}
+									catch (Exception ee) {
+									};
+							}
+						}
+					}
+				}
+			}
+		}
+		catch (Throwable t) {Logger.getLogger().error("Throwable:" + jar + ")", t);
+		}
+	}
+
+	private void walkIntoDirectory(File directory) {
+		walkIntoDirectory(directory, null, directory);
+	}
+
+	private void walkIntoDirectory(File directory, String path, File root) {
+		//System.out.println("Walk Directory: " + directory + "\t" + root);
+
+		String[] files = directory.list();
+
+		if ((null != files) && (null != m_fileListeners))
+			for (int i = 0; i < files.length; i++) {
+				String fileName = files[i];
+
+				String pathName =
+					(null != path) ? path + "/" + fileName : fileName;
+				File file = new File(root, pathName);
+
+				if (file.exists()) {
+					if (file.isFile()) {
+						processFile(
+							file,
+							root,
+							"File:" + directory.getAbsolutePath());
+
+						if (null != m_fileContentsListeners) {
+
+							if (!filter(fileName, m_fileContentsListeners)) {
+								InputStream contents = null;
+								try {
+									File absoluteFile =
+										new File(root, file.getPath());
+
+									contents =
+										new FileInputStream(
+											absoluteFile.getAbsoluteFile());
+
+									processFileContents(
+										file,
+										root,
+										contents,
+										"File:" + file);
+								}
+								catch (Exception fe) {
+									Logger.getLogger().error(
+										"Exception opening file: " + file,
+										fe);
+								}
+								finally {
+									if (null != contents)
+										try {
+											contents.close();
+										}
+										catch (Exception ee) {
+										};
+								}
+							}
+						}
+					}
+					else {
+						String dirName = file.getName();
+						String subPath =
+							((null != path) ? path + "." + dirName : dirName);
+						walkIntoDirectory(file, subPath, root);
+					}
+				}
+				else
+					Logger.getLogger().debug(
+						"Invalid part in path [" + file + "]");
+			}
+	}
+
+	private void processDirectory(File directory, String location) {
+		for (Iterator listeners = m_directoryListeners.iterator();
+			listeners.hasNext();
+			) {
+			Tuple tuple = (Tuple) listeners.next();
+			DirectoryListener listener = (DirectoryListener) tuple.getFirst();
+			Object context = tuple.getSecond();
+
+			//
+			// Filter (or not) based off name
+			//
+			boolean filter = false;
+
+			if (listener instanceof NameFilter)
+				filter =
+					((NameFilter) listener).filter(
+						directory.getAbsolutePath(),
+						context);
+
+			if (!filter)
+				listener.processDirectory(
+					tuple.getSecond(),
+					directory,
+					location);
+		}
+	}
+
+	private void processJar(File file, String location) {
+		for (Iterator listeners = m_jarListeners.iterator();
+			listeners.hasNext();
+			) {
+			Tuple tuple = (Tuple) listeners.next();
+
+			JarListener listener = (JarListener) tuple.getFirst();
+			Object context = tuple.getSecond();
+
+			//
+			// Filter (or not) based off name
+			//
+			boolean filter = false;
+
+			if (listener instanceof NameFilter)
+				filter =
+					((NameFilter) listener).filter(
+						file.getAbsolutePath(),
+						context);
+
+			if (!filter)
+				listener.processJar(tuple.getSecond(), file, location);
+		}
+	}
+
+	private void processManifest(File file, Manifest manifest) {
+		for (Iterator listeners = m_manifestListeners.iterator();
+			listeners.hasNext();
+			) {
+			Tuple tuple = (Tuple) listeners.next();
+
+			ManifestListener listener = (ManifestListener) tuple.getFirst();
+			Object context = tuple.getSecond();
+
+			//
+			// Filter (or not) based off name
+			//
+			boolean filter = false;
+
+			if (listener instanceof NameFilter)
+				filter =
+					((NameFilter) listener).filter(
+						file.getAbsolutePath(),
+						context);
+
+			if (!filter)
+				listener.processManifest(tuple.getSecond(), file, manifest);
+		}
+	}
+
+	private void processFile(File file, File rootDir, String location) {
+
+		Logger.getLogger().debug(
+			"Process File:" + file + "[" + location + "]");
+
+		//System.out.println(
+		//			"Process File:" + file + "[" + location + "]");
+
+		for (Iterator listeners = m_fileListeners.iterator();
+			listeners.hasNext();
+			) {
+
+			//
+			// This listener w/ their context
+			//
+			Tuple tuple = (Tuple) listeners.next();
+
+			FileListener listener = ((FileListener) (tuple.getFirst()));
+			Object context = tuple.getSecond();
+
+			//
+			// Filter (or not) based off name
+			//
+			boolean filter = false;
+
+			if (listener instanceof NameFilter)
+				filter =
+					((NameFilter) listener).filter(
+						file.getAbsolutePath(),
+						context);
+
+			if (!filter) {
+				listener.processFile(context, file, rootDir, location);
+			}
+		}
+	}
+
+	private void processDrops(List list) {
+
+		for (Iterator dropies = list.iterator(); dropies.hasNext();) {
+			PathPart entity = (PathPart) dropies.next();
+
+			Logger.getLogger().debug("Process Drop:" + entity + "]");
+
+			for (Iterator listeners = m_dropListeners.iterator();
+				listeners.hasNext();
+				) {
+
+				//
+				// This listener w/ their context
+				//
+				Tuple tuple = (Tuple) listeners.next();
+
+				DropListener listener = ((DropListener) (tuple.getFirst()));
+				listener.processDropped(tuple.getSecond(), entity);
+			}
+		}
+	}
+
+	private void processFileContents(
+		File file,
+		File rootDir,
+		InputStream fileContents,
+		String location) {
+
+		Logger.getLogger().debug(
+			"Process File:" + file + "[" + location + "]");
+
+		int readers = 0;
+		for (Iterator listeners = m_fileContentsListeners.iterator();
+			listeners.hasNext();
+			) {
+
+			//
+			// This listener w/ their context
+			//
+			Tuple tuple = (Tuple) listeners.next();
+
+			FileContentsListener listener =
+				((FileContentsListener) (tuple.getFirst()));
+			Object context = tuple.getSecond();
+
+			//
+			// Filter (or not) based off name
+			//
+			boolean filter = false;
+
+			if (listener instanceof NameFilter)
+				filter =
+					((NameFilter) listener).filter(
+						file.getAbsolutePath(),
+						context);
+
+			if (!filter) {
+
+				if (++readers > 1) {
+					//:TODO: Nasty bug w/ contents already read, can't
+					// easily reset to start, have to re-code to open 
+					// each time. Harder for in JAR...
+					throw new IllegalStateException("Can't have two readers on one stream, need to re-code.");
+				}
+
+				listener.processFile(
+					context,
+					file,
+					rootDir,
+					fileContents,
+					location);
+			}
+		}
+	}
+
+	private boolean filterFile(String name) {
+		boolean filter = true;
+
+		if (filter)
+			filter = filter(name, m_fileListeners);
+
+		if (filter)
+			filter = filter(name, m_fileContentsListeners);
+
+		return filter;
+	}
+
+	/**
+	 * 
+	 * Goes throgu a list of listeners and *ALL* are NameFilters
+	 * and *ALL* don't want it, return "true".
+	 * 
+	 * @param name
+	 * @param listenerList
+	 * @return
+	 */
+	private boolean filter(String name, List listenerList) {
+		boolean filter = true;
+
+		for (Iterator listeners = listenerList.iterator();
+			listeners.hasNext() && filter;
+			) {
+
+			//
+			// This listener w/ their context
+			//
+			Tuple tuple = (Tuple) listeners.next();
+
+			Object listener = tuple.getFirst();
+			Object context = tuple.getSecond();
+
+			if (listener instanceof NameFilter) {
+				filter &= ((NameFilter) listener).filter(name, context);
+			}
+			else
+				filter = false;
+		}
+		return filter;
+	}
+
+	/**
+	 * Returns the pathSet.
+	 * @return PathSet
+	*/
+	public PathSet getPathSet() {
+		return m_pathSet;
+	}
+
+	/**
+	 * Sets the pathSet.
+	 * @param pathSet The pathSet to set
+	*/
+	public void setPathSet(PathSet pathSet) {
+		m_pathSet = pathSet;
+	}
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/listener/DirectoryListener.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/listener/DirectoryListener.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,27 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.classpath.listener;
+
+import java.io.File;
+
+/**
+ * @author ajack
+ */
+public interface DirectoryListener
+{
+	void processDirectory(Object context, File directory, String location);
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/listener/DropListener.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/listener/DropListener.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,28 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.classpath.listener;
+
+import org.apache.depot.common.util.classpath.PathPart;
+
+
+/**
+ * @author ajack
+ */
+public interface DropListener
+{
+	void processDropped(Object context, PathPart entry);
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/listener/FileContentsListener.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/listener/FileContentsListener.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,28 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.classpath.listener;
+
+import java.io.File;
+import java.io.InputStream;
+
+/**
+ * @author ajack
+ */
+public interface FileContentsListener
+{
+	void processFile(Object context, File file, File root, InputStream contents, String location);
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/listener/FileListener.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/listener/FileListener.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,27 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.classpath.listener;
+
+import java.io.File;
+
+/**
+ * @author ajack
+ */
+public interface FileListener
+{
+	void processFile(Object context, File file, File root, String location);
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/listener/JarListener.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/listener/JarListener.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,26 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.classpath.listener;
+
+import java.io.File;
+
+/**
+ * @author ajack
+ */
+public interface JarListener {
+	void processJar(Object context, File jar, String location);
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/listener/ManifestListener.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/listener/ManifestListener.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,27 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.classpath.listener;
+
+import java.io.File;
+import java.util.jar.Manifest;
+
+/**
+ * @author ajack
+ */
+public interface ManifestListener {
+    void processManifest(Object context, File jar, Manifest manifest);
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/listener/NameFilter.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/classpath/listener/NameFilter.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,25 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.classpath.listener;
+
+
+/**
+ * @author ajack
+ */
+public interface NameFilter {
+    boolean filter(String name, Object context);
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/cli/CommandLine.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/cli/CommandLine.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,142 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.cli;
+
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.depot.common.util.collection.EntityList;
+import org.apache.depot.common.util.debug.DebugUtils;
+import org.apache.depot.common.util.debug.Dumpable;
+
+/**
+ *
+ * @author $Author: arb_jack $
+ * @version $Revision: 1.8 $
+ * 
+ */
+public class CommandLine implements Dumpable {
+	private static final String EMPTY_ARRAY[] = new String[0];
+
+	private Map m_options = null;
+
+	public CommandLine() {
+		m_options = new HashMap();
+	}
+
+	public void addOption(Option option) {
+		addOption(option, "");
+	}
+
+	public void addOption(Option option, String argument) {
+		List values = (List) m_options.get(option);
+
+		if (null == values) {
+			values = new EntityList("Args:" + option.getOpt());
+			m_options.put(option, values);
+		}
+
+		values.add(argument);
+	}
+
+	public String[] getMandatoryOptionValues(Option option)
+		throws ParseException {
+		String[] values = getOptionValues(option);
+
+		if (null == values)
+			throw new ParseException("Missing mandatory option : " + option);
+
+		return values;
+	}
+
+	public String[] getOptionValues(Option option) {
+		String array[] = null;
+
+		List values = (List) m_options.get(option);
+
+		if (null != values) {
+			Object stuff[] = values.toArray();
+			String sarray[] = new String[stuff.length];
+			for (int i = 0; i < stuff.length; ++i) {
+				sarray[i] = (String) stuff[i];
+			}
+
+			array = sarray;
+		}
+		else
+			array = EMPTY_ARRAY;
+
+		return array;
+	}
+
+	public String getMandatoryOptionValue(Option option)
+		throws ParseException {
+		return getMandatoryOptionValue(option, null);
+	}
+
+	public String getMandatoryOptionValue(Option option, String defaultValue)
+		throws ParseException {
+		String value = getOptionValue(option, defaultValue);
+
+		if ((null == value) || (0 == value.length()))
+			throw new ParseException("Missing mandatory option: " + option);
+
+		return value;
+	}
+
+	public String getOptionValue(Option option) {
+		return getOptionValue(option, null);
+	}
+
+	public String getOptionValue(Option option, String defaultValue) {
+
+		String array[] = getOptionValues(option);
+		String value = null;
+
+		if (1 <= array.length) {
+			value = array[0];
+		}
+
+		if (null == value)
+			value = defaultValue;
+
+		return value;
+	}
+
+	public boolean isSet(Option option) {
+		return (null != m_options.get(option));
+	}
+
+	public boolean hasArguments() {
+		return !(m_options.isEmpty());
+	}
+
+	public void print() {
+		DebugUtils.dump("Command Line Provided: ", m_options);
+	}
+
+	public void dump(PrintWriter out, int depth, boolean verbose) {
+		String indent = DebugUtils.getIndent(depth);
+
+		out.print(indent);
+		out.println("Command Line: ");
+
+		DebugUtils.dump(m_options);
+	}
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/cli/CommandLineParser.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/cli/CommandLineParser.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,97 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.cli;
+
+/**
+ *
+ * @author $Author: arb_jack $
+ * @version $Revision: 1.4 $
+ * 
+ */
+public class CommandLineParser {
+    private boolean m_strict = true;
+    
+    public CommandLine parse(Options options, String args[])
+        throws ParseException {
+        CommandLine cl = new CommandLine();
+
+        if (null != args)
+            for (int i = 0; i < args.length; ++i) {
+                
+                boolean skip = false;
+                String opt = args[i];
+
+                if (opt.startsWith("/") || opt.startsWith("-"))
+                    opt = opt.substring(1);
+                else {
+                    if (m_strict)
+                        throw new ParseException(
+                            "Unrecognizable option ["
+                                + opt
+                                + "]. Options look like -a or /a");
+                    else
+                        skip = true;
+                }
+
+                if (!skip) {
+                    Option option = options.getOption(opt);
+
+                    if (null == option)
+                        if (m_strict)
+                            throw new ParseException(
+                                "Unknown option ["
+                                    + opt
+                                    + "]. Not in "
+                                    + options.getOptionsString());
+                        else
+                            skip = true;
+
+                    if (!skip) {
+                        if (option.isHasArg()) {
+                            i++;
+
+                            if (i >= args.length)
+                                throw new ParseException(
+                                    "Missing argument for [" + option + "]");
+
+                            String arg = args[i];
+
+                            cl.addOption(option, arg);
+                        }
+                        else
+                            cl.addOption(option);
+                    }
+                }
+            }
+
+        return cl;
+    }
+    
+    /**
+     * @return
+     */
+    public boolean isStrict() {
+        return m_strict;
+    }
+
+    /**
+     * @param b
+     */
+    public void setStrict(boolean b) {
+        m_strict = b;
+    }
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/cli/Option.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/cli/Option.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,167 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.cli;
+
+/**
+ *
+ * @author $Author: arb_jack $
+ * @version $Revision: 1.4 $
+ * 
+ */
+public class Option implements Comparable {
+	private String m_opt = null;
+	private String m_longOpt = null;
+	private boolean m_hasArg = false;
+	private String m_desc = null;
+
+	public Option(String opt, boolean hasArg, String desc) {
+		m_opt = opt;
+		m_hasArg = hasArg;
+		m_desc = desc;
+
+	}
+
+	public Option(String opt, String longOpt, boolean hasArg, String desc) {
+		m_opt = opt;
+		m_longOpt = longOpt;
+		m_hasArg = hasArg;
+		m_desc = desc;
+	}
+
+	/**
+	 * Returns the desc.
+	 * @return String
+	 */
+	public String getDesc() {
+		return m_desc;
+	}
+
+	/**
+	 * Returns the hasArg.
+	 * @return boolean
+	 */
+	public boolean isHasArg() {
+		return m_hasArg;
+	}
+
+	/**
+	 * Returns the longOpt.
+	 * @return String
+	 */
+	public String getLongOpt() {
+		return m_longOpt;
+	}
+
+	/**
+	 * Returns the opt.
+	 * @return String
+	 */
+	public String getOpt() {
+		return m_opt;
+	}
+
+	/**
+	 * Sets the desc.
+	 * @param desc The desc to set
+	 */
+	public void setDesc(String desc) {
+		m_desc = desc;
+	}
+
+	/**
+	 * Sets the hasArg.
+	 * @param hasArg The hasArg to set
+	 */
+	public void setHasArg(boolean hasArg) {
+		m_hasArg = hasArg;
+	}
+
+	/**
+	 * Sets the longOpt.
+	 * @param longOpt The longOpt to set
+	 */
+	public void setLongOpt(String longOpt) {
+		m_longOpt = longOpt;
+	}
+
+	/**
+	 * Sets the opt.
+	 * @param opt The opt to set
+	 */
+	public void setOpt(String opt) {
+		m_opt = opt;
+	}
+
+	public String toString() {
+		return"-"
+			+ m_opt
+			+ ((null != m_longOpt) ? (" [or -" + m_longOpt) +"]": "")
+			+ (m_hasArg ? " {argument}" : "") + " : " +  m_desc;
+	}
+
+	public int compareTo(Object other) {
+		int comparison = -1;
+		if (null == other) {
+			comparison = -1;
+		}
+		else if (other instanceof Option) {
+			Option otherOption = (Option) other;
+
+			comparison = m_opt.compareTo(otherOption.m_opt);
+
+			if (0 == comparison)
+				if (null != m_longOpt)
+					if (null != otherOption.m_longOpt)
+						comparison = m_longOpt.compareTo(otherOption.m_longOpt);
+					else
+						comparison = -1;
+				else if (null != otherOption.m_longOpt)
+					comparison = -1;
+
+			if (0 == comparison)
+				comparison = (m_opt == otherOption.m_opt) ? 0 : -1;
+
+			if (0 == comparison)
+				comparison = (m_desc.compareTo(otherOption.m_desc));
+		}
+		else
+			throw new IllegalArgumentException(
+				"Not an 'Option':"
+					+ other.getClass().getName()
+					+ ":"
+					+ other.toString());
+
+		return comparison;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#equals(java.lang.Object)
+	 */
+	public boolean equals(Object arg0) {
+		// TODO Auto-generated method stub
+		return m_opt.equals(((Option) arg0).m_opt);
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#hashCode()
+	 */
+	public int hashCode() {
+		// TODO Auto-generated method stub
+		return m_opt.hashCode();
+	}
+
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/cli/Options.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/cli/Options.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,103 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.cli;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ * @author $Author: arb_jack $
+ * @version $Revision: 1.3 $
+ * 
+ */
+public class Options {
+    private List m_options = null;
+    private Map m_optKey = null;
+    private Map m_longOptKey = null;
+
+    public Options() {
+        m_options = new ArrayList();
+        m_optKey = new HashMap();
+        m_longOptKey = new HashMap();
+    }
+
+    public void addOption(String opt, boolean hasArg, String desc) {
+        addOption(new Option(opt, hasArg, desc));
+    }
+
+    public void addOption(
+        String opt,
+        String logOpt,
+        boolean hasArg,
+        String desc) {
+        addOption(new Option(opt, logOpt, hasArg, desc));
+    }
+
+    public void addOption(Option option) {
+        m_options.add(option);
+
+        if (m_optKey.containsKey(option.getOpt()))
+            throw new Error("Duplicate CommandLine Option [" + option + "]");
+
+        m_optKey.put(option.getOpt(), option);
+
+        if (null != option.getLongOpt())
+            m_longOptKey.put(option.getLongOpt(), option);
+    }
+
+    public Option getOption(String opt) {
+        Option option = (Option) m_optKey.get(opt);
+
+        if (null == option)
+            option = (Option) m_longOptKey.get(opt);
+
+        return option;
+    }
+
+    public String getOptionsString() {
+        StringBuffer list = new StringBuffer();
+
+        for (Iterator i = m_options.iterator(); i.hasNext();) {
+            Option option = (Option) i.next();
+
+            list.append(option.getOpt());
+            if (null != option.getLongOpt()) {
+                list.append("(");
+                list.append(option.getLongOpt());
+                list.append(")");
+            }
+
+            if (i.hasNext())
+                list.append(" ");
+        }
+
+        return list.toString();
+    }
+
+    public void display() {
+		System.out.println("Command Line Options:");
+        for (Iterator i = m_options.iterator(); i.hasNext();) {
+            Option option = (Option) i.next();
+            System.out.print("  ");
+            System.out.println(option);
+        }
+    }
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/cli/ParseException.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/cli/ParseException.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,61 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.cli;
+
+import org.apache.depot.common.DepotException;
+
+/**
+ *
+ * @author $Author: arb_jack $
+ * @version $Revision: 1.2 $
+ * 
+ */
+public class ParseException extends DepotException {
+
+    /**
+     * Constructor for ParseException.
+     */
+    public ParseException() {
+        super();
+    }
+
+    /**
+     * Constructor for ParseException.
+     * @param message
+     */
+    public ParseException(String message) {
+        super(message);
+    }
+
+    /**
+     * Constructor for ParseException.
+     * @param message
+     * @param cause
+     */
+    public ParseException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    /**
+     * Constructor for ParseException.
+     * @param cause
+     */
+    public ParseException(Throwable cause) {
+        super(cause);
+    }
+
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/collection/EntityList.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/collection/EntityList.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,204 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.collection;
+
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.depot.common.util.debug.DebugUtils;
+import org.apache.depot.common.util.debug.Dumpable;
+import org.apache.depot.common.util.dom.DOMProducer;
+import org.apache.depot.common.util.dom.DOMUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * @version $Revision: $
+ */
+public class EntityList extends ArrayList implements Dumpable, Comparable, DOMProducer {
+
+	private String m_name = null;
+
+	/**
+	 * Limiting to a max size (FIFO = First In, First Out)
+	 */
+	private int m_maxSize = 0;
+
+	/**
+	 * Constructor for ConstraintSet.
+	 * @param initialCapacity
+	 */
+	public EntityList(String name, int initialCapacity) {
+		super(initialCapacity);
+		m_name = name;
+		init();
+	}
+
+	/**
+	 * Constructor for ConstraintSet.
+	 */
+	public EntityList(String name) {
+		super();
+		m_name = name;
+		init();
+	}
+
+	/**
+	 * Constructor for ConstraintSet.
+	 * @param c
+	 */
+	public EntityList(String name, Collection c) {
+		super(c);
+		m_name = name;
+		init();
+	}
+
+	private void init() {
+		if (null == m_name)
+			m_name = "EntitySet";
+	}
+
+	public boolean hasEntries() {
+		return !isEmpty();
+	}
+
+	public void dump(PrintWriter out, int depth, boolean verbose) {
+		String indent = DebugUtils.getIndent(depth);
+		String indent1 = DebugUtils.getIndent(depth + 1);
+
+		out.print(indent);
+		out.print("Name : ");
+		out.println(m_name);
+		if (hasEntries()) {
+			out.print(indent);
+			out.println("(");
+			for (Iterator i = iterator(); i.hasNext();) {
+				Object entry = (Object) i.next();
+
+				if (entry instanceof Dumpable) {
+					((Dumpable) entry).dump(out, depth + 1, verbose);
+					out.println();
+				}
+				else {
+					out.print(indent1);
+					out.println(entry.toString());
+				}
+			}
+			out.print(indent);
+			out.println(")");
+		}
+		else {
+			out.print(indent);
+			out.println("No Entries.");
+		}
+	}
+	/**
+	 * Returns the name.
+	 * @return String
+	 */
+	public String getName() {
+		return m_name;
+	}
+
+	/**
+	 * Sets the name.
+	 * @param name The name to set
+	 */
+	public void setName(String name) {
+		m_name = name;
+	}
+
+	private boolean hasLimit() {
+		return m_maxSize != 0;
+	}
+	private void capLimit() {
+		if (m_maxSize != 0)
+			return;
+		while (size() > m_maxSize) {
+			remove(0);
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see java.util.List#add(int, java.lang.Object)
+	 */
+	public void add(int arg0, Object arg1) {
+		super.add(arg0, arg1);
+		if (hasLimit())
+			capLimit();
+	}
+
+	/* (non-Javadoc)
+	 * @see java.util.Collection#add(java.lang.Object)
+	 */
+	public boolean add(Object arg0) {
+		boolean added = super.add(arg0);
+
+		if (hasLimit())
+			capLimit();
+
+		return added;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.util.Collection#addAll(java.util.Collection)
+	 */
+	public boolean addAll(Collection arg0) {
+		boolean added = super.addAll(arg0);
+
+		if (hasLimit())
+			capLimit();
+
+		return added;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.util.List#addAll(int, java.util.Collection)
+	 */
+	public boolean addAll(int arg0, Collection arg1) {
+		boolean added = super.addAll(arg0, arg1);
+
+		if (hasLimit())
+			capLimit();
+
+		return added;
+	}
+
+	/**
+	 * @return
+	 */
+	public int getMaxSize() {
+		return m_maxSize;
+	}
+
+	/**
+	 * @param i
+	 */
+	public void setMaxSize(int i) {
+		m_maxSize = i;
+	}
+
+	public int compareTo(Object other) {
+		return m_name.compareTo(((EntityList) other).m_name);
+	}
+	
+	public void produceDOM(Document document, Element element) {
+		DOMUtils.produceDOM(document, element, m_name, (Collection)this);
+	}
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/collection/EntryCollection.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/collection/EntryCollection.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,35 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.collection;
+
+import java.util.Collections;
+
+/**
+ * @author ajack
+ */
+
+//:TODO: TreeSet again, to compare/avoid duplicates...
+public class EntryCollection extends EntityList {
+
+	public EntryCollection(String name) {
+		super(name);
+	}
+
+	public void sort() {
+		Collections.sort(this);
+	}
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/debug/DebugUtils.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/debug/DebugUtils.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,429 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.debug;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.depot.common.util.SystemUtils;
+
+/**
+ * @version $Revision: $
+ */
+public class DebugUtils {
+
+	private static Hashtable l_indents = new Hashtable();
+
+	private static boolean l_verbose = false;
+
+	public static void enableXercesParser() {
+		// SAX ...
+		System.setProperty(
+			"org.xml.sax.driver",
+			"org.apache.xerces.parsers.SAXParser");
+
+		// DOM...
+		//:TODO:
+		//javax.xml.parsers.DocumentBuilderFactory 
+	}
+
+	public static void enableCommonsLogging() {
+		System.setProperty(
+			"org.apache.commons.logging.Log",
+			"org.apache.commons.logging.impl.SimpleLog");
+
+		System.setProperty(
+			"org.apache.commons.logging.simplelog.showdatetime",
+			"true");
+	}
+
+	public static void enableHttpClientDebug() {
+
+		enableCommonsLogging();
+
+		System.setProperty(
+			"org.apache.commons.logging.simplelog.log.httpclient.wire",
+			"debug");
+
+		System.setProperty(
+			"org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient",
+			"debug");
+	}
+
+	public static void enableVerboseDumps() {
+		l_verbose = true;
+	}
+
+	public static void indent(PrintWriter out, int x) {
+		for (int i = 0; i < x; ++i) {
+			out.print("  ");
+		}
+	}
+
+	public static String getIndent(int x) {
+		String idstr = (String) l_indents.get(new Integer(x));
+
+		if (null == idstr) {
+			StringBuffer indent = new StringBuffer();
+
+			for (int i = 0; i < x; ++i)
+				indent.append("  ");
+
+			idstr = indent.toString();
+
+			l_indents.put(new Integer(x), idstr);
+		}
+
+		return idstr;
+	}
+
+	public static String getDump(Throwable t) {
+		return getDump(t, l_verbose);
+	}
+
+	public static String getDump(Throwable t, boolean verbose) {
+		if (verbose) {
+			StringWriter sw = new StringWriter();
+
+			PrintWriter pw = new PrintWriter(sw, true);
+			t.printStackTrace(pw);
+			pw.flush();
+			return sw.toString();
+		}
+
+		return t.getLocalizedMessage();
+	}
+
+	public static String getDump(Dumpable d) {
+		return getDump(0, null, d, l_verbose);
+	}
+
+	public static String getDump(Dumpable d, boolean verbose) {
+		return getDump(0, null, d, verbose);
+	}
+
+	public static String getDump(String title, Dumpable d) {
+		return getDump(0, title, d, l_verbose);
+	}
+
+	public static String getDump(String title, Dumpable d, boolean verbose) {
+		return getDump(0, title, d, verbose);
+	}
+
+	public static String getDump(int depth, String title, Dumpable d) {
+		return getDump(depth, title, d, l_verbose);
+	}
+
+	public static String getDump(
+		int depth,
+		String title,
+		Dumpable d,
+		boolean verbose) {
+		StringWriter sw = new StringWriter();
+		PrintWriter pw = new PrintWriter(sw, true);
+		dump(pw, depth, title, verbose, d);
+		pw.flush();
+		return sw.toString();
+	}
+
+	public static void dump(PrintWriter out, boolean verbose, Object d) {
+		dump(out, 0, verbose, d);
+	}
+
+	public static void dump(String title, Dumpable d) {
+		dump(SystemUtils.getSystemOut(), 0, title, l_verbose, d);
+	}
+
+	public static void dump(String title, Object o) {
+		dump(SystemUtils.getSystemOut(), 0, title, l_verbose, o);
+	}
+
+	public static void dump(String title, boolean verbose, Dumpable d) {
+		dump(SystemUtils.getSystemOut(), 0, title, verbose, d);
+	}
+
+	public static void printSeparator() {
+		printSeparator(SystemUtils.getSystemOut(), 0);
+	}
+	public static void printSeparator(PrintWriter out, int depth) {
+		out.print(DebugUtils.getIndent(depth));
+		out.println(
+			"--------------------------------------------------------------");
+	}
+
+	//	public static void dump(Dumpable d) {
+	//		dump(System.out, 0, d, l_verbose);
+	//	}
+	public static void dump(Object d) {
+		dump(SystemUtils.getSystemOut(), d);
+	}
+
+	public static void dump(boolean verbose, Dumpable d) {
+		dump(SystemUtils.getSystemOut(), 0, null, verbose, d);
+	}
+
+	public static void dump(
+		PrintStream out,
+		int depth,
+		Dumpable d,
+		boolean verbose) {
+		dump(new PrintWriter(out, true), depth, d, verbose);
+	}
+
+	public static void dump(
+		PrintStream out,
+		int depth,
+		String title,
+		boolean verbose,
+		Dumpable d) {
+		dump(new PrintWriter(out, true), depth, title, verbose, d);
+	}
+
+	public static void dump(boolean verbose, Object o) {
+		dump(SystemUtils.getSystemOut(), 0, null, verbose, o);
+	}
+
+	public static void dump(PrintWriter out, Object o) {
+		dump(out, 0, null, l_verbose, o);
+	}
+
+	public static void dump(
+		PrintWriter out,
+		int depth,
+		boolean verbose,
+		Object o) {
+		dump(out, depth, null, verbose, o);
+	}
+
+	public static void dump(
+		PrintWriter out,
+		int depth,
+		String title,
+		boolean verbose,
+		Object o) {
+		final String indent = DebugUtils.getIndent(depth);
+
+		if (null == o) {
+			if (null != title) {
+				out.print(indent);
+				out.println(title);
+			}
+
+			out.print(indent);
+			out.println("Null Object");
+		}
+		else if (o instanceof Dumpable) {
+			if (null != title) {
+				out.print(indent);
+				out.println(title);
+			}
+			dump(out, depth, (Dumpable) o, verbose);
+		}
+		else if (o instanceof Map)
+			dumpMap(out, depth, title, verbose, ((Map) o));
+		else if (o instanceof List)
+			dumpList(out, depth, title, verbose, ((List) o));
+		else {
+			if (null != title) {
+				out.print(indent);
+				out.println(title);
+			}
+
+			out.print(indent);
+			out.print(SystemUtils.getShortName(o.getClass()));
+			out.print(" : ");
+			out.println(o.toString());
+		}
+	}
+
+	//	public static void dump(PrintWriter out, Dumpable d) {
+	//		dump(out, 0, d, l_verbose);
+	//	}
+
+	public static void dump(PrintWriter out, Dumpable d, boolean verbose) {
+		dump(out, 0, d, verbose);
+	}
+
+	public static void dump(PrintWriter out, int depth, Dumpable d) {
+		if (null != d)
+			d.dump(out, depth, l_verbose);
+		else {
+			out.println(DebugUtils.getIndent(depth) + "NULL");
+		}
+	}
+
+	public static void dump(
+		PrintWriter out,
+		int depth,
+		Dumpable d,
+		boolean verbose) {
+		if (null != d)
+			d.dump(out, depth, verbose);
+		else {
+			out.println(DebugUtils.getIndent(depth) + "NULL");
+		}
+	}
+
+	public static void dump(
+		PrintWriter out,
+		int depth,
+		String title,
+		boolean verbose,
+		Dumpable d) {
+		final String indent = DebugUtils.getIndent(depth);
+
+		if (null != title) {
+			out.print(indent);
+			out.println(title);
+		}
+		if (null != d)
+			d.dump(out, depth, verbose);
+		else {
+			out.print(indent);
+			out.println("NULL");
+		}
+	}
+
+	//	public static void dumpList(PrintWriter out, int depth, List list) {
+	//		dumpList(out, depth, null, l_verbose, list);
+	//	}
+
+	public static void dumpList(
+		PrintWriter out,
+		int depth,
+		boolean verbose,
+		List list) {
+		dumpList(out, depth, null, verbose, list);
+	}
+
+	public static void dumpList(
+		PrintWriter out,
+		int depth,
+		String title,
+		boolean verbose,
+		List list) {
+		String indent = DebugUtils.getIndent(depth);
+		String indent1 = DebugUtils.getIndent(depth + 1);
+
+		if (null != title) {
+			out.print(indent);
+			out.println(title);
+		}
+		else {
+			out.print(indent);
+			out.println("List Type: " + SystemUtils.getShortName(list));
+		}
+
+		if (null != list) {
+			if (0 != list.size()) {
+				int ii = 0;
+				for (Iterator i = list.iterator(); i.hasNext(); ++ii) {
+					Object entry = i.next();
+
+					out.print(indent1);
+					out.print("Entry #");
+					out.print(ii);
+					if (entry instanceof Dumpable) {
+						out.print(", class: ");
+						out.println(entry.getClass().getName());
+					}
+					else
+						out.print(" ");
+
+					DebugUtils.dump(out, depth + 2, verbose, entry);
+
+					// Separator for entries
+					//if (i.hasNext() && verbose)
+					//	DebugUtils.printSeparator(out,depth);
+				}
+			}
+			else {
+				out.print(indent);
+				out.println("Empty List.");
+			}
+		}
+		else {
+			out.print(indent);
+			out.println("No List.");
+		}
+	}
+
+	public static void dumpMap(
+		PrintWriter out,
+		int depth,
+		boolean verbose,
+		Map map) {
+		dumpMap(out, depth, null, verbose, map);
+	}
+
+	public static void dumpMap(
+		PrintWriter out,
+		int depth,
+		String title,
+		boolean verbose,
+		Map map) {
+		String indent = DebugUtils.getIndent(depth);
+		String indent1 = DebugUtils.getIndent(depth + 1);
+
+		if (null != title) {
+			out.print(indent);
+			out.println(title);
+		}
+		else {
+			out.print(indent);
+			out.println("Map Type: " + SystemUtils.getShortName(map));
+		}
+
+		if (null != map) {
+			if (0 != map.size()) {
+				for (Iterator i = map.keySet().iterator(); i.hasNext();) {
+					Object key = i.next();
+					Object entry = map.get(key);
+
+					out.print(indent1);
+					out.print("Key ");
+					out.print(key);
+					if (entry instanceof Dumpable) {
+						out.print(", class: ");
+						out.println(entry.getClass().getName());
+					}
+					else
+						out.print(" ");
+
+					DebugUtils.dump(out, depth + 1, verbose, entry);
+
+					// Separator for entries
+					//if (i.hasNext() && verbose)
+					//	DebugUtils.printSeparator(out,depth);
+				}
+			}
+			else {
+				out.print(indent);
+				out.println("Empty Map.");
+			}
+		}
+		else {
+			out.print(indent);
+			out.println("No Map.");
+		}
+	}
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/debug/Dumpable.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/debug/Dumpable.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,29 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.debug;
+
+import java.io.PrintWriter;
+
+/**
+ *
+ * @author $Author: arb_jack $
+ * @version $Revision: 1.2 $
+ * 
+ */
+public interface Dumpable {
+    void dump(PrintWriter out, int depth, boolean verbose);
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/dom/DOMConsumer.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/dom/DOMConsumer.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,29 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.dom;
+
+import org.w3c.dom.Element;
+
+/**
+ * @version $Revision: $
+ */
+public interface DOMConsumer {
+	// Unwritten rule, a DOMConsumer must have a public
+	// constructor for (Element element)
+	void consumeDOMElement(String tag, Element element);
+	void consumeDOMObject(String tag, Object object);
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/dom/DOMProducer.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/dom/DOMProducer.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,28 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.dom;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * @version $Revision: $
+ */
+public interface DOMProducer {
+
+    void produceDOM(Document document, Element element);
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/dom/DOMUtils.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/dom/DOMUtils.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,927 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.dom;
+
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.depot.common.DepotException;
+import org.apache.depot.common.log.Logger;
+import org.apache.depot.common.util.SystemUtils;
+import org.apache.depot.common.util.debug.DebugUtils;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.xml.sax.InputSource;
+
+/**
+ * @version $Revision: $
+ */
+public class DOMUtils {
+
+	private static boolean l_initialized = false;
+	private static DocumentBuilderFactory l_factory = null;
+	private static DocumentBuilder l_builder = null;
+
+	public static synchronized void initialize() {
+		if (l_initialized)
+			return;
+
+		try {
+			l_factory = DocumentBuilderFactory.newInstance();
+			l_builder = l_factory.newDocumentBuilder();
+
+			l_initialized = true;
+		}
+		catch (Exception e) {
+			Logger.getLogger().error("Error getting DocumentBuilder", e);
+		}
+	}
+
+	public static Document deserialize(InputStream data) throws Exception {
+		if (!l_initialized)
+			initialize();
+		Document doc =
+			(l_factory.newDocumentBuilder()).parse(new InputSource(data));
+
+		return doc;
+	}
+
+	public static Document deserialize(Reader data) throws Exception {
+		if (!l_initialized)
+			initialize();
+		Document doc =
+			(l_factory.newDocumentBuilder()).parse(new InputSource(data));
+		return doc;
+	}
+
+	public static String serialize(Node root) {
+		StringWriter sw = new StringWriter();
+		PrintWriter pw = new PrintWriter(sw);
+		serialize(pw, root);
+		pw.flush();
+		return sw.toString();
+	}
+
+	public static String serialize(
+		Node root,
+		boolean headerless,
+		boolean pretty,
+		boolean canonical) {
+		StringWriter sw = new StringWriter();
+		PrintWriter pw = new PrintWriter(sw);
+		serialize(pw, root);
+		pw.flush();
+		return sw.toString();
+	}
+
+	public static void serialize(PrintWriter out, Node root) {
+		serializeNode(out, root, 0, false, true, true);
+	}
+
+	public static void serialize(
+		PrintWriter out,
+		Node root,
+		boolean headerless,
+		boolean pretty,
+		boolean canonical) {
+		serializeNode(out, root, 0, headerless, pretty, canonical);
+	}
+
+	private static void serializeNode(
+		PrintWriter out,
+		Node node,
+		int depth,
+		boolean headerless,
+		boolean pretty,
+		boolean canonical) {
+		// is there anything to do?
+		if (node == null)
+			return;
+
+		short type = node.getNodeType();
+
+		if (type == Node.ELEMENT_NODE)
+			if (pretty)
+				out.print(DebugUtils.getIndent(depth));
+
+		switch (type) {
+			case Node.DOCUMENT_NODE :
+				{
+					if (!headerless) {
+						out.println(
+							"<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+						out.flush();
+					}
+
+					Document document = (Document) node;
+					serializeNode(
+						out,
+						document.getDocumentElement(),
+						depth + 1,
+						headerless,
+						pretty,
+						canonical);
+					break;
+				}
+
+			case Node.ELEMENT_NODE :
+				{
+					out.print('<');
+					out.print(node.getNodeName());
+					Attr attrs[] = sortAttributes(node.getAttributes());
+					for (int i = 0; i < attrs.length; i++) {
+						Attr attr = attrs[i];
+						out.print(' ');
+						out.print(attr.getNodeName());
+						out.print("=\"");
+						normalizeAndPrint(attr.getNodeValue(), out, canonical);
+						out.print('"');
+					}
+					out.print('>');
+					if (pretty)
+						out.println();
+					out.flush();
+
+					Node child = node.getFirstChild();
+					while (child != null) {
+						serializeNode(
+							out,
+							child,
+							depth + 1,
+							headerless,
+							pretty,
+							canonical);
+						child = child.getNextSibling();
+					}
+					break;
+				}
+
+			case Node.ENTITY_REFERENCE_NODE :
+				{
+					if (canonical) {
+						Node child = node.getFirstChild();
+						while (child != null) {
+							serializeNode(
+								out,
+								child,
+								depth + 1,
+								headerless,
+								pretty,
+								canonical);
+							child = child.getNextSibling();
+						}
+					}
+					else {
+						out.print('&');
+						out.print(node.getNodeName());
+						out.print(';');
+						out.flush();
+					}
+					break;
+				}
+
+			case Node.CDATA_SECTION_NODE :
+				{
+					if (canonical) {
+						normalizeAndPrint(node.getNodeValue(), out, canonical);
+					}
+					else {
+						out.print("<![CDATA[");
+						out.print(node.getNodeValue());
+						out.print("]]>");
+					}
+					out.flush();
+					break;
+				}
+
+			case Node.TEXT_NODE :
+				{
+					normalizeAndPrint(node.getNodeValue(), out, canonical);
+					if (pretty)
+						out.println();
+					out.flush();
+					break;
+				}
+
+			case Node.PROCESSING_INSTRUCTION_NODE :
+				{
+					out.print("<?");
+					out.print(node.getNodeName());
+					String data = node.getNodeValue();
+					if (data != null && data.length() > 0) {
+						out.print(' ');
+						out.print(data);
+					}
+					out.println("?>");
+					out.flush();
+					break;
+				}
+		}
+
+		if (type == Node.ELEMENT_NODE) {
+			if (pretty) {
+				out.print(DebugUtils.getIndent(depth));
+			}
+			out.print("</");
+			out.print(node.getNodeName());
+			out.print('>');
+			if (pretty)
+				out.println();
+			out.flush();
+		}
+
+	}
+
+	/** Returns a sorted array of attributes. */
+	public static Attr[] sortAttributes(NamedNodeMap attrs) {
+
+		int len = (attrs != null) ? attrs.getLength() : 0;
+		Attr array[] = new Attr[len];
+		for (int i = 0; i < len; i++) {
+			array[i] = (Attr) attrs.item(i);
+		}
+		for (int i = 0; i < len - 1; i++) {
+			String name = array[i].getNodeName();
+			int index = i;
+			for (int j = i + 1; j < len; j++) {
+				String curName = array[j].getNodeName();
+				if (curName.compareTo(name) < 0) {
+					name = curName;
+					index = j;
+				}
+			}
+			if (index != i) {
+				Attr temp = array[i];
+				array[i] = array[index];
+				array[index] = temp;
+			}
+		}
+
+		return array;
+
+	}
+
+	//
+	// Protected methods
+	//
+
+	/** Normalizes and prints the given string. */
+	public static void normalizeAndPrint(
+		String s,
+		PrintWriter out,
+		boolean canonical) {
+
+		int len = (s != null) ? s.length() : 0;
+		for (int i = 0; i < len; i++) {
+			char c = s.charAt(i);
+			normalizeAndPrint(c, out, canonical);
+		}
+
+	} // normalizeAndPrint(String)
+
+	/** Normalizes and print the given character. */
+	public static void normalizeAndPrint(
+		char c,
+		PrintWriter out,
+		boolean canonical) {
+
+		switch (c) {
+			case '<' :
+				{
+					out.print("&lt;");
+					break;
+				}
+			case '>' :
+				{
+					out.print("&gt;");
+					break;
+				}
+			case '&' :
+				{
+					out.print("&amp;");
+					break;
+				}
+			case '"' :
+				{
+					out.print("&quot;");
+					break;
+				}
+			case '\r' :
+			case '\n' :
+				{
+					if (canonical) {
+						out.print("&#");
+						out.print(Integer.toString(c));
+						out.print(';');
+						break;
+					}
+					// else, default print char
+				}
+			default :
+				{
+					out.print(c);
+				}
+		}
+
+	}
+	public static Document createDocument() {
+		if (!l_initialized)
+			initialize();
+
+		return l_builder.newDocument();
+	}
+
+	public static String extractText(Node node) {
+		StringBuffer buffer = new StringBuffer();
+
+		if (Element.TEXT_NODE == node.getNodeType())
+			buffer.append(node.getNodeValue());
+
+		if (node.hasChildNodes()) {
+			NodeList nl = node.getChildNodes();
+
+			for (int i = 0; i < nl.getLength(); ++i) {
+				Node n = nl.item(i);
+
+				buffer.append(DOMUtils.extractText(n));
+			}
+		}
+
+		return buffer.toString();
+	}
+
+	public static Element getRootElement(Node node) {
+		Element root = null;
+
+		if (node instanceof Element)
+			return (Element) node;
+
+		if (node.hasChildNodes()) {
+			NodeList nl = node.getChildNodes();
+
+			for (int i = 0;(i < nl.getLength()) && (null == root); ++i) {
+				Node n = nl.item(i);
+
+				root = DOMUtils.getRootElement(n);
+			}
+		}
+
+		return root;
+	}
+
+	public static Node simplify(Node node) {
+		return simplify(node, false, false);
+	}
+
+	public static Node simplify(
+		Node node,
+		boolean stripWhitespace,
+		boolean stripComplex) {
+		Node newNode = node.cloneNode(true);
+
+		//
+		//  Allow DOM to clean itself up
+		//
+		newNode.normalize();
+
+		//
+		//  Take it a step further...
+		//
+		if (removable(newNode, stripWhitespace, stripComplex))
+			newNode = null;
+
+		return newNode;
+	}
+
+	/**
+	 * Insert a Node tree into a Document other than the one
+	 * it was created in.
+	 */
+	public static void crossInsert(
+		Document doc,
+		Node docCursor,
+		Node foreignNode) {
+		if (null == foreignNode)
+			return;
+
+		Node newNode = null;
+
+		try {
+			newNode = doc.importNode(foreignNode, true);
+
+			try {
+
+				if (null != docCursor)
+					docCursor.appendChild(newNode);
+				else
+					doc.appendChild(newNode);
+
+			}
+			catch (RuntimeException e) {
+				Logger.getLogger().error(
+					"Failed to insert ["
+						+ newNode.getClass().getName()
+						+ ":"
+						+ newNode
+						+ "] into ["
+						+ docCursor.getClass().getName()
+						+ ":"
+						+ docCursor
+						+ "]",
+					e);
+			}
+		}
+		catch (RuntimeException ee) {
+			Logger.getLogger().error(
+				"Failed to create new node ["
+					+ foreignNode.getClass().getName()
+					+ ":"
+					+ foreignNode
+					+ "]",
+				ee);
+
+			throw ee;
+		}
+	}
+
+	/**
+	 * 
+	 */
+	public static boolean removable(
+		Node node,
+		boolean stripWhitespace,
+		boolean stripComplex) {
+		ArrayList removes = null;
+		boolean removeable = false;
+
+		if (stripWhitespace && (Node.TEXT_NODE == node.getNodeType())) {
+			String value = node.getNodeValue();
+
+			if (null != value) {
+				value = value.trim();
+				removeable = (0 == value.length());
+			}
+		}
+		else if (stripComplex) {
+
+		}
+
+		if (node.hasChildNodes()) {
+			NodeList nl = node.getChildNodes();
+
+			for (int i = 0; i < nl.getLength(); ++i) {
+				Node n = nl.item(i);
+
+				boolean rem =
+					DOMUtils.removable(n, stripWhitespace, stripComplex);
+
+				if (rem) {
+					//DOMLogger.log.debug("Remove removable");
+					//DOMUtils.dump(TSystem.verbose, n);
+					if (null == removes)
+						removes = new ArrayList();
+					removes.add(n);
+				}
+			}
+		}
+
+		//
+		//  Weed ...
+		//
+		if (null != removes) {
+			for (Iterator i = removes.iterator(); i.hasNext();) {
+				Node n = (Node) i.next();
+				node.removeChild(n);
+			}
+		}
+
+		return removeable;
+	}
+
+	public static void dump(PrintWriter out, Node node) {
+		dump(out, node, 0);
+	}
+
+	public static void dump(PrintWriter out, Node node, int depth) {
+		String indent = DebugUtils.getIndent(depth);
+
+		if (Node.ATTRIBUTE_NODE == node.getNodeType()) {
+			String value = node.getNodeValue();
+			out.println(
+				indent
+					+ "("
+					+ depth
+					+ ")Attr> "
+					+ node.getNodeName()
+					+ " ("
+					+ node.getPrefix()
+					+ "|"
+					+ node.getNamespaceURI()
+					+ "|"
+					+ node.getLocalName()
+					+ ") ["
+					+ value
+					+ "]");
+		}
+		else {
+			out.println(
+				indent
+					+ "("
+					+ depth
+					+ ")Name> "
+					+ node.getNodeName()
+					+ " ("
+					+ node.getPrefix()
+					+ "|"
+					+ node.getNamespaceURI()
+					+ "|"
+					+ node.getLocalName()
+					+ ")");
+			out.println(
+				indent
+					+ "("
+					+ depth
+					+ ")Class> "
+					+ node.getClass().getName()
+					+ " Type > "
+					+ node.getNodeType());
+
+			String value = node.getNodeValue();
+			if (null != value)
+				out.println(indent + "(" + depth + ")Value> " + value);
+
+			if (node.hasAttributes()) {
+				NamedNodeMap map = node.getAttributes();
+
+				for (int i = 0; i < map.getLength(); ++i) {
+					Node n = map.item(i);
+
+					DOMUtils.dump(out, n, depth + 2);
+				}
+			}
+
+			if (node.hasChildNodes()) {
+				NodeList nl = node.getChildNodes();
+
+				for (int i = 0; i < nl.getLength(); ++i) {
+					Node n = nl.item(i);
+
+					DOMUtils.dump(out, n, depth + 1);
+				}
+			}
+		}
+	}
+
+	public static String getAttributeValue(Node node, String name) {
+		String value = null;
+
+		if (node.hasAttributes()) {
+			NamedNodeMap map = node.getAttributes();
+
+			for (int i = 0; i < map.getLength(); ++i) {
+				Node n = map.item(i);
+				String nodeName = n.getNodeName();
+
+				if (nodeName.equalsIgnoreCase(name)) {
+					value = n.getNodeValue();
+
+					//DOMLogger.log.debug("getAttributeValue: Attribute [" + name + "] [" + value + "]");
+
+					break;
+				}
+			}
+		}
+		else
+			Logger.getLogger().debug("getAttributeValue: No Attributes");
+
+		return value;
+	}
+
+	public Document toXML(DOMProducer xml) {
+
+		Document doc = DOMUtils.createDocument();
+		xml.produceDOM(DOMUtils.createDocument(), null);
+		return doc;
+	}
+
+	public static Element insertElement(
+		Document document,
+		Element parentElement,
+		String name) {
+
+		// Create on this document
+		Element element = document.createElement(name);
+
+		// If nowhere specified, insert to document
+		appendChild(document, parentElement, element);
+
+		return element;
+	}
+
+	public static Element insertElement(
+		Document document,
+		Element element,
+		Object node) {
+		return insertElement(document, element, SystemUtils.getShortName(node));
+	}
+
+	public static Attr insertAttribute(
+		Document document,
+		Element element,
+		String name,
+		String value) {
+
+		// Create on this document
+		Attr attr = document.createAttribute(name);
+		if (null != value)
+			attr.setNodeValue(value);
+
+		element.setAttributeNode(attr);
+
+		return attr;
+	}
+
+	public static Text insertText(
+		Document document,
+		Element element,
+		String value) {
+
+		// Create on this document
+		Text text = document.createTextNode(value);
+
+		// If nowhere specified, insert to document
+		element.appendChild(text);
+
+		return text;
+	}
+
+	public static Document produceDOM(DOMProducer xml) {
+		Document document = DOMUtils.createDocument();
+		xml.produceDOM(document, document.getDocumentElement());
+		return document;
+	}
+
+	public static void produceDOM(
+		Document document,
+		Element parentElement,
+		String name,
+		DOMProducer xml) {
+		xml.produceDOM(
+			document,
+			DOMUtils.insertElement(
+				document,
+				parentElement,
+				sanitizeName(name)));
+	}
+
+	/**
+	 * 
+	 * Create an element for the collection and inside it create DOM sub-trees for the contents
+	 * of the collection.
+	 * 
+	 * @param document
+	 * @param element
+	 * @param collection
+	 */
+	public static void produceDOM(
+		Document document,
+		Element element,
+		Collection collection) {
+		produceDOM(
+			document,
+			element,
+			sanitizeName(SystemUtils.getShortName(collection)),
+			collection);
+	}
+
+	/**
+	 * 
+	 * 
+	 * Create a named element for the collection and inside it create DOM sub-trees for the contents
+	 * of the collection.
+	 * 
+	 * @param document
+	 * @param element
+	 * @param name
+	 * @param collection
+	 */
+	public static void produceDOM(
+		Document document,
+		Element element,
+		String name,
+		Collection collection) {
+		Element parent =
+			DOMUtils.insertElement(document, element, sanitizeName(name));
+
+		for (Iterator i = collection.iterator(); i.hasNext();) {
+			DOMUtils.produceDOM(document, parent, i.next());
+		}
+	}
+
+	public static void produceDOM(
+		Document document,
+		Element element,
+		String name,
+		Iterator iterator) {
+		Element parent =
+			DOMUtils.insertElement(document, element, sanitizeName(name));
+		DOMUtils.produceDOM(document, parent, iterator);
+	}
+
+	public static void produceDOM(
+		Document document,
+		Element element,
+		Iterator iterator) {
+		for (; iterator.hasNext();) {
+			Object obj = iterator.next();
+			DOMUtils.produceDOM(document, element, obj);
+		}
+	}
+
+	/**
+	 * 
+	 * Create an element for the map and inside it create DOM sub-trees for the contents
+	 * of the map.
+	 * 
+	 * @param document
+	 * @param element
+	 * @param collection
+	 */
+	public static void produceDOM(
+		Document document,
+		Element element,
+		Map map) {
+		produceDOM(
+			document,
+			element,
+			sanitizeName(SystemUtils.getShortName(map)),
+			map);
+	}
+
+	public static void produceDOM(
+		Document document,
+		Element element,
+		String name,
+		Map map) {
+		Element parent =
+			DOMUtils.insertElement(document, element, sanitizeName(name));
+
+		for (Iterator i = map.keySet().iterator(); i.hasNext();) {
+			Object key = i.next();
+			Object value = map.get(key);
+
+			Element entity = DOMUtils.insertElement(document, parent, "Entity");
+
+			DOMUtils.insertAttribute(document, entity, "id", key.toString());
+
+			DOMUtils.insertText(document, entity, value.toString());
+		}
+	}
+
+	public static void produceDOM(
+		Document document,
+		Element element,
+		String name,
+		Object node) {
+		if (null != node) {
+			if (node instanceof DOMProducer) {
+				((DOMProducer) node).produceDOM(document, element);
+			}
+			else {
+				Element parent = document.createElement(sanitizeName(name));
+				Text t = document.createTextNode(node.toString());
+				parent.appendChild(t);
+				element.appendChild(parent);
+			}
+		}
+	}
+
+	public static void produceDOM(
+		Document document,
+		Element element,
+		Object node) {
+		if (node instanceof DOMProducer)
+			 ((DOMProducer) node).produceDOM(document, element);
+		else
+			produceDOM(
+				document,
+				element,
+				sanitizeName(SystemUtils.getShortName(node)),
+				node);
+	}
+
+	public static void appendChild(
+		Document document,
+		Element parentElement,
+		Element element) {
+		if (null == element)
+			element = document.getDocumentElement();
+
+		if (null == parentElement)
+			document.appendChild(element);
+		else
+			parentElement.appendChild(element);
+	}
+
+	public static String sanitizeName(String name) {
+		StringBuffer sane = new StringBuffer();
+
+		for (int i = 0; i < name.length(); ++i) {
+			char ch = name.charAt(i);
+
+			if ((('A' <= ch) && ('Z' >= ch)) || (('a' <= ch) && ('z' >= ch)))
+				sane.append(ch);
+		}
+
+		return sane.toString();
+	}
+
+	public static void consumeDOMSubElements(
+		DOMConsumer handler,
+		Map tags,
+		Element element)
+		throws DepotException {
+		//
+		// Iterate through sub-elements (not all nodes)
+		//
+		if (element.hasChildNodes()) {
+			NodeList nl = element.getChildNodes();
+
+			for (int i = 0; i < nl.getLength(); ++i) {
+				Node node = nl.item(i);
+				String name = node.getNodeName();
+
+				if (node instanceof Element) {
+					boolean handled = false;
+
+					//SystemUtils.getSystemOut().println("Tag: " + name);
+
+					//
+					// Tags For Object Handlers
+					//
+					Class subhandler = (Class) tags.get(name);
+
+					if ((null != subhandler)
+						&& (DOMConsumer.class.isAssignableFrom(subhandler))) {
+
+						try {
+							Constructor c =
+								subhandler.getConstructor(
+									new Class[] { Element.class });
+							// Construct from DOM...
+							Object sub =
+								c.newInstance(new Object[] {(Element) node });
+
+							// Pass it to the 'parent'
+							handler.consumeDOMObject(name, sub);
+
+							handled = true;
+						}
+						catch (Throwable t) {
+							throw new DepotException(
+								"Failed to consume DOM * <" + name,
+								t);
+						}
+					}
+					else {
+						handler.consumeDOMElement(name, (Element) node);
+						handled = true;
+					}
+
+					if (!handled) {
+						Logger.getLogger().warn("Not handled: " + name);
+					}
+				}
+			}
+		}
+	}
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/envsafe/ClassLoaderContext.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/envsafe/ClassLoaderContext.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,430 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.envsafe;
+
+import java.io.InputStream;
+
+import org.apache.depot.common.DepotError;
+import org.apache.depot.common.DepotException;
+import org.apache.depot.common.log.Logger;
+
+/**
+ * @author ajack
+ */
+public class ClassLoaderContext {
+
+	/**
+ 	* The classloader that this context work upon 
+ 	*/
+	private ClassLoader m_loader = null;
+
+	// Another useful one...
+	private static ClassLoaderContext l_root = null;
+
+	static {
+		l_root = new ClassLoaderContext(ClassLoader.getSystemClassLoader());
+	}
+
+	public ClassLoaderContext(ClassLoader loader) {
+		m_loader = loader;
+		classInit();
+	}
+
+	public ClassLoaderContext(Object context) {
+		this(context.getClass());
+		classInit();
+	}
+
+	public ClassLoaderContext(Class context) {
+		m_loader = context.getClassLoader();
+		classInit();
+	}
+
+	private void classInit() {
+		// If not already specified...
+		if (null == m_loader) {
+			//
+			// Last ditched effort...
+			//
+			m_loader = getContextClassLoader();
+		}
+	}
+
+	public Class getClassForName(String name) throws ClassNotFoundException {
+		return Class.forName(name, true, m_loader);
+	}
+
+	public InputStream getResourceAsStream(String name)
+		throws ClassNotFoundException {
+		return m_loader.getResourceAsStream(name);
+	}
+
+	/**
+	* 
+	* Return the thread context class loader if available.
+	* Otherwise return null.
+	*
+	*/
+	public ClassLoader getContextClassLoader() {
+		return getContextClassLoader(null);
+	}
+
+	/**
+	* 
+	* Return the thread context class loader if available.
+	* Otherwise return null.
+	*
+	*/
+	public ClassLoader getContextClassLoader(Class context) {
+		ClassLoader classLoader = null;
+
+		//
+		// Get the loader for the provided class
+		//
+		if (null != context)
+			classLoader = context.getClassLoader();
+
+		//
+		//	:TODO: Is this better than using System?
+		//
+		if (classLoader == null) {
+			classLoader =
+				(ClassLoader) RelativelySafe.callMethod(
+					Thread.currentThread(),
+					"getContextClassLoader");
+		}
+
+		//
+		//    A null return from Class.getClassLoader() means the
+		//    System ClassLoader was used. [Sybase EAS, amongst 
+		//	  other (no doubt) do this.] Spec says they can...
+		//
+		if (null == classLoader)
+			classLoader = ClassLoader.getSystemClassLoader();
+
+		// Return the selected class loader
+		return classLoader;
+	}
+
+	public Object loadClassWithFallbacks(
+		String primaryOption,
+		String secondaryOption,
+		String tertiaryOption,
+		String quaternaryOption) {
+
+		Object implementation = null;
+
+		DepotException primaryProblem = null;
+		DepotException secondaryProblem = null;
+		DepotException tertiaryProblem = null;
+		DepotException quaternaryProblem = null;
+
+		try {
+			implementation = attemptLoad(primaryOption, "Primary");
+		}
+		catch (DepotException ve) {
+			primaryProblem = ve;
+
+			Logger.getLogger().debug(
+				"Failed to load [" + primaryOption + "] due to ",
+				primaryProblem);
+		}
+
+		if (null == implementation) {
+			try {
+				implementation = attemptLoad(secondaryOption, "Secondary");
+			}
+
+			catch (DepotException ve2) {
+				secondaryProblem = ve2;
+
+				Logger.getLogger().debug(
+					"Failed to load [" + secondaryOption + "] due to ",
+					secondaryProblem);
+			}
+		}
+
+		if (null == implementation) {
+			try {
+				implementation = attemptLoad(tertiaryOption, "Tertiary");
+			}
+
+			catch (DepotException ve3) {
+				tertiaryProblem = ve3;
+
+				Logger.getLogger().debug(
+					"Failed to load [" + tertiaryOption + "] due to ",
+					tertiaryProblem);
+
+			}
+		}
+
+		if (null == implementation) {
+			try {
+				implementation = attemptLoad(quaternaryOption, "Quaternary");
+			}
+
+			catch (DepotException ve4) {
+				quaternaryProblem = ve4;
+
+				Logger.getLogger().debug(
+					"Failed to load [" + quaternaryOption + "] due to ",
+					quaternaryProblem);
+
+			}
+		}
+
+		if (null == implementation) {
+
+			Logger.getLogger().error(
+				"Failed to load [" + primaryOption + "] due to ",
+				primaryProblem);
+
+			Logger.getLogger().error(
+				"Failed to load [" + secondaryOption + "] due to ",
+				secondaryProblem);
+
+			Logger.getLogger().error(
+				"Failed to load [" + tertiaryOption + "] due to ",
+				tertiaryProblem);
+
+			Logger.getLogger().error(
+				"Failed to load [" + quaternaryOption + "] due to ",
+				quaternaryProblem);
+
+			throw new DepotError(
+				"Severe failure, a fallback ought exist",
+				quaternaryProblem);
+		}
+
+		return implementation;
+	}
+
+	public Object loadClassWithFallbacks(
+		String primaryOption,
+		String secondaryOption,
+		String tertiaryOption) {
+
+		Object implementation = null;
+
+		DepotException primaryProblem = null;
+		DepotException secondaryProblem = null;
+		DepotException tertiaryProblem = null;
+
+		try {
+			implementation = attemptLoad(primaryOption, "Primary");
+		}
+		catch (DepotException ve) {
+			primaryProblem = ve;
+
+			Logger.getLogger().debug(
+				"Failed to load [" + primaryOption + "] due to ",
+				primaryProblem);
+		}
+
+		if (null == implementation) {
+			try {
+				implementation = attemptLoad(secondaryOption, "Secondary");
+			}
+
+			catch (DepotException ve2) {
+				secondaryProblem = ve2;
+
+				Logger.getLogger().debug(
+					"Failed to load [" + secondaryOption + "] due to ",
+					secondaryProblem);
+
+			}
+		}
+
+		if (null == implementation) {
+			try {
+				implementation = attemptLoad(tertiaryOption, "Tertiary");
+			}
+
+			catch (DepotException ve3) {
+				tertiaryProblem = ve3;
+
+				Logger.getLogger().debug(
+					"Failed to load [" + tertiaryOption + "] due to ",
+					tertiaryProblem);
+
+			}
+		}
+
+		if (null == implementation) {
+
+			Logger.getLogger().error(
+				"Failed to load [" + primaryOption + "] due to ",
+				primaryProblem);
+
+			Logger.getLogger().error(
+				"Failed to load [" + secondaryOption + "] due to ",
+				secondaryProblem);
+
+			Logger.getLogger().error(
+				"Failed to load [" + tertiaryOption + "] due to ",
+				tertiaryProblem);
+
+			throw new DepotError(
+				"Severe failure, a fallback ought exist",
+				tertiaryProblem);
+		}
+
+		return implementation;
+	}
+
+	public Object loadClassWithFallback(
+		String primaryOption,
+		String secondaryOption) {
+
+		DepotException primaryProblem = null;
+		DepotException secondaryProblem = null;
+
+		Object implementation = null;
+
+		try {
+			implementation = attemptLoad(primaryOption, "Primary");
+		}
+		catch (DepotException ve) {
+			primaryProblem = ve;
+
+			Logger.getLogger().debug(
+				"Failed to load [" + primaryOption + "] due to ",
+				primaryProblem);
+
+		}
+
+		if (null == implementation) {
+			try {
+				implementation = attemptLoad(secondaryOption, "Secondary");
+			}
+
+			catch (DepotException ve2) {
+				secondaryProblem = ve2;
+
+				Logger.getLogger().debug(
+					"Failed to load [" + secondaryOption + "] due to ",
+					secondaryProblem);
+
+			}
+		}
+
+		//:TODO: We can't set cuase again, we can't attach two
+		// causes. Hmm. Log both and throw one?
+
+		if (null == implementation) {
+
+			Logger.getLogger().error(
+				"Failed to load [" + primaryOption + "] due to ",
+				primaryProblem);
+
+			Logger.getLogger().error(
+				"Failed to load [" + secondaryOption + "] due to ",
+				secondaryProblem);
+
+			throw new DepotError(
+				"Severe failure, a fallback ought exist",
+				secondaryProblem);
+		}
+
+		return implementation;
+	}
+
+	public Object attemptLoad(String className, String optionName)
+		throws DepotException {
+		Object implementation = null;
+
+		try {
+			Class optionClass = Class.forName(className);
+
+			implementation = optionClass.newInstance();
+
+		}
+		catch (NoClassDefFoundError ncdfe) {
+			throw new DepotException(
+				getClassLoadMessage(className, optionName, ncdfe),
+				ncdfe);
+		}
+		catch (ClassNotFoundException cnf) {
+			throw new DepotException(
+				getClassLoadMessage(className, optionName, cnf),
+				cnf);
+		}
+		catch (IllegalAccessException iae) {
+			throw new DepotException(
+				getClassLoadMessage(className, optionName, iae),
+				iae);
+		}
+		catch (InstantiationException ie) {
+			throw new DepotException(
+				getClassLoadMessage(className, optionName, ie),
+				ie);
+		}
+
+		return implementation;
+	}
+
+	public Throwable thrownIfLoaded(String className) {
+		Throwable thrown = null;
+
+		try {
+			Class.forName(className);
+		}
+		catch (ClassNotFoundException cnf) {
+			thrown = cnf;
+		}
+
+		return thrown;
+	}
+
+	private String getClassLoadMessage(String o1, String o2, Throwable cause) {
+		return "Failed to \"Safely Load\"  ["
+			+ o1
+			+ "] as ["
+			+ o2
+			+ "] :"
+			+ cause;
+	}
+	/**
+	 * @return
+	 */
+	public ClassLoader getClassLoader() {
+		return m_loader;
+	}
+
+	/**
+	 * @param loader
+	 */
+	public void setClassLoader(ClassLoader loader) {
+		m_loader = loader;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#equals(java.lang.Object)
+	 */
+	public boolean equals(Object arg0) {
+		return m_loader.equals(((ClassLoaderContext)arg0).m_loader);
+	}
+
+	/* (non-Javadoc)
+	 * @see java.lang.Object#hashCode()
+	 */
+	public int hashCode() {
+		return m_loader.hashCode();
+	}
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/envsafe/RelativelySafe.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/envsafe/RelativelySafe.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,231 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.envsafe;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.apache.depot.common.DepotError;
+import org.apache.depot.common.log.Logger;
+import org.apache.depot.common.util.SystemUtils;
+
+/**
+ * @author ajack
+ */
+public class RelativelySafe {
+	private static boolean l_initialized = false;
+	private static boolean l_isJVM12 = false;
+	private static boolean l_isJVM13 = false;
+	private static boolean l_isJVM14 = true;
+
+	public static synchronized void initialize() {
+		if (l_initialized)
+			return;
+
+		String version =
+			System.getProperties().getProperty("java.specification.version");
+
+		if ("1.2".equals(version)) {
+			l_isJVM12 = true;
+			l_isJVM13 = l_isJVM14 = false;
+		}
+		else if ("1.3".equals(version)) {
+			l_isJVM13 = true;
+			l_isJVM12 = l_isJVM14 = false;
+		}
+		else if ("1.4".equals(version) || ("1.4".compareTo(version) < 0)) {
+			// Fail safe if anything about JVM 1.4 comes out whilst this code 
+			// is still around
+			l_isJVM14 = true;
+			l_isJVM12 = l_isJVM13 = false;
+		}
+		else {
+			throw new DepotError("Unhandled JVM version: " + version);
+		}
+
+	}
+
+	public static boolean isJVM12() {
+		if (!l_initialized)
+			initialize();
+
+		return l_isJVM12;
+	}
+
+	public static boolean isJVM13() {
+		if (!l_initialized)
+			initialize();
+
+		return l_isJVM13;
+	}
+
+	public static boolean isJVM14() {
+		if (!l_initialized)
+			initialize();
+
+		return l_isJVM14;
+	}
+
+	public static Object callMethod(Object obj, String name) {
+		return attemptMethod(obj, name, null);
+	}
+
+	public static Object callMethod(Object obj, String name, Object argument) {
+		Object args[] = new Object[1];
+		args[0] = argument;
+
+		return attemptMethod(obj, name, args);
+	}
+
+	public static Object callMethod(
+		Object obj,
+		String name,
+		Class argumentClass,
+		Object argument) {
+		Class argClasses[] = new Class[1];
+		argClasses[0] = argumentClass;
+
+		Object args[] = new Object[1];
+		args[0] = argument;
+
+		return attemptMethod(obj, name, argClasses, args);
+	}
+
+	public static Object callMethod(
+		Object obj,
+		String name,
+		Object argument1,
+		Object argument2) {
+		Object args[] = new Object[2];
+		args[0] = argument1;
+		args[1] = argument2;
+
+		return attemptMethod(obj, name, args);
+	}
+
+	public static Object callMethod(
+		Object obj,
+		String name,
+		Object arguments[]) {
+		return attemptMethod(obj, name, arguments);
+	}
+
+	private static Object attemptMethod(
+		Object obj,
+		String name,
+		Object arguments[]) {
+		return attemptMethod(obj, name, null, arguments);
+	}
+
+	private static Object attemptMethod(
+		Object obj,
+		String name,
+		Class argumentClasses[],
+		Object arguments[]) {
+		Object result = null;
+
+		Class objectClass = obj.getClass();
+
+		//
+		//    Construct some if not passed...
+		//
+		if (null == argumentClasses) {
+			if (null != arguments) {
+				argumentClasses = new Class[arguments.length];
+
+				for (int i = 0; i < arguments.length; ++i) {
+					Class argClass = (arguments[i]).getClass();
+					argumentClasses[i] = argClass;
+				}
+			}
+			else {
+				argumentClasses = new Class[0];
+			}
+		}
+		else if (argumentClasses.length != arguments.length)
+			throw new DepotError(
+				"Mismatch Classes to Arguments: "
+					+ argumentClasses.length
+					+ " != "
+					+ arguments.length);
+
+		try {
+			Method method = objectClass.getMethod(name, argumentClasses);
+
+			int modifiers = method.getModifiers();
+
+			if (Modifier.isPublic(modifiers)
+				&& !Modifier.isStatic(modifiers)) {
+				result = method.invoke(obj, arguments);
+			}
+		}
+		catch (InvocationTargetException ite) {
+			Logger.getLogger().debug(
+				getMethodMessage(name, argumentClasses, arguments),
+				ite);
+		}
+		catch (IllegalAccessException iae) {
+			Logger.getLogger().debug(
+				getMethodMessage(name, argumentClasses, arguments),
+				iae);
+		}
+		catch (NoSuchMethodException nsme) {
+			Logger.getLogger().debug(
+				getMethodMessage(name, argumentClasses, arguments),
+				nsme);
+		}
+
+		return result;
+	}
+
+	private static String getMethodMessage(
+		String name,
+		Class argumentClasses[],
+		Object arguments[]) {
+		StringBuffer buffer =
+			new StringBuffer(
+				"Failed to \"Safely Invoke\" method [" + name + "] using [");
+		if (null != argumentClasses) {
+			buffer.append(Integer.toString(arguments.length));
+			buffer.append(" :");
+
+			for (int ac = 0; ac < argumentClasses.length; ++ac) {
+				Class clazz = argumentClasses[ac];
+				buffer.append(SystemUtils.getShortName(clazz));
+				if ((ac + 1) < argumentClasses.length)
+					buffer.append(", ");
+			}
+		}
+		buffer.append("] w/ [");
+		if (null != arguments) {
+			buffer.append(Integer.toString(arguments.length));
+			buffer.append(" :");
+
+			for (int a = 0; a < arguments.length; ++a) {
+				Object obj = arguments[a];
+				buffer.append(obj.toString());
+				if ((a + 1) < arguments.length)
+					buffer.append(", ");
+			}
+		}
+		buffer.append("]");
+
+		return buffer.toString();
+	}
+
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/io/IOUtils.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/io/IOUtils.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,77 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+
+public class IOUtils {
+
+	public static void transfer(InputStream input, OutputStream output)
+		throws IOException {
+		// Transfer the bytes in blocks..
+		byte b[] = new byte[1000];
+		int numRead = -1;
+		do {
+			numRead = input.read(b);
+			if (numRead != -1)
+				output.write(b, 0, numRead);
+		}
+		while (numRead != -1);
+	}
+
+	public static void close(Reader reader) {
+		if (null != reader) {
+			try {
+				reader.close();
+			}
+			catch (Exception e) {
+			}
+		}
+	}
+	public static void close(InputStream stream) {
+		if (null != stream) {
+			try {
+				stream.close();
+			}
+			catch (Exception e) {
+			}
+		}
+	}
+	public static void close(Writer writer) {
+		if (null != writer) {
+			try {
+				writer.close();
+			}
+			catch (Exception e) {
+			}
+		}
+	}
+	
+	public static void close(OutputStream stream) {
+		if (null != stream) {
+			try {
+				stream.close();
+			}
+			catch (Exception e) {
+			}
+		}
+	}
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/note/Annotation.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/note/Annotation.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,168 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.note;
+
+import org.apache.depot.common.util.debug.DebugUtils;
+import org.apache.depot.common.util.dom.DOMProducer;
+import org.apache.depot.common.util.dom.DOMUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * @version $Revision: $
+ */
+public class Annotation implements DOMProducer {
+	static final int UNSET = 0;
+	static final int DEBUG = 1;
+	static final int VERBOSE = 2;
+	static final int INFORMATION = 3;
+	static final int WARNING = 4;
+	static final int ERROR = 5;
+
+	private int m_qualifier = 0;
+	private Object m_content = null;
+	private Throwable m_throwable = null;
+
+	public Annotation(int qualifier, Object content) {
+		m_qualifier = qualifier;
+		m_content = content;
+		m_throwable = null;
+	}
+
+	public Annotation(int qualifier, Object content, Throwable throwable) {
+		m_qualifier = qualifier;
+		m_content = content;
+		m_throwable = throwable;
+	}
+
+	public String getQualifierAsString() {
+		String str = "unset";
+
+		switch (m_qualifier) {
+			case DEBUG :
+				{
+					str = "DEBUG";
+					break;
+				}
+			case VERBOSE :
+				{
+					str = "VERBOSE";
+					break;
+				}
+			case INFORMATION :
+				{
+					str = "INFORMATION";
+					break;
+				}
+			case WARNING :
+				{
+					str = "WARNING";
+					break;
+				}
+			case ERROR :
+				{
+					str = "ERROR";
+					break;
+				}
+		}
+
+		return str;
+	}
+
+	public String toString() {
+		StringBuffer buffer = new StringBuffer();
+
+		buffer.append(getQualifierAsString());
+		buffer.append(": ");
+		buffer.append(getContentString());
+
+
+		return buffer.toString();
+
+	}
+	
+	public String getContentString() {
+		StringBuffer buffer = new StringBuffer();
+
+		buffer.append(m_content.toString());
+		
+		if (null != m_throwable) {
+			buffer.append(": ");
+			buffer.append(m_throwable.getLocalizedMessage());
+			buffer.append("\n");
+			buffer.append(DebugUtils.getDump(m_throwable));
+		}
+
+		return buffer.toString();
+
+	}
+
+	/**
+	 * Returns the qualifier.
+	 * @return int
+	 */
+	int getQualifier() {
+		return m_qualifier;
+	}
+
+	public boolean isError() {
+		return m_qualifier == Annotation.ERROR;
+	}
+	public boolean isWarning() {
+		return m_qualifier == Annotation.WARNING;
+	}
+	public boolean isInformation() {
+		return m_qualifier == Annotation.INFORMATION;
+	}
+
+	public boolean isVerbose() {
+		return m_qualifier == Annotation.VERBOSE;
+	}
+	public boolean isDebug() {
+		return m_qualifier == Annotation.DEBUG;
+	}
+
+	/**
+	 * Returns the content.
+	 * @return Object
+	 */
+	public Object getContent() {
+		return m_content;
+	}
+
+	/**
+	 * @return
+	 */
+	public Throwable getThrowable() {
+		return m_throwable;
+	}
+
+	public void produceDOM(Document document, Element element) {
+		Element annotation = DOMUtils.insertElement(document, element, this);
+		DOMUtils.insertAttribute(
+			document,
+			annotation,
+			"severity",
+			getQualifierAsString());
+		DOMUtils.insertText(document, annotation, m_content.toString());
+		if (null != m_throwable)
+			DOMUtils.insertText(
+				document,
+				annotation,
+				DebugUtils.getDump(m_throwable));
+	}
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/note/AnnotationIterator.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/note/AnnotationIterator.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,91 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.note;
+
+import java.util.Iterator;
+
+/**
+ * @version $Revision: $
+ */
+public class AnnotationIterator implements Iterator {
+
+	private int m_qualifier = Annotation.UNSET;
+	private boolean m_equalOrGreater = true;
+	private Iterator m_baseIterator = null;
+
+	private Object m_nextAnnotation = null;
+
+	/**
+	 * Constructor for AnnotationIterator.
+	 */
+	public AnnotationIterator(AnnotationScratchpad pad, int qualifier) {
+		m_baseIterator = pad.iterator();
+		m_qualifier = qualifier;
+
+		lookAhead();
+	}
+
+	/**
+	 * Constructor for AnnotationIterator.
+	 */
+	public AnnotationIterator(
+		AnnotationScratchpad pad,
+		int qualifier,
+		boolean equalOrGreater) {
+		m_baseIterator = pad.iterator();
+		m_qualifier = qualifier;
+		m_equalOrGreater = equalOrGreater;
+
+		lookAhead();
+	}
+
+	public boolean hasNext() {
+		return (null != m_nextAnnotation);
+	}
+
+	public Object next() {
+		Object nextAnnotation = m_nextAnnotation;
+
+		lookAhead();
+
+		return nextAnnotation;
+	}
+
+	public void remove() {
+		lookAhead();
+	}
+
+	private void lookAhead() {
+		m_nextAnnotation = null;
+
+		for (; m_baseIterator.hasNext() && (null == m_nextAnnotation);) {
+			Object next = m_baseIterator.next();
+
+			if (next instanceof Annotation) {
+				Annotation note = (Annotation) next;
+
+				if ((note.getQualifier() == m_qualifier)
+					|| (m_equalOrGreater && (note.getQualifier() > m_qualifier)))
+					m_nextAnnotation = note;
+			}
+			else if (m_qualifier > Annotation.DEBUG) {
+				// Unqualified
+				m_nextAnnotation = next;
+			}
+		}
+	}
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/note/AnnotationScratchpad.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/note/AnnotationScratchpad.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,214 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.note;
+
+import java.io.PrintWriter;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.depot.common.util.collection.EntityList;
+import org.apache.depot.common.util.debug.DebugUtils;
+import org.apache.depot.common.util.debug.Dumpable;
+import org.apache.depot.common.util.dom.DOMProducer;
+import org.apache.depot.common.util.dom.DOMUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * @version $Revision: $
+ */
+public class AnnotationScratchpad implements Dumpable, DOMProducer {
+
+    private EntityList m_list = null;
+
+    /**
+     * Constructor for AnnotationScratchpad.
+     * @param c
+     */
+    public AnnotationScratchpad(AnnotationScratchpad otherPad) {
+        super();
+
+        m_list = new EntityList("Annotations", otherPad.m_list);
+    }
+
+    /**
+     * Constructor for AnnotationScratchpad.
+     * @param c
+     */
+    public AnnotationScratchpad(int maxSize) {
+        super();
+
+        m_list = new EntityList("Annotations");
+        m_list.setMaxSize(maxSize);
+    }
+
+	/**
+	 * Constructor for AnnotationScratchpad.
+	 * @param c
+	 */
+	public AnnotationScratchpad(String title) {
+		super();
+
+		m_list = new EntityList(title);
+	}
+	
+	/**
+		* Constructor for AnnotationScratchpad.
+		* @param c
+		*/
+	   public AnnotationScratchpad() {
+		   super();
+
+		   m_list = new EntityList("Annotations");
+	   }
+
+    /**
+     * Constructor for AnnotationScratchpad.
+     * @param c
+     */
+    public AnnotationScratchpad(Collection c) {
+        super();
+
+        m_list = new EntityList("Annotations",c);
+    }
+
+    public Annotation debug(Object content) {
+        Annotation note = new Annotation(Annotation.DEBUG, content);
+        m_list.add(note);
+        return note;
+    }
+
+    public Annotation debug(Object content, Throwable throwable) {
+        Annotation note = new Annotation(Annotation.DEBUG, content, throwable);
+        m_list.add(note);
+        return note;
+    }
+
+    public Annotation verbose(Object content) {
+        Annotation note = new Annotation(Annotation.VERBOSE, content);
+        m_list.add(note);
+        return note;
+    }
+    public Annotation verbose(Object content, Throwable throwable) {
+        Annotation note =
+            new Annotation(Annotation.VERBOSE, content, throwable);
+        m_list.add(note);
+        return note;
+    }
+
+    public Annotation warning(Object content) {
+        Annotation note = new Annotation(Annotation.WARNING, content);
+        m_list.add(note);
+        return note;
+    }
+    public Annotation warning(Object content, Throwable throwable) {
+        Annotation note =
+            new Annotation(Annotation.WARNING, content, throwable);
+        m_list.add(note);
+        return note;
+    }
+
+    public Annotation info(Object content) {
+        Annotation note = new Annotation(Annotation.INFORMATION, content);
+        m_list.add(note);
+        return note;
+    }
+    public Annotation info(Object content, Throwable throwable) {
+        Annotation note =
+            new Annotation(Annotation.INFORMATION, content, throwable);
+        m_list.add(note);
+        return note;
+    }
+
+    public Annotation error(Object content) {
+        Annotation note = new Annotation(Annotation.ERROR, content);
+        m_list.add(note);
+        return note;
+    }
+    public Annotation error(Object content, Throwable throwable) {
+        Annotation note = new Annotation(Annotation.ERROR, content, throwable);
+        m_list.add(note);
+        return note;
+    }
+
+    public void addPad(AnnotationScratchpad pad) {
+        m_list.addAll(pad.m_list);
+    }
+
+    public Iterator iterator() {
+        return m_list.iterator();
+    }
+
+    public Iterator errorIterator() {
+        return new AnnotationIterator(this, Annotation.ERROR);
+    }
+
+    public Iterator infoIterator() {
+        return new AnnotationIterator(this, Annotation.INFORMATION);
+    }
+
+    public Iterator verboseIterator() {
+        return new AnnotationIterator(this, Annotation.VERBOSE);
+    }
+
+    public Iterator debugIterator() {
+        return new AnnotationIterator(this, Annotation.DEBUG);
+    }
+
+    public boolean hasAnnotations() {
+        return !m_list.isEmpty();
+    }
+
+    public boolean hasErrors() {
+        return errorIterator().hasNext();
+    }
+
+    public int size() {
+        return m_list.size();
+    }
+
+    public void dump(PrintWriter out, int depth, boolean verbose) {
+
+        final String indent = DebugUtils.getIndent(depth);
+        final String indent1 = DebugUtils.getIndent(depth+1);
+
+        out.print(indent);
+        out.println(m_list.getName());
+        if (hasAnnotations()) {
+            out.print(indent);
+            out.println("(");
+            for (Iterator i = m_list.iterator(); i.hasNext();) {
+                Object entry = (Object) i.next();
+
+                if (entry instanceof Dumpable) {
+                    Dumpable d = (Dumpable) entry;
+                    d.dump(out, depth + 1, verbose);
+                }
+                else {
+                    out.print(indent1);
+                    out.println(entry.toString());
+                }
+            }
+            out.print(indent);
+            out.println(")");
+        }
+    }
+    
+	public void produceDOM(Document document, Element element) {
+		DOMUtils.produceDOM(document, element, (DOMProducer)m_list);
+	}
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/throwable/PortableError.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/throwable/PortableError.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,115 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.throwable;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+import org.apache.depot.common.util.envsafe.RelativelySafe;
+
+/**
+ * @author ajack
+ */
+public class PortableError extends Error {
+
+    private Throwable m_cause = null;
+
+    /**
+     * Constructor for PortableError.
+     */
+    public PortableError() {
+        super();
+    }
+
+    /**
+     * Constructor for PortableError.
+     * @param message
+     */
+    public PortableError(String message) {
+        super(message);
+    }
+
+    /**
+     * Constructor for PortableError.
+     * @param message
+     * @param cause
+     */
+    public PortableError(String message, Throwable cause) {
+        super(message);
+        setCause(cause);
+    }
+
+    /**
+     * Constructor for PortableError.
+     * @param cause
+     */
+    public PortableError(Throwable cause) {
+        super();
+        setCause(cause);
+    }
+
+    /**
+     * Returns the cause.
+     * @return Throwable
+     */
+    public Throwable getCause() {
+        return m_cause;
+    }
+
+    /**
+     * Sets the cause.
+     * @param cause The cause to set
+     */
+    public void setCause(Throwable cause) {
+        m_cause = cause;
+
+        RelativelySafe.callMethod(this, "initCause", cause);
+    }
+
+    /**
+     * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
+     */
+    public void printStackTrace() {
+        super.printStackTrace();
+
+        if (null != m_cause) {
+            System.err.println("Caused By:" + m_cause.toString());
+            m_cause.printStackTrace();
+        }
+    }
+
+    /**
+     * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
+     */
+    public void printStackTrace(PrintWriter out) {
+        super.printStackTrace(out);
+
+        if (null != m_cause) {
+            out.println("Caused By:" + m_cause.toString());
+            m_cause.printStackTrace(out);
+        }
+    }
+
+    public void printStackTrace(PrintStream out) {
+        super.printStackTrace(out);
+
+        if (null != m_cause) {
+            out.println("Caused By:" + m_cause.toString());
+            m_cause.printStackTrace(out);
+        }
+    }
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/throwable/PortableException.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/throwable/PortableException.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,117 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.throwable;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+import org.apache.depot.common.util.envsafe.RelativelySafe;
+
+/**
+ * @author ajack
+ */
+public class PortableException extends Exception {
+
+    private Throwable m_cause = null;
+
+    /**
+     * Constructor for PortableException.
+     */
+    public PortableException() {
+        super();
+    }
+
+    /**
+     * Constructor for PortableException.
+     * @param message
+     */
+    public PortableException(String message) {
+        super(message);
+    }
+
+    /**
+     * Constructor for PortableException.
+     * @param message
+     * @param cause
+     */
+    public PortableException(String message, Throwable cause) {
+        super(message);
+
+        setCause(cause);
+    }
+
+    /**
+     * Constructor for PortableException.
+     * @param cause
+     */
+    public PortableException(Throwable cause) {
+        super();
+
+        setCause(cause);
+    }
+
+    /**
+     * Returns the cause.
+     * @return Throwable
+     */
+    public Throwable getCause() {
+        return m_cause;
+    }
+
+    /**
+     * Sets the cause.
+     * @param cause The cause to set
+     */
+    public void setCause(Throwable cause) {
+        m_cause = cause;
+
+        RelativelySafe.callMethod(this, "initCause", Throwable.class, cause);
+    }
+
+    /**
+     * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
+     */
+    public void printStackTrace() {
+        super.printStackTrace();
+
+        if (null != m_cause) {
+            System.err.println("Caused By:" + m_cause.toString());
+            m_cause.printStackTrace();
+        }
+    }
+
+    /**
+     * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
+     */
+    public void printStackTrace(PrintWriter out) {
+        super.printStackTrace(out);
+
+        if (null != m_cause) {
+            out.println("Caused By:" + m_cause.toString());
+            m_cause.printStackTrace(out);
+        }
+    }
+
+    public void printStackTrace(PrintStream out) {
+        super.printStackTrace(out);
+
+        if (null != m_cause) {
+            out.println("Caused By:" + m_cause.toString());
+            m_cause.printStackTrace(out);
+        }
+    }
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/throwable/PortableRuntimeException.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/throwable/PortableRuntimeException.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,115 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.throwable;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+import org.apache.depot.common.util.envsafe.RelativelySafe;
+
+/**
+ * @author ajack
+ */
+public class PortableRuntimeException extends RuntimeException {
+
+    private Throwable m_cause = null;
+
+    /**
+     * Constructor for PortableRuntimeException.
+     */
+    public PortableRuntimeException() {
+        super();
+    }
+
+    /**
+     * Constructor for PortableRuntimeException.
+     * @param message
+     */
+    public PortableRuntimeException(String message) {
+        super(message);
+    }
+
+    /**
+     * Constructor for PortableRuntimeException.
+     * @param message
+     * @param cause
+     */
+    public PortableRuntimeException(String message, Throwable cause) {
+        super(message);
+        setCause(cause);
+    }
+
+    /**
+     * Constructor for PortableRuntimeException.
+     * @param cause
+     */
+    public PortableRuntimeException(Throwable cause) {
+        super();
+        setCause(cause);
+    }
+
+    /**
+     * Returns the cause.
+     * @return Throwable
+     */
+    public Throwable getCause() {
+        return m_cause;
+    }
+
+    /**
+     * Sets the cause.
+     * @param cause The cause to set
+     */
+    public void setCause(Throwable cause) {
+        m_cause = cause;
+
+        RelativelySafe.callMethod(this, "initCause", cause);
+    }
+
+    /**
+     * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
+     */
+    public void printStackTrace() {
+        super.printStackTrace();
+
+        if (null != m_cause) {
+            System.err.println("Caused By:" + m_cause.toString());
+            m_cause.printStackTrace();
+        }
+    }
+
+    /**
+     * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
+     */
+    public void printStackTrace(PrintWriter out) {
+        super.printStackTrace(out);
+
+        if (null != m_cause) {
+            out.println("Caused By:" + m_cause.toString());
+            m_cause.printStackTrace(out);
+        }
+    }
+
+    public void printStackTrace(PrintStream out) {
+        super.printStackTrace(out);
+
+        if (null != m_cause) {
+            out.println("Caused By:" + m_cause.toString());
+            m_cause.printStackTrace(out);
+        }
+    }
+}

Added: incubator/depot/trunk/common/src/java/org/apache/depot/common/util/throwable/PortableThrowable.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/common/src/java/org/apache/depot/common/util/throwable/PortableThrowable.java	Sat Feb 28 14:23:06 2004
@@ -0,0 +1,115 @@
+/*
+ * Copyright  2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.depot.common.util.throwable;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+import org.apache.depot.common.util.envsafe.RelativelySafe;
+
+/**
+ * @author ajack
+ */
+public class PortableThrowable extends Throwable {
+
+    private Throwable m_cause = null;
+
+    /**
+     * Constructor for PortableThrowable.
+     */
+    public PortableThrowable() {
+        super();
+    }
+
+    /**
+     * Constructor for PortableThrowable.
+     * @param message
+     */
+    public PortableThrowable(String message) {
+        super(message);
+    }
+
+    /**
+     * Constructor for PortableThrowable.
+     * @param message
+     * @param cause
+     */
+    public PortableThrowable(String message, Throwable cause) {
+        super(message);
+        setCause(cause);
+    }
+
+    /**
+     * Constructor for PortableThrowable.
+     * @param cause
+     */
+    public PortableThrowable(Throwable cause) {
+        super();
+        setCause(cause);
+    }
+
+    /**
+     * Returns the cause.
+     * @return Throwable
+     */
+    public Throwable getCause() {
+        return m_cause;
+    }
+
+    /**
+     * Sets the cause.
+     * @param cause The cause to set
+     */
+    public void setCause(Throwable cause) {
+        m_cause = cause;
+
+        RelativelySafe.callMethod(this, "initCause", cause);
+    }
+
+    /**
+     * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
+     */
+    public void printStackTrace() {
+        super.printStackTrace();
+
+        if (null != m_cause) {
+            System.err.println("Caused By:" + m_cause.toString());
+            m_cause.printStackTrace();
+        }
+    }
+
+    /**
+     * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
+     */
+    public void printStackTrace(PrintWriter out) {
+        super.printStackTrace(out);
+
+        if (null != m_cause) {
+            out.println("Caused By:" + m_cause.toString());
+            m_cause.printStackTrace(out);
+        }
+    }
+
+    public void printStackTrace(PrintStream out) {
+        super.printStackTrace(out);
+
+        if (null != m_cause) {
+            out.println("Caused By:" + m_cause.toString());
+            m_cause.printStackTrace(out);
+        }
+    }
+}

Mime
View raw message