You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2006/03/31 21:59:17 UTC

svn commit: r390489 [3/4] - in /webservices/axis2/trunk/archive/java/scratch/dennis: ./ bin/ docs/ docs/soaps/ lib/ src/ src/com/ src/com/sosnoski/ src/com/sosnoski/args/ src/com/sosnoski/xmlbench/ src/com/sosnoski/xmlbench/models/

Added: webservices/axis2/trunk/archive/java/scratch/dennis/lib/Piccolo.jar
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/dennis/lib/Piccolo.jar?rev=390489&view=auto
==============================================================================
Binary file - no diff available.

Propchange: webservices/axis2/trunk/archive/java/scratch/dennis/lib/Piccolo.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: webservices/axis2/trunk/archive/java/scratch/dennis/lib/axiom-api-SNAPSHOT.jar
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/dennis/lib/axiom-api-SNAPSHOT.jar?rev=390489&view=auto
==============================================================================
Binary file - no diff available.

Propchange: webservices/axis2/trunk/archive/java/scratch/dennis/lib/axiom-api-SNAPSHOT.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: webservices/axis2/trunk/archive/java/scratch/dennis/lib/axiom-impl-SNAPSHOT.jar
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/dennis/lib/axiom-impl-SNAPSHOT.jar?rev=390489&view=auto
==============================================================================
Binary file - no diff available.

Propchange: webservices/axis2/trunk/archive/java/scratch/dennis/lib/axiom-impl-SNAPSHOT.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: webservices/axis2/trunk/archive/java/scratch/dennis/lib/dom4j.jar
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/dennis/lib/dom4j.jar?rev=390489&view=auto
==============================================================================
Binary file - no diff available.

Propchange: webservices/axis2/trunk/archive/java/scratch/dennis/lib/dom4j.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: webservices/axis2/trunk/archive/java/scratch/dennis/lib/jdom.jar
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/dennis/lib/jdom.jar?rev=390489&view=auto
==============================================================================
Binary file - no diff available.

Propchange: webservices/axis2/trunk/archive/java/scratch/dennis/lib/jdom.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: webservices/axis2/trunk/archive/java/scratch/dennis/lib/stax-api-1.0.jar
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/dennis/lib/stax-api-1.0.jar?rev=390489&view=auto
==============================================================================
Binary file - no diff available.

Propchange: webservices/axis2/trunk/archive/java/scratch/dennis/lib/stax-api-1.0.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: webservices/axis2/trunk/archive/java/scratch/dennis/lib/wstx-asl-2.8.2.jar
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/dennis/lib/wstx-asl-2.8.2.jar?rev=390489&view=auto
==============================================================================
Binary file - no diff available.

Propchange: webservices/axis2/trunk/archive/java/scratch/dennis/lib/wstx-asl-2.8.2.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: webservices/axis2/trunk/archive/java/scratch/dennis/lib/xercesImpl.jar
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/dennis/lib/xercesImpl.jar?rev=390489&view=auto
==============================================================================
Binary file - no diff available.

Propchange: webservices/axis2/trunk/archive/java/scratch/dennis/lib/xercesImpl.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: webservices/axis2/trunk/archive/java/scratch/dennis/lib/xml-apis.jar
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/dennis/lib/xml-apis.jar?rev=390489&view=auto
==============================================================================
Binary file - no diff available.

Propchange: webservices/axis2/trunk/archive/java/scratch/dennis/lib/xml-apis.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/ArgumentProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/ArgumentProcessor.java?rev=390489&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/ArgumentProcessor.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/ArgumentProcessor.java Fri Mar 31 11:59:03 2006
@@ -0,0 +1,267 @@
+/*
+ * Copyright (c) 2002 Sosnoski Software Solutions, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+package com.sosnoski.args;
+
+import java.io.PrintStream;
+import java.lang.reflect.Field;
+
+/**
+ * Command line argument processing handler. Organizes all the argument
+ * information, including the data object to which parameter values defined
+ * by the command line are stored. Provides specialized processing for the
+ * argument strings, including recognizing the '-' character at the start of
+ * an argument as indicating that the argument provides control information 
+ * (flags and possibly embedded values) as opposed to data.
+ *
+ * @author Dennis M. Sosnoski
+ * @version 1.0
+ */
+
+public class ArgumentProcessor
+{
+	/** Head of parameter set chain. */
+	protected ParameterSet m_parameterSet;
+	
+	/** Character tracker for current argument. */
+	protected CharTracker m_currentArg;
+	
+	/** Current argument position in list. */
+	protected int m_currentIndex;
+
+	/** String tracker for full set of arguments. */
+	protected StringTracker m_remainingArgs;
+	
+	/** Parameter data object. */
+	protected Object m_parameterData;
+
+	/**
+	 * Constructor
+	 *
+	 * @param set head parameter set in possible chain of sets defined
+	 */
+	
+	public ArgumentProcessor(ParameterSet set) {
+		m_parameterSet = set;
+	}
+
+	/**
+	 * Process argument list control information. Processes control flags
+	 * present in the supplied argument list, setting the associated parameter
+	 * values. Arguments not consumed in the control flag processing are
+	 * available for access using other methods after the return from this
+	 * call.
+	 *
+	 * @param args command line argument string array
+	 * @param parm data object for parameter values
+	 * @throws ParameterErrorException on error in data
+	 * @throws IllegalArgumentException on error in processing
+	 */
+	
+	public Object processArgs(String[] args, Object parm) {
+		
+		// clean up argument text (may have CR-LF line ends, confusing Linux)
+		String[] trims = new String[args.length];
+		for (int i = 0; i < args.length; i++) {
+			trims[i] = args[i].trim();
+		}
+		
+		// initialize argument list information
+		m_currentArg = new CharTracker("", 0);
+		m_remainingArgs = new StringTracker(trims, 0);
+		m_parameterData = parm;
+		
+		// loop for processing all parameter values present
+		while (true) {
+			if (m_currentArg.hasNext()) {
+				
+				// find the parameter definition for current flag character
+				char flag = m_currentArg.next();
+				ParameterDef def = m_parameterSet.findDef(flag);
+				if (def != null) {
+					
+					// process the parameter
+					def.handle(this);
+					
+				} else {
+					throw new IllegalArgumentException("Control flag '" + 
+						flag + "' in argument " + m_currentIndex + 
+						" is not defined");
+				}
+				
+			} else if (m_remainingArgs.hasNext()) {
+				
+				// check if more control flags in next argument
+				String next = m_remainingArgs.peek();
+				if (next.length() > 0 && next.charAt(0) == '-') {
+					m_remainingArgs.next();
+					m_currentIndex = m_remainingArgs.nextOffset();
+					m_currentArg = new CharTracker(next, 1);
+				} else {
+					break;
+				}
+				
+			} else {
+				break;
+			}
+		}
+		return m_parameterData;
+	}
+
+	/**
+	 * Get current control argument character information. The caller can 
+	 * consume characters from the current argument as needed.
+	 *
+	 * @return argument string tracking information
+	 */
+
+	public CharTracker getChars() {
+		return m_currentArg;
+	}
+
+	/**
+	 * Get current argument position in list.
+	 *
+	 * @return offset in argument list of current flag argument
+	 */
+
+	public int getIndex() {
+		return m_currentIndex;
+	}
+
+	/**
+	 * Get argument list information. The caller can comsume arguments
+	 * from the list as needed.
+	 *
+	 * @return argument list information
+	 */
+
+	public StringTracker getArgs() {
+		return m_remainingArgs;
+	}
+
+	/**
+	 * Set parameter value. Uses reflection to set a value within the
+	 * parameter data object.
+	 *
+	 * @param value value to be set for parameter
+	 * @param field parameter field description
+	 * @throws IllegalArgumentException on error in setting parameter value
+	 */
+
+	public void setValue(Object value, Field field) {
+		try {
+			field.set(m_parameterData, value);
+		} catch (IllegalAccessException ex) {
+			throw new IllegalArgumentException("Field " + field.getName() +
+				" is not accessible in object of class " + 
+				m_parameterData.getClass().getName());
+		}
+	}
+
+	/**
+	 * Report parameter error. Generates an exception with information about
+	 * the argument causing the problem.
+	 *
+	 * @param flag argument flag character
+	 * @param text error message text
+	 * @throws ParameterErrorException reporting the error
+	 */
+
+	public void reportParameterError(char flag, String text) {
+		throw new ParameterErrorException(text + " for parameter '" + 
+			flag + "' in argument " + m_currentIndex);
+	}
+
+	/**
+	 * List known parameter definitions. This lists all known parameter
+	 * definitions in 80-column width format.
+	 *
+	 * @param print print stream destination for listing definitions
+	 */
+
+	public void listParameters(PrintStream print) {
+		
+		// scan once to find maximum parameter abbreviation length
+		int count = 0;
+		int maxlen = 0;
+		ParameterDef def = null;
+		while ((def = m_parameterSet.indexDef(count)) != null) {
+			int length = def.getAbbreviation().length();
+			if (maxlen < length) {
+				maxlen = length;
+			}
+			count++;
+		}
+		
+		// initialize for handling text generation
+		StringBuffer line = new StringBuffer(80);
+		int lead = maxlen + 2;
+		char[] blanks = new char[lead];
+		for (int i = 0; i < lead; i++) {
+			blanks[i] = ' ';
+		}
+		
+		// scan again to print text of definitions
+		for (int i = 0; i < count; i++) {
+			
+			// set up lead parameter abbreviation for first line
+			line.setLength(0);
+			def = m_parameterSet.indexDef(i);
+			line.append(' ');
+			line.append(def.getAbbreviation());
+			line.append(blanks, 0, lead-line.length());
+			
+			// format description text in as many lines as needed
+			String text = def.getDescription();
+			while (line.length()+text.length() > 80) {
+				
+				// scan for first line break position (even if beyond limit)
+				int limit = 80 - line.length();
+				int mark = text.indexOf(' ');
+				if (mark >= 0) {
+					
+					// find break position closest to limit
+					int split = mark;
+					while (mark >= 0 && mark <= limit) {
+						split = mark;
+						mark = text.indexOf(' ', mark+1);
+					}
+					
+					// split the description for printing line
+					line.append(text.substring(0, split));
+					print.println(line.toString());
+					line.setLength(0);
+					line.append(blanks);
+					text = text.substring(split+1);
+					
+				} else {
+					break;
+				}
+			}
+			
+			// print remainder of description in single line
+			line.append(text);
+			print.println(line.toString());
+		}
+	}
+}

Added: webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/CharTracker.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/CharTracker.java?rev=390489&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/CharTracker.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/CharTracker.java Fri Mar 31 11:59:03 2006
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2002 Sosnoski Software Solutions, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+package com.sosnoski.args;
+
+/**
+ * Character tracker for processing text. This is effectively a specialized
+ * iterator for processing characters in a string one at a time.
+ *
+ * @author Dennis M. Sosnoski
+ * @version 1.0
+ */
+
+public class CharTracker
+{
+	/** String supplying character data. */
+	protected String m_source;
+	
+	/** Current position within string. */
+	protected int m_position;
+
+	/**
+	 * Constructor
+	 *
+	 * @param source string supplying character data
+	 * @param offset initial character position within source string
+	 */
+	
+	public CharTracker(String source, int offset) {
+		m_source = source;
+		m_position = offset;
+	}
+
+	/**
+	 * Get next character from string, advancing past that character.
+	 *
+	 * @return next character from string
+	 * @exception ArrayIndexOutOfBoundsException if past end of text
+	 */
+
+	public char next() {
+		if (m_position < m_source.length()) {
+			return m_source.charAt(m_position++);
+		} else {
+			throw new ArrayIndexOutOfBoundsException(m_position);
+		}
+	}
+
+	/**
+	 * Peek next character from string. Gets the next character without
+	 * advancing the current character position.
+	 *
+	 * @return next character from string
+	 * @exception ArrayIndexOutOfBoundsException if past end of text
+	 */
+
+	public char peek() {
+		if (m_position < m_source.length()) {
+			return m_source.charAt(m_position);
+		} else {
+			throw new ArrayIndexOutOfBoundsException(m_position);
+		}
+	}
+
+	/**
+	 * Check if another character is available.
+	 *
+	 * @return <code>true</code> if a character is available, 
+	 * <code>false</code> if at end
+	 */
+
+	public boolean hasNext() {
+		return m_position < m_source.length();
+	}
+}

Added: webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/FlagDef.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/FlagDef.java?rev=390489&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/FlagDef.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/FlagDef.java Fri Mar 31 11:59:03 2006
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2002 Sosnoski Software Solutions, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+package com.sosnoski.args;
+
+
+/**
+ * Command line flag definition. This defines a simple command line flag that
+ * sets a boolean parameter value. Both <code>true</code> and <code>false</code>
+ * settings are supported.
+ *
+ * @author Dennis M. Sosnoski
+ * @version 1.0
+ */
+
+public class FlagDef extends ParameterDef
+{
+	/** Value set when flag is seen. */
+	protected boolean m_value;
+
+	/**
+	 * Constructor with flag sense specified.
+	 *
+	 * @param chr parameter flag character
+	 * @param clas class definition for parameter value object
+	 * @param name field name for parameter
+	 * @param desc discription text for parameter
+	 * @param sense value set when flag is seen
+	 * @throws IllegalArgumentException if the field is not a boolean
+	 */
+	
+	public FlagDef(char chr, Class clas, String name, String desc, 
+		boolean sense) {
+		super(chr, clas, name, desc);
+		m_value = sense;
+		Class type = m_field.getType();
+		if (type != Boolean.class && type != Boolean.TYPE) {
+			throw new IllegalArgumentException
+				("Reference field must be a boolean");
+		}
+	}
+
+	/**
+	 * Constructor defaulting to flag <code>true</code>.
+	 *
+	 * @param chr parameter flag character
+	 * @param clas class definition for parameter value object
+	 * @param name field name for parameter
+	 * @param desc discription text for parameter
+	 * @throws IllegalArgumentException if the field is not a boolean
+	 */
+	
+	public FlagDef(char chr, Class clas, String name, String desc) {
+		this(chr, clas, name, desc, true);
+	}
+
+	/**
+	 * Handle parameter. This implementation of the abstract base class method
+	 * just sets the parameter value as appropriate for the flag.
+	 *
+	 * @param proc argument processor making call to handler
+	 * @throws IllegalArgumentException on error in processing
+	 */
+
+	public void handle(ArgumentProcessor proc) {
+		proc.setValue(m_value ? Boolean.TRUE : Boolean.FALSE, m_field);
+	}
+}

Added: webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/IntDef.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/IntDef.java?rev=390489&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/IntDef.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/IntDef.java Fri Mar 31 11:59:03 2006
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2002 Sosnoski Software Solutions, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+package com.sosnoski.args;
+
+import java.lang.reflect.Field;
+
+/**
+ * Command line integer parameter definition. This defines a command line flag
+ * with an associated integer value. The optionally signed value must 
+ * immediately follow the flag character within the same argument string.
+ *
+ * @author Dennis M. Sosnoski
+ * @version 1.0
+ */
+
+public class IntDef extends ParameterDef
+{
+	/** Minimum allowed parameter value. */
+	protected int m_min;
+	
+	/** Maximum allowed parameter value. */
+	protected int m_max;
+
+	/**
+	 * Constructor
+	 *
+	 * @param chr parameter flag character
+	 * @param clas class definition for parameter value object
+	 * @param name field name for parameter
+	 * @param desc discription text for parameter
+	 * @param min minimum allowed value
+	 * @param max maximum allowed value
+	 * @throws IllegalArgumentException if the field is not an int
+	 */
+	
+	public IntDef(char chr, Class clas, String name, String desc, 
+		int min, int max) {
+		super(chr, clas, name, desc);
+		m_min = min;
+		m_max = max;
+		Class type = m_field.getType();
+		if (type != Integer.class && type != Integer.TYPE) {
+			throw new IllegalArgumentException
+				("Reference field must be an int");
+		}
+	}
+
+	/**
+	 * Get text abbreviation for parameter. This override of the base class
+	 * method returns "-cNN", where 'c' is the flag character for the parameter.
+	 *
+	 * @return text abbreviation for showing parameter
+	 */
+
+	public String getAbbreviation() {
+		return "-" + m_char + "NN";
+	}
+
+	/**
+	 * Handle parameter. This implementation of the abstract base class method
+	 * interprets the characters following the flag character as an optionally
+	 * signed decimal value. If the value is within the allowed range the
+	 * parameter is set to that value. Other flag characters may follow the
+	 * numeric value within the argument.
+	 *
+	 * @param proc argument processor making call to handler
+	 * @throws ParameterErrorException if decimal value missing or out of range
+	 * @throws IllegalArgumentException on error in processing
+	 */
+
+	public void handle(ArgumentProcessor proc) {
+		
+		// set up for validating
+		boolean minus = false;
+		boolean digits = false;
+		int value = 0;
+		CharTracker track = proc.getChars();
+		if (track.hasNext()) {
+			
+			// check for leading sign flag
+			char chr = track.peek();
+			if (chr == '-' || chr == '+') {
+				minus = chr == '-';
+				track.next();
+			}
+			
+			// accumulate all digits in value
+			while (track.hasNext()) {
+				chr = track.peek();
+				if (chr >= '0' && chr <= '9') {
+					track.next();
+					digits = true;
+					value = value*10 + (chr - '0');
+				} else {
+					break;
+				}
+			}
+		}
+		
+		// make sure we have a valid value
+		value = minus ? -value : value;
+		if (!digits) {
+			proc.reportParameterError(m_char, "Missing value");
+		} else if (value < m_min || value > m_max) {
+			proc.reportParameterError(m_char, "Value out of range");
+		} else {
+			proc.setValue(new Integer(value), m_field);
+		}
+	}
+}

Added: webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/ParameterDef.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/ParameterDef.java?rev=390489&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/ParameterDef.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/ParameterDef.java Fri Mar 31 11:59:03 2006
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2002 Sosnoski Software Solutions, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+package com.sosnoski.args;
+
+import java.lang.reflect.Field;
+
+/**
+ * Base class for command line parameter definitions. This is used for simple
+ * command line parameters of various flavors. Subclasses define the particular
+ * types of parameters supported.
+ *
+ * @author Dennis M. Sosnoski
+ * @version 1.0
+ */
+
+public abstract class ParameterDef
+{
+	/** Argument flag character. */
+	protected char m_char;
+
+	/** Field holding parameter value. */
+	protected Field m_field;
+	
+	/** Argument description text. */
+	protected String m_description;
+
+	/**
+	 * Constructor
+	 *
+	 * @param chr parameter flag character
+	 * @param clas class definition for parameter value object
+	 * @param name field name for parameter
+	 * @param desc discription text for parameter
+	 * @throws IllegalArgumentException if the field is not accessible
+	 */
+	
+	public ParameterDef(char chr, Class clas, String name, String desc) {
+		m_char = chr;
+		m_description = desc;
+		try {
+			m_field = clas.getField(name);
+		} catch (NoSuchFieldException ex) {
+			throw new IllegalArgumentException("Field '" + name +
+				"' not found in " + clas.getName());
+		}
+	}
+
+	/**
+	 * Get text abbreviation for parameter. The default format is just "-c", 
+	 * where 'c' is the flag character for the parameter. If a different format 
+	 * is needed by a subclass it should override this method.
+	 *
+	 * @return text abbreviation for showing parameter
+	 */
+
+	public String getAbbreviation() {
+		return "-" + m_char;
+	}
+
+	/**
+	 * Get flag character for parameter.
+	 *
+	 * @return flag character specifying the parameter
+	 */
+
+	public char getFlag() {
+		return m_char;
+	}
+
+	/**
+	 * Get text of parameter description.
+	 *
+	 * @param file file to be read
+	 * @return array of bytes containing all data from file
+	 * @throws IOException on file access error
+	 */
+
+	public String getDescription() {
+		return m_description;
+	}
+
+	/**
+	 * Handle parameter. This abstract method must be overridden in each
+	 * subclass to perform the appropriate processing, if necessary using
+	 * additional characters from the current argument or the next argument
+	 * in the list.
+	 *
+	 * @param proc argument processor making call to handler
+	 */
+
+	public abstract void handle(ArgumentProcessor proc);
+}

Added: webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/ParameterErrorException.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/ParameterErrorException.java?rev=390489&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/ParameterErrorException.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/ParameterErrorException.java Fri Mar 31 11:59:03 2006
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2002 Sosnoski Software Solutions, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+package com.sosnoski.args;
+
+/**
+ * Parameter error exception. This is used for reporting any errors encountered
+ * while processing command line arguments.
+ *
+ * @author Dennis M. Sosnoski
+ * @version 1.0
+ */
+
+public class ParameterErrorException extends RuntimeException
+{
+	/**
+	 * Constructor.
+	 *
+	 * @param text error message text
+	 */
+	
+	public ParameterErrorException(String text) {
+		super(text);
+	}
+}

Added: webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/ParameterSet.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/ParameterSet.java?rev=390489&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/ParameterSet.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/ParameterSet.java Fri Mar 31 11:59:03 2006
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2002 Sosnoski Software Solutions, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+package com.sosnoski.args;
+
+/**
+ * Command line parameter collection definition. Each collection consists of
+ * some number of parameter definitions. Multiple collections may be linked
+ * to function as a single collection.
+ *
+ * @author Dennis M. Sosnoski
+ * @version 1.0
+ */
+
+public class ParameterSet
+{
+	/** Parameters known by this handler. */
+	protected ParameterDef[] m_knownParameters;
+
+	/** Next parameter set for control flags not included in this one. */
+	protected ParameterSet m_nextSet;
+
+	/**
+	 * Constructor
+	 *
+	 * @param defs parameter definitions for this handler
+	 * @param next parameter set used for arguments not defined in this set
+	 */
+	
+	public ParameterSet(ParameterDef[] defs, ParameterSet next) {
+		m_knownParameters = defs;
+		m_nextSet = next;
+	}
+
+	/**
+	 * Find the parameter definition for a particular control flag. If the 
+	 * control flag is not defined in the set this will pass the call on
+	 * to the next set until we reach the end of the chain.
+	 *
+	 * @param flag control flag for parameter
+	 * @param parameter definition, or <code>null</code> if not defined
+	 */
+
+	public ParameterDef findDef(char flag) {
+		for (int i = 0; i < m_knownParameters.length; i++) {
+			if (flag == m_knownParameters[i].getFlag()) {
+				return m_knownParameters[i];
+			}
+		}
+		if (m_nextSet == null) {
+			return null;
+		} else {
+			return m_nextSet.findDef(flag);
+		}
+	}
+
+	/**
+	 * Get the parameter definition at a particular position in the list. If
+	 * the index value supplied is not defined in the set this will pass the
+	 * call on to the next set until we reach the end of the chain. The caller
+	 * can index through all defined values by starting at zero and
+	 * incrementing until a <code>null</code> is returned.
+	 *
+	 * @param index position for parameter definition to be returned
+	 * @param parameter definition, or <code>null</code> if not defined
+	 */
+
+	public ParameterDef indexDef(int index) {
+		if (index < m_knownParameters.length) {
+			return m_knownParameters[index];
+		} else if (m_nextSet == null) {
+			return null;
+		} else {
+			return m_nextSet.indexDef(index);
+		}
+	}
+}

Added: webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/StringDef.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/StringDef.java?rev=390489&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/StringDef.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/StringDef.java Fri Mar 31 11:59:03 2006
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2002 Sosnoski Software Solutions, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+package com.sosnoski.args;
+
+import java.lang.reflect.Field;
+
+/**
+ * Command line string parameter definition. This defines a command line flag
+ * with an associated string value, supplied as a separate argument on the
+ * command line. The argument giving the parameter value must be the next 
+ * unused argument from the command line, and must not begin with the '-'
+ * character used to indicate control parameter flags.
+ *
+ * @author Dennis M. Sosnoski
+ * @version 1.0
+ */
+
+public class StringDef extends ParameterDef
+{
+	/**
+	 * Constructor
+	 *
+	 * @param chr parameter flag character
+	 * @param clas class definition for parameter value object
+	 * @param name field name for parameter
+	 * @param desc discription text for parameter
+	 * @throws IllegalArgumentException if the field is not a string
+	 */
+	
+	public StringDef(char chr, Class clas, String name, String desc) {
+		super(chr, clas, name, desc);
+		Class type = m_field.getType();
+		if (type != String.class) {
+			throw new IllegalArgumentException
+				("Reference field must be a string");
+		}
+	}
+
+	/**
+	 * Handle parameter. This implementation of the abstract base class method
+	 * makes sure that we have another command line argument available, and
+	 * checks that the argument does not begin with the '-' character used to
+	 * indicate control parameter flags. If these conditions are met the
+	 * parameter is set to the string value of the argument.
+	 *
+	 * @param proc argument processor making call to handler
+	 * @throws ParameterErrorException if argument value missing or malformed
+	 * @throws IllegalArgumentException on error in processing
+	 */
+
+	public void handle(ArgumentProcessor proc) {
+		StringTracker args = proc.getArgs();
+		if (args.hasNext()) {
+			String arg = args.next();
+			if (arg.length() > 0 && arg.charAt(0) == '-') {
+				proc.reportParameterError(m_char, 
+					"Argument value starts with '-'");
+			} else {
+				proc.setValue(arg, m_field);
+			}
+		} else {
+			proc.reportParameterError(m_char, "Argument value missing");
+		}
+	}
+}

Added: webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/StringTracker.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/StringTracker.java?rev=390489&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/StringTracker.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/args/StringTracker.java Fri Mar 31 11:59:03 2006
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2002 Sosnoski Software Solutions, Inc.
+ *
+ * Permission is hereby granted, free of Stringge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+package com.sosnoski.args;
+
+/**
+ * String tracker for processing an array of strings. This is effectively a
+ * specialized iterator for processing an array of strings one at a time.
+ *
+ * @author Dennis M. Sosnoski
+ * @version 1.0
+ */
+
+public class StringTracker
+{
+	/** Array supplying string data. */
+	protected String[] m_source;
+	
+	/** Current position within array. */
+	protected int m_position;
+
+	/**
+	 * Constructor
+	 *
+	 * @param source array supplying string data
+	 * @param offset initial string position within source array
+	 */
+	
+	public StringTracker(String[] source, int offset) {
+		m_source = source;
+		m_position = offset;
+	}
+
+	/**
+	 * Get next string from array, advancing past that string.
+	 *
+	 * @return next string from array
+	 * @exception ArrayIndexOutOfBoundsException if past end of array
+	 */
+
+	public String next() {
+		return m_source[m_position++];
+	}
+
+	/**
+	 * Peek next string from array. Gets the next string without
+	 * advancing the current string position.
+	 *
+	 * @return next string from array
+	 * @exception ArrayIndexOutOfBoundsException if past end of array
+	 */
+
+	public String peek() {
+		return m_source[m_position];
+	}
+
+	/**
+	 * Check if another string is available.
+	 *
+	 * @return <code>true</code> if a string is available, 
+	 * <code>false</code> if at end
+	 */
+
+	public boolean hasNext() {
+		return m_position < m_source.length;
+	}
+
+	/**
+	 * Get position of next string in array.
+	 *
+	 * @return offset in array of next string
+	 */
+
+	public int nextOffset() {
+		return m_position;
+	}
+
+	/**
+	 * Get length of array.
+	 *
+	 * @return total number of strings in array
+	 */
+
+	public int length() {
+		return m_source.length;
+	}
+}

Added: webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/xmlbench/DocumentSummary.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/xmlbench/DocumentSummary.java?rev=390489&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/xmlbench/DocumentSummary.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/xmlbench/DocumentSummary.java Fri Mar 31 11:59:03 2006
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 2000-2001 Sosnoski Software Solutions, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+package com.sosnoski.xmlbench;
+
+/**
+ * Document summary information. This includes several count values
+ * characteristic of a document, allowing simple consistency checks across
+ * different representations of the document.
+ *
+ * @author Dennis M. Sosnoski
+ * @version 1.1
+ */
+
+public class DocumentSummary
+{
+	/** Number of elements. */
+	private int m_elementCount;
+
+	/** Number of content text segments. */
+	private int m_contentCount;
+
+	/** Number of attributes. */
+	private int m_attributeCount;
+
+	/** Number of characters of content text. */
+	private int m_textCharCount;
+
+	/** Number of characters of attribute data. */
+	private int m_attrCharCount;
+
+	/**
+	 * Reset count values.
+	 */
+
+	public void reset() {
+		m_elementCount = 0;
+		m_contentCount = 0;
+		m_attributeCount = 0;
+		m_textCharCount = 0;
+		m_attrCharCount = 0;
+	}
+
+	/**
+	 * Get element count.
+	 *
+	 * @return number of elements
+	 */
+
+	public int getElementCount() {
+		return m_elementCount;
+	}
+
+	/**
+	 * Get content segment count.
+	 *
+	 * @return number of content segments
+	 */
+
+	public int getContentCount() {
+		return m_contentCount;
+	}
+
+	/**
+	 * Get attribute count.
+	 *
+	 * @return number of attributes
+	 */
+
+	public int getAttributeCount() {
+		return m_attributeCount;
+	}
+
+	/**
+	 * Get text content character count.
+	 *
+	 * @return number of text characters
+	 */
+
+	public int getTextCharCount() {
+		return m_textCharCount;
+	}
+
+	/**
+	 * Get attribute value character count.
+	 *
+	 * @return number of attribute value characters
+	 */
+
+	public int getAttrCharCount() {
+		return m_attrCharCount;
+	}
+
+	/**
+	 * Add to element count.
+	 *
+	 * @param count value to be added to element count
+	 */
+
+	public void addElements(int count) {
+		m_elementCount += count;
+	}
+
+	/**
+	 * Count attribute. Increments the attribute count by one and adds the
+	 * supplied character count to the attribute data length.
+	 *
+	 * @param length attribute value text length
+	 */
+
+	public void addAttribute(int length) {
+		m_attributeCount++;
+		m_attrCharCount += length;
+	}
+
+	/**
+	 * Count content text segment. Increments the content segment count by one
+	 * and adds the supplied character count to the content text length.
+	 *
+	 * @param length attribute value text length
+	 */
+
+	public void addContent(int length) {
+		m_contentCount++;
+		m_textCharCount += length;
+	}
+
+	/**
+	 * Check if object is equal to this one.
+	 *
+	 * @param obj object to be compared
+	 * @return <code>true</code> if the values match, <code>false</code>
+	 * if not
+	 */
+
+	public boolean equals(Object obj) {
+		if (obj instanceof DocumentSummary) {
+			DocumentSummary comp = (DocumentSummary)obj;
+			return m_elementCount == comp.m_elementCount &&
+				m_contentCount == comp.m_contentCount &&
+				m_attributeCount == comp.m_attributeCount &&
+				m_textCharCount == comp.m_textCharCount &&
+				m_attrCharCount == comp.m_attrCharCount;
+		} else {
+			return false;
+		}
+	}
+
+	/**
+	 * Check if data and structure is equal to this one. This comparison 
+	 * ignores the text content segment count, since that can be changed 
+	 * by output formatting.
+	 *
+	 * @param obj object to be compared
+	 * @return <code>true</code> if the values match, <code>false</code>
+	 * if not
+	 */
+
+	public boolean dataEquals(Object obj) {
+		if (obj instanceof DocumentSummary) {
+			DocumentSummary comp = (DocumentSummary)obj;
+			return m_elementCount == comp.m_elementCount &&
+				m_attributeCount == comp.m_attributeCount &&
+				m_textCharCount == comp.m_textCharCount &&
+				m_attrCharCount == comp.m_attrCharCount;
+		} else {
+			return false;
+		}
+	}
+
+	/**
+	 * Check if object structure is equal to this one. This comparison ignores
+	 * the text content segment count and total character length, since that
+	 * can be changed by output formatting.
+	 *
+	 * @param obj object to be compared
+	 * @return <code>true</code> if the values match, <code>false</code>
+	 * if not
+	 */
+
+	public boolean structureEquals(Object obj) {
+		if (obj instanceof DocumentSummary) {
+			DocumentSummary comp = (DocumentSummary)obj;
+			return m_elementCount == comp.m_elementCount &&
+				m_attributeCount == comp.m_attributeCount &&
+				m_attrCharCount == comp.m_attrCharCount;
+		} else {
+			return false;
+		}
+	}
+}
+

Added: webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/xmlbench/TestBase.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/xmlbench/TestBase.java?rev=390489&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/xmlbench/TestBase.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/xmlbench/TestBase.java Fri Mar 31 11:59:03 2006
@@ -0,0 +1,293 @@
+/*
+ * Copyright (c) 2000-2001 Sosnoski Software Solutions, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+package com.sosnoski.xmlbench;
+
+import java.io.*;
+
+import java.util.*;
+
+/**
+ * Base class for XML benchmark tests. This class provides some basic methods
+ * used by the testing. It must be subclassed for each processing variation to
+ * be processed.
+ *
+ * @author Dennis M. Sosnoski
+ * @version 1.1
+ */
+
+public abstract class TestBase
+{
+	/** Total interval in milliseconds to wait for garbage collection. */
+	public static final long GARBAGE_COLLECT_DELAY = 1000;
+
+	/** Interval in milliseconds to wait each time. */
+	public static final long GARBAGE_UNIT_DELAY = 100;
+
+	/** Memory usage at start of test. */
+	protected static long m_lastMemory;
+
+	/** Time at start of test. */
+	protected static long m_lastTime;
+
+	/** Name for this test configuration. */
+	protected final String m_configName;
+
+	/** Optional variant information for test configuration. */
+	protected String m_configVariant;
+
+	/** Destination for test results listing. */
+	protected PrintStream m_printStream;
+
+	/** Flag for printing document summary information. */
+	protected boolean m_printSummary;
+
+	/** Flag for printing detailed pass results. */
+	protected boolean m_printPass;
+
+	/**
+	 * Constructor.
+	 *
+	 * @param config test configuration name
+	 */
+
+	protected TestBase(String config) {
+		m_configName = config;
+	}
+
+	/**
+	 * Initializes the memory state prior to a test run. This method first
+	 * requests a garbage collection operation, then waits for a fixed interval
+	 * in order to encourage the JVM to do the collection. It also sets the
+	 * start of test value for memory usage.
+	 */
+
+	protected void initMemory() {
+		long done = System.currentTimeMillis() + GARBAGE_COLLECT_DELAY;
+		Runtime rt = Runtime.getRuntime();
+		while (System.currentTimeMillis() < done) {
+			rt.gc();
+			try {
+				Thread.sleep(GARBAGE_UNIT_DELAY);
+			} catch (InterruptedException ex) {}
+		}
+		m_lastMemory = rt.totalMemory() - rt.freeMemory();
+	}
+
+	/**
+	 * Initializes the time prior to a test run. This method justs sets the
+	 * start of test time from the system clock.
+	 */
+
+	protected void initTime() {
+		m_lastTime = System.nanoTime();
+	}
+
+	/**
+	 * Report a value. Prints the leading text and the value with a space
+	 * between, if printing is enabled.
+	 *
+	 * @param lead leading text for test results
+	 * @param value value to be printed
+	 */
+
+	protected void reportValue(String lead, int value) {
+		if (m_printStream != null) {
+			m_printStream.println("  " + lead + ' ' + value);
+		}
+	}
+
+	/**
+	 * Find test pass time. Besides returning the time for the last test pass,
+	 * this sets the current time as the start of the next test pass.
+	 *
+	 * @return microseconds taken for the test
+	 */
+
+	protected int testPassTime() {
+		long now = System.nanoTime();
+		int time = (int)(now-m_lastTime);
+		m_lastTime = now;
+		return (time + 500) / 1000;
+	}
+
+	/**
+	 * Find test pass space. Besides returning the space for the last test pass,
+	 * this sets the current space usage as the start of the next test pass.
+	 *
+	 * @return bytes of memory added by test pass (negative if space released)
+	 */
+
+	protected int testPassSpace() {
+		long done = System.currentTimeMillis() + GARBAGE_COLLECT_DELAY;
+		while (System.currentTimeMillis() < done) {
+			System.gc();
+			try {
+				Thread.sleep(GARBAGE_UNIT_DELAY);
+			} catch (InterruptedException ex) {}
+		}
+		Runtime rt = Runtime.getRuntime();
+		long used = rt.totalMemory() - rt.freeMemory();
+		long diff = used - m_lastMemory;
+		m_lastMemory = used;
+		return (int)diff;
+	}
+
+	/**
+	 * Report the results of a time test run. Prints the time taken for the
+	 * last test and sets the current time as the start time for the next
+	 * test.
+	 *
+	 * @param test test description for display
+	 * @return milliseconds taken for the test
+	 */
+
+	protected int reportTime(String test) {
+		int time = testPassTime();
+		if (m_printStream != null) {
+			m_printStream.println("  " + test + " in " + time + " micros.");
+		}
+		return time;
+	}
+
+	/**
+	 * Report the results of a memory test run. First attempts a
+	 * garbage collection operation before computing the difference between
+	 * the memory in use at the end of the test and that in use at the start
+	 * of the test. Prints the space used by the test and sets the current
+	 * space as the base for the next test.
+	 *
+	 * @param test test description for display
+	 * @return space used by test
+	 */
+
+	protected int reportSpace(String test) {
+		int space = testPassSpace();
+		if (m_printStream != null) {
+			m_printStream.println("  " + test + " used space " + space);
+		}
+		return space;
+	}
+
+	/**
+	 * Print document summary information. Prints the information with a
+	 * supplied lead phrase.
+	 *
+	 * @param lead lead text phrase for document summary
+	 * @param info document summary information
+	 * @param print stream on which to print
+	 */
+
+	protected void printSummary(String lead, DocumentSummary info,
+		PrintStream print) {
+		print.println(lead + " has " + info.getElementCount() +
+			" elements, " +	info.getAttributeCount() +
+			" attributes with " + info.getAttrCharCount() +
+			" characters of data, and " + info.getContentCount() +
+			" content text segments with " + info.getTextCharCount() +
+			" characters of text");
+	}
+
+	/**
+	 * Get configuration name. Returns the name of the document model used
+	 * by this test, with any supplied variant information appended in
+	 * parenthesis.
+	 *
+	 * @return document model name
+	 */
+
+	public String getName() {
+		if (m_configVariant == null) {
+			return m_configName;
+		} else {
+			return m_configName + " (" + m_configVariant + ')';
+		}
+	}
+
+	/**
+	 * Set configuration variant information. This may be used by subclasses
+	 * which need to deal with several variations of a single configuration.
+	 *
+	 * @param variant configuration variant description, appended to name
+	 */
+
+	protected void setVariant(String variant) {
+		m_configVariant = variant;
+	}
+
+	/**
+	 * Set output print stream for printing detailed test run results.
+	 *
+	 * @param print test results listing destination (<code>null</code> if
+	 * no listing output)
+	 */
+
+	public void setPrint(PrintStream print) {
+		m_printStream = print;
+	}
+
+	/**
+	 * Set flag for printing document summary information.
+	 *
+	 * @param show flag for document summary information to be printed
+	 */
+
+	public void setShowDocument(boolean show) {
+		m_printSummary = show;
+	}
+
+	/**
+	 * Set flag for printing individual test pass results.
+	 *
+	 * @param show flag for document summary information to be printed
+	 */
+
+	public void setShowPass(boolean show) {
+		m_printPass = show;
+	}
+
+	/**
+	 * Main time test method. This must be implemented by the subclass to
+	 * perform the sequence of speed tests appropriate to the test
+	 * platform.
+	 *
+	 * @param passes number of passes of each test
+	 * @param excludes number of initialization passes excluded from averages
+	 * @param texts document texts for test
+	 * @return result times array
+	 */
+
+	public abstract int[] runTimeTest(int passes, int excludes, byte[][] texts);
+
+	/**
+	 * Main space test method. This must be implemented by the subclass to
+	 * perform the sequence of space tests appropriate to the test
+	 * platform.
+	 *
+	 * @param passes number of passes of each test
+	 * @param excludes number of initialization passes excluded from averages
+	 * @param texts document texts for test
+	 * @return result spaces array
+	 */
+
+	public abstract int[] runSpaceTest(int passes, int excludes, byte[][] texts);
+}

Added: webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/xmlbench/XMLBench.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/xmlbench/XMLBench.java?rev=390489&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/xmlbench/XMLBench.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/xmlbench/XMLBench.java Fri Mar 31 11:59:03 2006
@@ -0,0 +1,281 @@
+/*
+ * Copyright (c) 2000-2001 Sosnoski Software Solutions, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+package com.sosnoski.xmlbench;
+
+import com.sosnoski.args.ArgumentProcessor;
+import com.sosnoski.args.FlagDef;
+import com.sosnoski.args.ParameterDef;
+import com.sosnoski.args.ParameterErrorException;
+import com.sosnoski.args.ParameterSet;
+import com.sosnoski.args.StringDef;
+import com.sosnoski.xmlbench.models.BenchAxiom;
+import com.sosnoski.xmlbench.models.BenchDOM4J;
+import com.sosnoski.xmlbench.models.BenchJDOM;
+import com.sosnoski.xmlbench.models.BenchXerces2Base;
+import com.sosnoski.xmlbench.models.BenchXerces2Deferred;
+import com.sosnoski.xmlbench.models.ModelBase;
+
+/**
+ * Benchmark program for comparing performance of Java XML
+ * document representations. Performance is measured in terms of both
+ * speed and memory requirement for constructing the document representation
+ * from a SAX parse, and in terms of speed for walking the representation and
+ * generating text output.
+ *
+ * @author Dennis M. Sosnoski
+ * @version 1.1
+ */
+
+public class XMLBench extends XMLBenchBase
+{
+	/** Parameter definitions used by all subclasses. */
+	private static final ParameterDef[] BENCH_PARAMETERS =
+	{
+		new FlagDef('m', XMLBench.class, "m_testMem",
+			"run memory tests (default is time tests only, when testing " +
+			"both memory tests are run first)"),
+		new FlagDef('n', XMLBench.class, "m_testTime",
+			"do not run time tests (default is time tests only)", false),
+		new StringDef('u', XMLBench.class, "m_useParser",
+			"use specified SAX2 parser factory class " +
+			"(only for models using SAX2, default is Piccolo)"),
+	};
+	
+	/** Set of parameter definitions used by benchmark. */
+	protected static ParameterSet s_benchParameters = 
+		new ParameterSet(BENCH_PARAMETERS, s_baseParameters);
+	
+	/** Flag for testing memory usage. */
+	public boolean m_testMem;
+	
+	/** Flag for testing execution times. */
+	public boolean m_testTime = true;
+	
+	/** Parser factory class name. */
+	public String m_useParser = "com.apache.crimson.jaxp.SAXParserFactoryImpl";
+	
+	/** Instance of test implementation class. */
+	protected ModelBase m_testBench;
+
+	/**
+	 * Process test name argument. This override of the abstract base class
+	 * method adds a check for a valid test request, and creates the actual
+	 * test implementation instance for the model named by the user.
+	 *
+	 * @param name test name supplied by user
+	 * @throws ParameterErrorException on any form of parameter error
+	 */
+
+	protected void handleTestName(String name) {
+		
+		// make sure we have a test to execute
+		if (!m_testMem && !m_testTime) {
+			throw new ParameterErrorException
+				("Neither memory nor time tests - nothing to be done");
+		}
+		
+		// create the test instance
+		if (name.equalsIgnoreCase("JDOM")) {
+			m_testBench = new BenchJDOM(m_useParser);
+		} else if (name.equalsIgnoreCase("dom4j")) {
+			m_testBench = new BenchDOM4J(m_useParser);
+/*        } else if (name.equalsIgnoreCase("dom4jstax")) {
+            m_testBench = new BenchDOM4JStAX();     */
+        } else if (name.equalsIgnoreCase("axiom")) {
+            m_testBench = new BenchAxiom();
+		} else if (name.equalsIgnoreCase("Xerces2")) {
+			m_testBench = new BenchXerces2Base();
+		} else if (name.equalsIgnoreCase("Xerces2D")) {
+			m_testBench = new BenchXerces2Deferred();
+		} else {
+			throw new ParameterErrorException
+				("Unknown model name '" + name +'\'');
+		}
+		
+		// initialize with parameter settings
+		m_testBench.setPrint(System.out);
+		m_testBench.setShowDocument(m_summaryFlag);
+		m_testBench.setShowPass(m_detailFlag);
+	}
+
+	/**
+	 * Execute tests and print results. This implementation of the abstract
+	 * base class method runs the document model benchmarks tests.
+	 */
+
+	public void runTests() {
+
+		// report JVM and parameter information
+		printJVM(System.out);
+
+		// initialize results accumulation array
+		int tests = (m_testMem && m_testTime) ? 2 : 1;
+		int[][][] results = new int[tests][m_filePaths.length][];
+
+		// check for memory test needed
+		if (m_testMem) {
+
+			// execute the test sequence on supplied files
+			for (int i = 0; i < m_filePaths.length; i++) {
+
+				// check if we're printing results immediately
+				if (m_briefFlag | m_interpretFlag) {
+					if (i > 0) {
+						System.out.println();
+					}
+					System.out.print("Running " + m_testBench.getName() +
+						" memory test with " + m_passCount + " passes on ");
+					if (m_documentData[i].length == 1) {
+						System.out.println("file " + m_filePaths[i] + 
+							" (" + m_documentSizes[i] + " bytes):");
+					} else {
+						System.out.println("directory " + m_filePaths[i] +
+							" (" + m_documentData[i].length + 
+							" files totaling " + m_documentSizes[i] + 
+							" bytes):");
+					}
+				}
+
+				// collect test results
+				int[] values = m_testBench.runSpaceTest(m_passCount, 
+					m_excludeCount, m_documentData[i]);
+				results[0][i] = values;
+
+				// show results in brief format
+				if (m_briefFlag) {
+					showBrief(values, ModelBase.s_spaceShortDescriptions);
+				}
+
+				// show results in interpreted format
+				if (m_interpretFlag) {
+					showFull(values, ModelBase.s_spaceFullDescriptions);
+				}
+			}
+		}
+
+		// check for time test needed
+		if (m_testTime) {
+
+			// add spacer if running both types of tests
+			if (m_testMem) {
+				System.out.println();
+			}
+
+			// execute the test sequence on supplied files
+			int index = m_testMem ? 1 : 0;
+			for (int i = 0; i < m_filePaths.length; i++) {
+
+				// check if we're printing results immediately
+				if (m_briefFlag | m_interpretFlag) {
+					if (i > 0) {
+						System.out.println();
+					}
+					System.out.print("Running " + m_testBench.getName() +
+						" with " + m_passCount + " passes on ");
+					if (m_documentData[i].length == 1) {
+						System.out.println("file " + m_filePaths[i] + 
+							" (" + m_documentSizes[i] + " bytes):");
+					} else {
+						System.out.println("directory " + m_filePaths[i] +
+							" (" + m_documentData[i].length + 
+							" files totaling " + m_documentSizes[i] + 
+							" bytes):");
+					}
+				}
+
+				// collect test results
+				int[] values = m_testBench.runTimeTest
+					(m_passCount, m_excludeCount, m_documentData[i]);
+				results[index][i] = values;
+
+				// show results in brief format
+				if (m_briefFlag) {
+					showBrief(values, ModelBase.s_timeShortDescriptions);
+				}
+
+				// show results in interpreted format
+				if (m_interpretFlag) {
+					showFull(values, ModelBase.s_timeFullDescriptions);
+				}
+			}
+		}
+
+		// print compressed results for all files
+		if (m_compFlag) {
+			System.out.println("Compressed results for " + 
+				m_testBench.getName() + " with " + m_passCount + 
+				" passes on the following files:");
+			printDocumentList(System.out);
+			StringBuffer line = new StringBuffer();
+			line.append(m_testBench.getName());
+			if (m_testMem) {
+				buildCompressed(results[0],
+					ModelBase.s_spaceShortDescriptions, line);
+			}
+			if (m_testTime) {
+				int index = m_testMem ? 1 : 0;
+				buildCompressed(results[index],
+					ModelBase.s_timeShortDescriptions, line);
+			}
+			System.out.println(line);
+		}
+		System.out.println();
+	}
+
+	/**
+	 * Test driver, just reads the input parameters and executes the test.
+	 *
+	 * @param argv command line arguments
+	 */
+
+	public static void main(String[] argv) {
+		
+		// parse the command line arguments
+		ArgumentProcessor proc = new ArgumentProcessor(s_benchParameters);
+		XMLBench inst = new XMLBench();
+		boolean valid = inst.processArgs(argv, proc);
+		
+		// print usage information if problem with parameters
+		if (!valid) {
+			System.out.println("\nUsage: XMLBench [-options] test file-list\n" +
+				"Options are:");
+			proc.listParameters(System.out);
+			System.out.println
+				("These options may be concatenated together with a single" +
+				" leading dash.\n\n" +
+				"'test' may be any of the following values for document" +
+				" models:\n" +
+                " axiom    AXIOM with default StAX parser\n" +
+                " dom4j    dom4j with JAXP-compliant SAX2 parser\n" +
+//                " dom4jstax dom4j using StAX Event API (inefficient)\n" +
+				" jdom     JDOM with JAXP-compliant SAX2 parser\n" +
+				" xerces2  Xerces2 DOM and parser combination\n" +
+				" xerces2d Xerces2 deferred DOM and parser combination\n" +
+				"\nThe file-list consists of any number of file or directory" +
+				" names, in any\n" +
+				"combination. If a directory name is given, all files in the" +
+				" directory are\n" +
+				"processed once in each timing pass.\n");
+		}
+	}
+}

Added: webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/xmlbench/XMLBenchBase.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/xmlbench/XMLBenchBase.java?rev=390489&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/xmlbench/XMLBenchBase.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/xmlbench/XMLBenchBase.java Fri Mar 31 11:59:03 2006
@@ -0,0 +1,411 @@
+/*
+ * Copyright (c) 2000-2001 Sosnoski Software Solutions, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+package com.sosnoski.xmlbench;
+
+import java.io.*;
+import java.util.*;
+
+import com.sosnoski.args.*;
+
+/**
+ * Base class for XML benchmark programs. This provides some basic utilities
+ * used by all forms of benchmarks, along with the basic command line 
+ * processing.
+ *
+ * @author Dennis M. Sosnoski
+ * @version 1.2
+ */
+
+public abstract class XMLBenchBase
+{
+	/** Wait time between test documents (ms). */
+	public static final int DELAY_BETWEEN_DOCUMENTS = 400;
+
+	/** Output line length for brief format. */
+	public static final int BRIEF_LINE_LENGTH = 80;
+
+	/** Width of each item field in brief format. */
+	public static final int BRIEF_ITEM_WIDTH = 16;
+
+	/** Number of brief format items per output line. */
+	public static final int BRIEF_PER_LINE = BRIEF_LINE_LENGTH/BRIEF_ITEM_WIDTH;
+	
+	/** Parameter definitions used by all subclasses. */
+	private static final ParameterDef[] BASE_PARAMETERS =
+	{
+		new FlagDef('b', XMLBenchBase.class, "m_briefFlag",
+			"print brief results (with abbreviated captions)"),
+		new FlagDef('c', XMLBenchBase.class, "m_compFlag",
+			"print compressed results (comma-separated value fields with " +
+			"results ordered by type and within type by file, useful for " +
+			"spreadsheet import)"),
+		new FlagDef('d', XMLBenchBase.class, "m_detailFlag",
+			"print detailed per-pass information"),
+		new FlagDef('i', XMLBenchBase.class, "m_interpretFlag",
+			"print interpreted results (with full captions)"),
+		new FlagDef('s', XMLBenchBase.class, "m_summaryFlag",
+			"print summary information for each document"),
+		new FlagDef('v', XMLBenchBase.class, "m_versionFlag",
+			"print JVM version information"),
+		new IntDef('p', XMLBenchBase.class, "m_passCount",
+			"run NN passes of each operation on each document, where " +
+			"NN is 1-99 (default is 10)", 1, 99),
+		new IntDef('e', XMLBenchBase.class, "m_excludeCount",
+			"exclude first NN passes of each document from averages, " +
+			"where NN is 0-99 (default is 1, must be less than pass count)", 
+			0, 99),
+	};
+	
+	/** Set of parameter definitions used by all subclasses. */
+	protected static ParameterSet s_baseParameters = 
+		new ParameterSet(BASE_PARAMETERS, null);
+	
+	/** Flag for printing results with abbreviated captions. */
+	public boolean m_briefFlag;
+	
+	/** Flag for printing compressed results as comma-separated values. */
+	public boolean m_compFlag;
+	
+	/** Flag for printing detailed per-pass results. */
+	public boolean m_detailFlag;
+	
+	/** Flag for printing interpreted results (full captions). */
+	public boolean m_interpretFlag;
+	
+	/** Flag for printing summary information for each document. */
+	public boolean m_summaryFlag;
+	
+	/** Flag for printing JVM version information. */
+	public boolean m_versionFlag;
+	
+	/** Number of test passes to run on each document. */
+	public int m_passCount = 10;
+	
+	/** Number of test passes to exclude from averages. */
+	public int m_excludeCount = 1;
+	
+	/** File or directory paths for data used in tests. */
+	protected String[] m_filePaths;
+	
+	/** Sizes of document data. */
+	protected int[] m_documentSizes;
+	
+	/** Document data for tests. */
+	protected byte[][][] m_documentData;
+
+	/**
+	 * Read contents of file into byte array.
+	 *
+	 * @param file file to be read
+	 * @return array of bytes containing all data from file
+	 * @throws IOException on file access error
+	 */
+
+	private static byte[] getFileBytes(File file) throws IOException {
+		int length = (int)file.length();
+		byte[]data = new byte[length];
+		FileInputStream in = new FileInputStream(file);
+		int offset = 0;
+		do {
+			offset += in.read(data, offset, length-offset);
+		} while (offset < data.length);
+		return data;
+	}
+
+	/**
+	 * Load data for file or directory argument. If the supplied path is a
+	 * file, the returned array of arrays consists of a single byte array
+	 * containing the data from that file. If the path is a directory, the 
+	 * returned array contains one value array for each file in the
+	 * target directory, with the value arrays sorted by file name (ignoring
+	 * case).
+	 *
+	 * @param path file or directory path
+	 * @return array of arrays of bytes containing all data from file(s)
+	 * @throws IOException on file access error
+	 */
+
+	private static byte[][] getPathData(String path) throws IOException {
+		
+		// check type of path supplied
+		File file = new File(path);
+		Vector data = new Vector();
+		if (file.isDirectory()) {
+			
+			// get array of files in this directory
+			File[] files = file.listFiles();
+			byte[][] arrays = new byte[files.length][];
+			String[] names = new String[files.length];
+			int count = 0;
+			for (int i = 0; i < files.length; i++) {
+				if (files[i].isFile()) {
+					arrays[count] = getFileBytes(files[i]);
+					names[count++] = files[i].getName();
+				}
+			}
+			
+			// (bubble) sort results by file name
+			for (int i = 0; i < count; i++) {
+				for (int j = i+1; j < count; j++) {
+					if (names[j].compareToIgnoreCase(names[i]) < 0) {
+						byte[] array = arrays[j];
+						arrays[j] = arrays[i];
+						arrays[i] = array;
+						String name = names[j];
+						names[j] = names[i];
+						names[i] = name;
+					}
+				}
+//				System.out.println("  sorted " + names[i]);
+			}
+			
+			// convert results to sized array
+			byte[][] results = new byte[count][];
+			System.arraycopy(arrays, 0, results, 0, count);
+			return results;
+			
+		} else {
+			byte[][] results = new byte[1][];
+			results[0] = getFileBytes(file);
+			return results;
+		}
+	}
+
+	/**
+	 * Process test name argument. This abstract method must be overridden by
+	 * each subclass to perform appropriate processing of the test name from
+	 * the command line. The subclass can also use this method to implement
+	 * additional parameter validation, beyond what's done by the base class.
+	 *
+	 * @param name test name supplied by user
+	 * @throws ParameterErrorException on any form of parameter error
+	 */
+
+	protected abstract void handleTestName(String name);
+
+	/**
+	 * Run test sequence. This abstract method must be overridden by
+	 * each subclass to perform the actual testing and results generation
+	 */
+
+	protected abstract void runTests();
+
+	/**
+	 * Process command line arguments. The leading arguments provide optional
+	 * control information, indicated by a '-' prefix on each argument, along
+	 * with parameters required by the control flags. The argument following
+	 * this gives the specific test type, which is validated by calling an
+	 * abstract method implemented in each subclass. The remaining arguments
+	 * supply the names of files or directories of file to be used in the 
+	 * testing.
+	 *
+	 * @param argv command line arguments
+	 * @param proc argument processor information
+	 * @return <code>true</code> if command line processing successful,
+	 * <code>false</code> if error in command line arguments
+	 */
+
+	protected boolean processArgs(String[] argv, ArgumentProcessor proc) {
+		
+		// set up command line argument processor
+		boolean valid = false;
+		if (argv.length > 0) {
+			try {
+				
+				// process parameters indicated by control flags first
+				proc.processArgs(argv, this);
+				if (m_excludeCount > m_passCount) {
+					throw new ParameterErrorException
+						("Pass count must be greater than exclude count");
+				}
+
+				// next parameter should be the model name
+				StringTracker xargs = proc.getArgs();
+				if (xargs.hasNext()) {
+					
+					// create a test instance for the model
+					handleTestName(xargs.next());
+					
+					// make sure we have some test data specified
+					int fcnt = xargs.length() - xargs.nextOffset();
+					if (fcnt == 0) {
+						throw new ParameterErrorException
+							("No test data supplied - nothing to be done");
+					}
+
+					// read data from all input files into array of arrays
+					valid = true;
+					m_filePaths = new String[fcnt];
+					m_documentSizes = new int[fcnt];
+					m_documentData = new byte[fcnt][][];
+					try {
+						for (int i = 0; i < fcnt; i++) {
+							String path = xargs.next();
+							m_filePaths[i] = path;
+							byte[][] data = getPathData(path);
+							m_documentData[i] = data;
+							for (int j = 0; j < data.length; j++) {
+								m_documentSizes[i] += data[j].length;
+							}
+						}
+					} catch (IOException ex) {
+						ex.printStackTrace(System.err);
+						System.exit(0);
+					}
+					
+					// execute the tests and print results
+					runTests();
+				}
+					
+			} catch (ParameterErrorException ex) {
+				System.err.println(ex.getMessage());
+			}
+		}
+		return valid;
+	}
+
+	/**
+	 * Show test file results in brief format. This prints the results with
+	 * multiple values per line, using the abbreviated value descriptions.
+	 *
+	 * @param values test result values (unreported values ignored)
+	 * @param descripts value description texts
+	 */
+
+	protected static void showBrief(int[] values, String[] descripts) {
+		StringBuffer line = new StringBuffer(BRIEF_LINE_LENGTH);
+		int position = 0;
+		for (int j = 0; j < values.length; j++) {
+			if (values[j] != Integer.MIN_VALUE) {
+				if (position == 0) {
+					if (j > 0) {
+						System.out.println(line);
+						line.setLength(0);
+					}
+				} else {
+					int end = position*BRIEF_ITEM_WIDTH;
+					while (line.length() < end) {
+						line.append(' ');
+					}
+				}
+				line.append(' ');
+				line.append(descripts[j]);
+				line.append('=');
+				line.append(values[j]);
+				position = (position+1) % BRIEF_PER_LINE;
+			}
+		}
+		System.out.println(line);
+	}
+
+	/**
+	 * Show test file results in full format. This prints the results with
+	 * a single value per line, using the detailed value descriptions.
+	 *
+	 * @param values test result values (unreported values ignored)
+	 * @param descripts value description texts
+	 */
+
+	protected static void showFull(int[] values, String[] descripts) {
+		for (int j = 0; j < values.length; j++) {
+			if (values[j] != Integer.MIN_VALUE) {
+				System.out.println(' ' + descripts[j] + " = " + values[j]);
+			}
+		}
+	}
+
+	/**
+	 * Build text for showing results in compressed format. This uses an
+	 * abbreviated value description followed by the corresponding result
+	 * values for all test files in sequence, with comma separators.
+	 *
+	 * @param values array of test result value arrays
+	 * @param descripts value description texts
+	 * @param line buffer for output text accumulation
+	 */
+
+	protected static void buildCompressed(int[][] values, String[] descripts,
+		StringBuffer line) {
+		int fcnt = values.length;
+		int vcnt = values[0].length;
+		for (int i = 0; i < vcnt; i++) {
+			line.append(',');
+			line.append(descripts[i]);
+			for (int j = 0; j < fcnt; j++) {
+				line.append(',');
+				if (values[j][i] != Integer.MIN_VALUE) {
+					line.append(values[j][i]);
+				}
+			}
+		}
+	}
+
+	/**
+	 * Print JVM version information, if enabled. Checks if printing of the
+	 * JVM version was requested by the user, and if so outputs the information
+	 * to the supplied print stream.
+	 *
+	 * @param print stream to print version information
+	 */
+
+	protected void printJVM(PrintStream print) {
+		if (m_versionFlag) {
+			print.println("Java version " +
+				System.getProperty("java.version"));
+			String text = System.getProperty("java.vm.name");
+			if (text != null) {
+				print.println(text);
+			}
+			text = System.getProperty("java.vm.version");
+			if (text != null) {
+				print.println(text);
+			}
+			text = System.getProperty("java.vm.vendor");
+			if (text == null) {
+				text = System.getProperty("java.vendor");
+			}
+			print.println(text);
+		}
+	}
+
+	/**
+	 * Print test data. Lists the files and directories supplied as test data
+	 * to the supplied print stream, with file sizes included.
+	 *
+	 * @param print stream to print version information
+	 */
+
+	protected void printDocumentList(PrintStream print) {
+		for (int i = 0; i < m_filePaths.length; i++) {
+			if (m_documentData[i].length == 1) {
+				System.out.println(" file " + m_filePaths[i] + 
+					" (" + m_documentSizes[i] + " bytes)");
+			} else {
+				System.out.println(" directory " + m_filePaths[i] +
+					" (" + m_documentData[i].length + 
+					" files totaling " + m_documentSizes[i] + 
+					" bytes)");
+			}
+		}
+	}
+}

Added: webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/xmlbench/models/BenchAxiom.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/xmlbench/models/BenchAxiom.java?rev=390489&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/xmlbench/models/BenchAxiom.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/dennis/src/com/sosnoski/xmlbench/models/BenchAxiom.java Fri Mar 31 11:59:03 2006
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2000-2006 Sosnoski Software Solutions, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+package com.sosnoski.xmlbench.models;
+
+import java.io.*;
+import java.util.*;
+
+import org.apache.axiom.om.*;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.impl.llom.factory.OMLinkedListImplFactory;
+
+import com.sosnoski.xmlbench.DocumentSummary;
+
+/**
+ * Benchmark for measuring performance of the Axiom document representation.
+ *
+ * @author Dennis M. Sosnoski
+ */
+public class BenchAxiom extends BenchDocBase
+{
+    /** Factory instance to use for tests. */
+    private OMFactory m_factory;
+
+	/**
+	 * Constructor.
+	 *
+	 * @param clas package-qualified name of class to be used for parser
+	 */
+	public BenchAxiom() {
+		super("Axiom");
+	}
+
+	/**
+	 * Build document representation by parsing XML. This implementation creates
+	 * a StAX reader for each document, since StAX readers are not reusable.
+	 *
+	 * @param in XML document input stream
+	 * @return document representation
+	 */
+	protected Object build(InputStream in) {
+		Object doc = null;
+		try {
+            if (m_factory == null) {
+                m_factory = new OMLinkedListImplFactory();
+            }
+            StAXOMBuilder builder = new StAXOMBuilder(in);
+            doc = builder.getDocument();
+		} catch (Exception ex) {
+			ex.printStackTrace(System.out);
+			System.exit(0);
+		}
+		return doc;
+	}
+
+	/**
+	 * Walk subtree for element. This recursively walks through the document
+	 * nodes under an element, accumulating summary information.
+	 *
+	 * @param element element to be walked
+	 * @param summary document summary information
+	 */
+	protected void walkElement(OMElement element, DocumentSummary summary) {
+
+		// include attribute values in summary
+		for (Iterator iter = element.getAllAttributes(); iter.hasNext();) {
+            OMAttribute attr = (OMAttribute)iter.next();
+            summary.addAttribute(attr.getAttributeValue().length());
+        }
+
+		// loop through children
+		for (Iterator iter = element.getChildren(); iter.hasNext();) {
+
+			// handle child by type
+			OMNode child = (OMNode)iter.next();
+			int type = child.getType();
+			if (type == OMNode.TEXT_NODE) {
+				summary.addContent(((OMText)child).getText().length());
+			} else if (type == OMNode.ELEMENT_NODE) {
+				summary.addElements(1);
+				walkElement((OMElement)child, summary);
+			}
+
+		}
+	}
+
+	/**
+	 * Walk and summarize document. This method walks through the nodes
+	 * of the document, accumulating summary information.
+	 *
+	 * @param doc document representation to be walked
+	 * @param summary output document summary information
+	 */
+	protected void walk(Object doc, DocumentSummary summary) {
+		summary.addElements(1);
+		walkElement(((OMDocument)doc).getOMDocumentElement(), summary);
+	}
+
+	/**
+	 * Output a document as XML text.
+	 *
+	 * @param doc document representation to be output
+	 * @param out XML document output stream
+	 */
+	protected void output(Object doc, OutputStream out) {
+		try {
+            ((OMDocument)doc).serializeAndConsume(out);
+		} catch (Exception ex) {
+			ex.printStackTrace(System.err);
+			System.exit(0);
+		}
+	}
+
+	/**
+	 * Modify subtree for element. This recursively walks through the document
+	 * nodes under an element, performing the modifications.
+	 *
+	 * @param element element to be walked
+	 */
+	protected void modifyElement(OMElement element) {
+	}
+
+	/**
+	 * Modify a document representation. This implementation of the abstract
+	 * superclass method walks the document representation performing the
+	 * following modifications: remove all content segments which consist only
+	 * of whitespace; add an attribute "text" set to "true" to any elements
+	 * which directly contain non-whitespace text content; and replace each
+	 * non-whitespace text content segment with a "text" element which wraps
+	 * the trimmed content.
+	 *
+	 * @param doc document representation to be modified
+	 */
+
+	protected void modify(Object doc) {
+/*		modifyElement(((Document)doc).getRootElement());	*/
+	}
+
+	/**
+	 * Reset test class instance.
+	 */
+	protected void reset() {
+		m_factory = null;
+	}
+}
\ No newline at end of file