You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by ms...@apache.org on 2001/07/27 23:04:38 UTC

cvs commit: jakarta-jmeter/src/org/apache/jmeter/save/xml TagHandler.java XmlHandler.java

mstover1    01/07/27 14:04:38

  Modified:    src/org/apache/jmeter/protocol/http/config UrlConfig.java
               src/org/apache/jmeter/protocol/http/control
                        HttpTestSample.java
               src/org/apache/jmeter/protocol/http/sampler HTTPSampler.java
               src/org/apache/jmeter/samplers Entry.java
               src/org/apache/jmeter/save/handlers
                        HttpTestSampleHandler.java ThreadGroupHandler.java
               src/org/apache/jmeter/save/xml TagHandler.java
                        XmlHandler.java
  Log:
  Fixing bug with saving.  Fixing minor problem with UrlConfig elements getting polluted during test runs.
  
  Revision  Changes    Path
  1.16      +7 -2      jakarta-jmeter/src/org/apache/jmeter/protocol/http/config/UrlConfig.java
  
  Index: UrlConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/protocol/http/config/UrlConfig.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- UrlConfig.java	2001/07/26 00:34:47	1.15
  +++ UrlConfig.java	2001/07/27 21:04:38	1.16
  @@ -65,8 +65,8 @@
    *  Apache Foundation
    *
    *@author     Michael Stover
  - *@created    $Date: 2001/07/26 00:34:47 $
  - *@version    $Revision: 1.15 $
  + *@created    $Date: 2001/07/27 21:04:38 $
  + *@version    $Revision: 1.16 $
    */
   
   public class UrlConfig extends AbstractConfigElement
  @@ -132,6 +132,11 @@
   	public void setProtocol(String protocol)
   	{
   		properties.put(PROTOCOL, protocol);
  +	}
  +
  +	public void removeArguments()
  +	{
  +		properties.put(ARGUMENTS,new Arguments());
   	}
   
   	/**
  
  
  
  1.18      +3 -5      jakarta-jmeter/src/org/apache/jmeter/protocol/http/control/HttpTestSample.java
  
  Index: HttpTestSample.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/protocol/http/control/HttpTestSample.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- HttpTestSample.java	2001/07/24 12:54:17	1.17
  +++ HttpTestSample.java	2001/07/27 21:04:38	1.18
  @@ -86,7 +86,7 @@
    *  Apache Foundation
    *
    *@author     Michael Stover
  - *@created    $Date: 2001/07/24 12:54:17 $
  + *@created    $Date: 2001/07/27 21:04:38 $
    *@version    1.0
    */
   
  @@ -434,6 +434,7 @@
   		{
   			catClass.debug("Element class - " + element.getClass());
   		}
  +		entry.addConfigElement(element,UrlConfig.class);
   		// IMPORTANT : when addind new types of instance of
   		// ensure that you add those more specific classes first
   		// e.g. UrlConfigFull extends UrlConfig so the test for
  @@ -448,7 +449,6 @@
   			entry.setSamplerClass(MultipartFormSampler.class);
   
   		}
  -
   		else if (element instanceof UrlConfigFull)
   		{
   			catClass.debug(
  @@ -465,10 +465,8 @@
   			entry.setSamplerClass(HTTPSampler.class);
   
   		}
  -
  -		element.addConfigElement(defaultUrl);
   
  -		entry.addConfigElement(element);
  +		entry.addConfigElement(defaultUrl,UrlConfig.class);
   
   		for (Iterator iterB = this.getConfigElements().iterator(); iterB.hasNext(); )
   		{
  
  
  
  1.17      +4 -3      jakarta-jmeter/src/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java
  
  Index: HTTPSampler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- HTTPSampler.java	2001/07/23 19:17:39	1.16
  +++ HTTPSampler.java	2001/07/27 21:04:38	1.17
  @@ -6,7 +6,7 @@
    * companies.
    *
    * All rights reserved
  - * $Header: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java,v 1.16 2001/07/23 19:17:39 mstover1 Exp $
  + * $Header: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java,v 1.17 2001/07/27 21:04:38 mstover1 Exp $
    */
   package org.apache.jmeter.protocol.http.sampler;
   
  @@ -28,8 +28,8 @@
    *  HTTP requests, including cookies and authentication.
    *
    *@author     Michael Stover
  - *@created    $Date: 2001/07/23 19:17:39 $
  - *@version    $Revision: 1.16 $
  + *@created    $Date: 2001/07/27 21:04:38 $
  + *@version    $Revision: 1.17 $
    */
   public class HTTPSampler implements Sampler
   {
  @@ -257,6 +257,7 @@
   		URL newUrl = new URL(loc);
   		urlConfig.putProperty(UrlConfig.DOMAIN, newUrl.getHost());
   		urlConfig.putProperty(UrlConfig.PATH, newUrl.getFile());
  +		urlConfig.removeArguments();
   	}
   
   	private SampleResult sample(Entry e, boolean redirected)
  
  
  
  1.10      +12 -3     jakarta-jmeter/src/org/apache/jmeter/samplers/Entry.java
  
  Index: Entry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/samplers/Entry.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Entry.java	2001/07/26 00:34:49	1.9
  +++ Entry.java	2001/07/27 21:04:38	1.10
  @@ -62,7 +62,7 @@
    *  Apache Foundation
    *
    *@author     Michael Stover
  - *@created    $Date: 2001/07/26 00:34:49 $
  + *@created    $Date: 2001/07/27 21:04:38 $
    *@version    1.0
    ***********************************************************/
   
  @@ -120,12 +120,21 @@
   	 ***********************************************************/
   	public void addConfigElement(ConfigElement config)
   	{
  +		addConfigElement(config,config.getClass());
  +	}
  +
  +	/**
  +	 * Add a config element as a specific class.  Usually this is done to add a
  +	 * subclass as one of it's parent classes.
  +	 */
  +	public void addConfigElement(ConfigElement config,Class asClass)
  +	{
   		if (config != null)
   		{
  -			ConfigElement current = (ConfigElement)configSet.get(config.getClass());
  +			ConfigElement current = (ConfigElement)configSet.get(asClass);
   			if (current == null)
   			{
  -				configSet.put(config.getClass(), cloneIfNecessary(config));
  +				configSet.put(asClass, cloneIfNecessary(config));
   			}
   			else
   			{
  
  
  
  1.6       +175 -175  jakarta-jmeter/src/org/apache/jmeter/save/handlers/HttpTestSampleHandler.java
  
  Index: HttpTestSampleHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/save/handlers/HttpTestSampleHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- HttpTestSampleHandler.java	2001/07/26 00:34:50	1.5
  +++ HttpTestSampleHandler.java	2001/07/27 21:04:38	1.6
  @@ -1,175 +1,175 @@
  -/*
  - * ====================================================================
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - * notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - * notice, this list of conditions and the following disclaimer in
  - * the documentation and/or other materials provided with the
  - * distribution.
  - *
  - * 3. The end-user documentation included with the redistribution,
  - * if any, must include the following acknowledgment:
  - * "This product includes software developed by the
  - * Apache Software Foundation (http://www.apache.org/)."
  - * Alternately, this acknowledgment may appear in the software itself,
  - * if and wherever such third-party acknowledgments normally appear.
  - *
  - * 4. The names "Apache" and "Apache Software Foundation" and
  - * "Apache JMeter" must not be used to endorse or promote products
  - * derived from this software without prior written permission. For
  - * written permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache",
  - * "Apache JMeter", nor may "Apache" appear in their name, without
  - * prior written permission of the Apache Software Foundation.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - */
  - package org.apache.jmeter.save.handlers;
  -
  -import java.io.*;
  -import java.util.*;
  -
  -import org.apache.jmeter.control.GenericController;
  -import org.apache.jmeter.protocol.http.control.HttpTestSample;
  -import org.apache.jmeter.protocol.http.config.UrlConfig;
  -import org.apache.jmeter.save.*;
  -import org.apache.jmeter.save.xml.*;
  -
  -/**
  - *  Title: Apache JMeter Description: Copyright: Copyright (c) 2000 Company:
  - *  Apache Foundation
  - *
  - *@author     Michael Stover
  - *@created    February 18, 2001
  - *@version    1.0
  - */
  -
  -public class HttpTestSampleHandler extends GenericControllerHandler
  -{
  -
  -	/**
  -	 *  Constructor for the HttpTestSampleHandler object
  -	 */
  -	public HttpTestSampleHandler()
  -	{
  -	}
  -
  -	/**
  -	 *  Gets the PrimaryTagName attribute of the GenericControllerHandler object
  -	 *
  -	 *@return    The PrimaryTagName value
  -	 */
  -	public String getPrimaryTagName()
  -	{
  -		return "HttpTestSample";
  -	}
  -
  -	/**
  -	 *  Description of the Method
  -	 */
  -	public void defaultUrlTagEnd()
  -	{
  -		List children = xmlParent.takeChildObjects(this);
  -		if (children.size() == 1)
  -		{
  -			((HttpTestSample) controller).setDefaultUrl((UrlConfig) ((TagHandler)
  -					children.get(0)).getModel());
  -		}
  -	}
  -
  -	/**
  -	 *  Description of the Method
  -	 *
  -	 *@param  cont                     Description of Parameter
  -	 *@param  out                      Description of Parameter
  -	 *@exception  java.io.IOException  Description of Exception
  -	 */
  -	public void save(Saveable cont, Writer out) throws java.io.IOException
  -	{
  -		HttpTestSample controller = (HttpTestSample) cont;
  -		writeMainTag(out, controller);
  -		writeDefaultUrl(out, controller);
  -		writeTestUrls(out, controller);
  -		JMeterHandler.writeConfigElements(controller.getConfigElements(),out);
  -		JMeterHandler.writeControllers(controller.getSubControllers(),out);
  -		out.write("</HttpTestSample>\n");
  -	}
  -
  -	/**
  -	 *  Description of the Method
  -	 *
  -	 *@param  out                      Description of Parameter
  -	 *@param  controller               Description of Parameter
  -	 *@exception  java.io.IOException  Description of Exception
  -	 */
  -	protected void writeMainTag(Writer out, GenericController controller) throws java.io.IOException
  -	{
  -		out.write("<HttpTestSample type=\"");
  -		out.write(JMeterHandler.convertToXML(controller.getClass().getName()));
  -		out.write("\" name=\"");
  -		out.write(JMeterHandler.convertToXML(controller.getName()));
  -		out.write("\">\n");
  -	}
  -
  -	/**
  -	 *  Description of the Method
  -	 *
  -	 *@param  out                      Description of Parameter
  -	 *@param  controller               Description of Parameter
  -	 *@exception  java.io.IOException  Description of Exception
  -	 */
  -	protected void writeDefaultUrl(Writer out, HttpTestSample controller)
  -			 throws java.io.IOException
  -	{
  -		out.write("<defaultUrl>\n");
  -		JMeterHandler.writeObject(controller.getDefaultUrl(), out);
  -		out.write("</defaultUrl>\n");
  -	}
  -
  -	/**
  -	 *  Description of the Method
  -	 *
  -	 *@param  out                      Description of Parameter
  -	 *@param  controller               Description of Parameter
  -	 *@exception  java.io.IOException  Description of Exception
  -	 */
  -	protected void writeTestUrls(Writer out, HttpTestSample controller) throws java.io.IOException
  -	{
  -		out.write("<urlList>\n");
  -		Iterator iter = controller.getUrlList().iterator();
  -		while (iter.hasNext())
  -		{
  -			JMeterHandler.writeObject(iter.next(), out);
  -			out.write("\n");
  -		}
  -		out.write("</urlList>\n");
  -	}
  -}
  +/*
  + * ====================================================================
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + * notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + * notice, this list of conditions and the following disclaimer in
  + * the documentation and/or other materials provided with the
  + * distribution.
  + *
  + * 3. The end-user documentation included with the redistribution,
  + * if any, must include the following acknowledgment:
  + * "This product includes software developed by the
  + * Apache Software Foundation (http://www.apache.org/)."
  + * Alternately, this acknowledgment may appear in the software itself,
  + * if and wherever such third-party acknowledgments normally appear.
  + *
  + * 4. The names "Apache" and "Apache Software Foundation" and
  + * "Apache JMeter" must not be used to endorse or promote products
  + * derived from this software without prior written permission. For
  + * written permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache",
  + * "Apache JMeter", nor may "Apache" appear in their name, without
  + * prior written permission of the Apache Software Foundation.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + */
  + package org.apache.jmeter.save.handlers;
  +
  +import java.io.*;
  +import java.util.*;
  +
  +import org.apache.jmeter.control.GenericController;
  +import org.apache.jmeter.protocol.http.control.HttpTestSample;
  +import org.apache.jmeter.protocol.http.config.UrlConfig;
  +import org.apache.jmeter.save.*;
  +import org.apache.jmeter.save.xml.*;
  +
  +/**
  + *  Title: Apache JMeter Description: Copyright: Copyright (c) 2000 Company:
  + *  Apache Foundation
  + *
  + *@author     Michael Stover
  + *@created    February 18, 2001
  + *@version    1.0
  + */
  +
  +public class HttpTestSampleHandler extends GenericControllerHandler
  +{
  +
  +	/**
  +	 *  Constructor for the HttpTestSampleHandler object
  +	 */
  +	public HttpTestSampleHandler()
  +	{
  +	}
  +
  +	/**
  +	 *  Gets the PrimaryTagName attribute of the GenericControllerHandler object
  +	 *
  +	 *@return    The PrimaryTagName value
  +	 */
  +	public String getPrimaryTagName()
  +	{
  +		return "HttpTestSample";
  +	}
  +
  +	public void notifySubElementEnded(Object childObj)
  +	{
  +		if(this.getMethodName().endsWith("defaultUrl"))
  +		{
  +			List children = xmlParent.takeChildObjects(this);
  +			if (children.size() == 1)
  +			{
  +				((HttpTestSample) controller).setDefaultUrl((UrlConfig) ((TagHandler)
  +						children.get(0)).getModel());
  +			}
  +		}
  +	}
  +
  +	/**
  +	 *  Description of the Method
  +	 *
  +	 *@param  cont                     Description of Parameter
  +	 *@param  out                      Description of Parameter
  +	 *@exception  java.io.IOException  Description of Exception
  +	 */
  +	public void save(Saveable cont, Writer out) throws java.io.IOException
  +	{
  +		HttpTestSample controller = (HttpTestSample) cont;
  +		writeMainTag(out, controller);
  +		writeDefaultUrl(out, controller);
  +		writeTestUrls(out, controller);
  +		JMeterHandler.writeConfigElements(controller.getConfigElements(),out);
  +		JMeterHandler.writeControllers(controller.getSubControllers(),out);
  +		out.write("</HttpTestSample>\n");
  +	}
  +
  +	/**
  +	 *  Description of the Method
  +	 *
  +	 *@param  out                      Description of Parameter
  +	 *@param  controller               Description of Parameter
  +	 *@exception  java.io.IOException  Description of Exception
  +	 */
  +	protected void writeMainTag(Writer out, GenericController controller) throws java.io.IOException
  +	{
  +		out.write("<HttpTestSample type=\"");
  +		out.write(JMeterHandler.convertToXML(controller.getClass().getName()));
  +		out.write("\" name=\"");
  +		out.write(JMeterHandler.convertToXML(controller.getName()));
  +		out.write("\">\n");
  +	}
  +
  +	/**
  +	 *  Description of the Method
  +	 *
  +	 *@param  out                      Description of Parameter
  +	 *@param  controller               Description of Parameter
  +	 *@exception  java.io.IOException  Description of Exception
  +	 */
  +	protected void writeDefaultUrl(Writer out, HttpTestSample controller)
  +			 throws java.io.IOException
  +	{
  +		out.write("<defaultUrl>\n");
  +		JMeterHandler.writeObject(controller.getDefaultUrl(), out);
  +		out.write("</defaultUrl>\n");
  +	}
  +
  +	/**
  +	 *  Description of the Method
  +	 *
  +	 *@param  out                      Description of Parameter
  +	 *@param  controller               Description of Parameter
  +	 *@exception  java.io.IOException  Description of Exception
  +	 */
  +	protected void writeTestUrls(Writer out, HttpTestSample controller) throws java.io.IOException
  +	{
  +		out.write("<urlList>\n");
  +		Iterator iter = controller.getUrlList().iterator();
  +		while (iter.hasNext())
  +		{
  +			JMeterHandler.writeObject(iter.next(), out);
  +			out.write("\n");
  +		}
  +		out.write("</urlList>\n");
  +	}
  +}
  
  
  
  1.7       +135 -132  jakarta-jmeter/src/org/apache/jmeter/save/handlers/ThreadGroupHandler.java
  
  Index: ThreadGroupHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/save/handlers/ThreadGroupHandler.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ThreadGroupHandler.java	2001/07/26 00:34:50	1.6
  +++ ThreadGroupHandler.java	2001/07/27 21:04:38	1.7
  @@ -1,133 +1,136 @@
  -/*
  - * ====================================================================
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - * notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - * notice, this list of conditions and the following disclaimer in
  - * the documentation and/or other materials provided with the
  - * distribution.
  - *
  - * 3. The end-user documentation included with the redistribution,
  - * if any, must include the following acknowledgment:
  - * "This product includes software developed by the
  - * Apache Software Foundation (http://www.apache.org/)."
  - * Alternately, this acknowledgment may appear in the software itself,
  - * if and wherever such third-party acknowledgments normally appear.
  - *
  - * 4. The names "Apache" and "Apache Software Foundation" and
  - * "Apache JMeter" must not be used to endorse or promote products
  - * derived from this software without prior written permission. For
  - * written permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache",
  - * "Apache JMeter", nor may "Apache" appear in their name, without
  - * prior written permission of the Apache Software Foundation.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - */
  - package org.apache.jmeter.save.handlers;
  -
  -import org.xml.sax.Attributes;
  -import java.util.*;
  -
  -import org.apache.jmeter.threads.ThreadGroup;
  -import org.apache.jmeter.control.*;
  -import org.apache.jmeter.save.Saveable;
  -import java.io.Writer;
  -import org.apache.jmeter.save.xml.*;
  -
  -/**
  - * Title:
  - * Description:
  - * Copyright:    Copyright (c) 2001
  - * Company:
  - * @author Michael Stover
  - * @version 1.0
  - */
  -
  -public class ThreadGroupHandler extends TagHandler
  -{
  -
  -	private ThreadGroup group;
  -
  -	public ThreadGroupHandler()
  -	{
  -	}
  -
  -	public void save(Saveable s, Writer out) throws java.io.IOException
  -	{
  -		ThreadGroup save = (ThreadGroup)s;
  -		out.write("<ThreadGroup name=\"");
  -		out.write(JMeterHandler.convertToXML(save.getName()));
  -		out.write("\" numThreads=\"");
  -		out.write(""+save.getNumThreads());
  -		out.write("\">\n");
  -		Collection controllers = new LinkedList();
  -		controllers.add(save.getSamplerController());
  -		JMeterHandler.writeControllers(controllers,out);
  -		JMeterHandler.writeTimers(save.getTimers(),out);
  -		JMeterHandler.writeListeners(save.getListeners(),out);
  -		out.write("</ThreadGroup>\n");
  -	}
  -
  -	public void setAtts(Attributes atts) throws java.lang.Exception
  -	{
  -		group = new ThreadGroup();
  -		group.setName(atts.getValue("name"));
  -		try
  -		{
  -			group.setNumThreads(Integer.parseInt(atts.getValue("numThreads")));
  -		}
  -		catch (Exception ex)
  -		{
  -			ex.printStackTrace();
  -		}
  -
  -	}
  -
  -	public void ThreadGroupTagEnd()
  -	{
  -		Iterator children = xmlParent.takeChildObjects(this).iterator();
  -		if(children.hasNext())
  -		{
  -			group.setSamplerController((SamplerController)((TagHandler)children.next()).getModel());
  -		}
  -	}
  -
  -	public String getPrimaryTagName()
  -	{
  -		return "ThreadGroup";
  -	}
  -
  -	public Object getModel()
  -	{
  -		return group;
  -	}
  +/*
  + * ====================================================================
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + * notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + * notice, this list of conditions and the following disclaimer in
  + * the documentation and/or other materials provided with the
  + * distribution.
  + *
  + * 3. The end-user documentation included with the redistribution,
  + * if any, must include the following acknowledgment:
  + * "This product includes software developed by the
  + * Apache Software Foundation (http://www.apache.org/)."
  + * Alternately, this acknowledgment may appear in the software itself,
  + * if and wherever such third-party acknowledgments normally appear.
  + *
  + * 4. The names "Apache" and "Apache Software Foundation" and
  + * "Apache JMeter" must not be used to endorse or promote products
  + * derived from this software without prior written permission. For
  + * written permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache",
  + * "Apache JMeter", nor may "Apache" appear in their name, without
  + * prior written permission of the Apache Software Foundation.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + */
  + package org.apache.jmeter.save.handlers;
  +
  +import org.xml.sax.Attributes;
  +import java.util.*;
  +
  +import org.apache.jmeter.threads.ThreadGroup;
  +import org.apache.jmeter.control.*;
  +import org.apache.jmeter.save.Saveable;
  +import java.io.Writer;
  +import org.apache.jmeter.save.xml.*;
  +
  +/**
  + * Title:
  + * Description:
  + * Copyright:    Copyright (c) 2001
  + * Company:
  + * @author Michael Stover
  + * @version 1.0
  + */
  +
  +public class ThreadGroupHandler extends TagHandler
  +{
  +
  +	private ThreadGroup group;
  +
  +	public ThreadGroupHandler()
  +	{
  +	}
  +
  +	public void save(Saveable s, Writer out) throws java.io.IOException
  +	{
  +		ThreadGroup save = (ThreadGroup)s;
  +		out.write("<ThreadGroup name=\"");
  +		out.write(JMeterHandler.convertToXML(save.getName()));
  +		out.write("\" numThreads=\"");
  +		out.write(""+save.getNumThreads());
  +		out.write("\">\n");
  +		Collection controllers = new LinkedList();
  +		controllers.add(save.getSamplerController());
  +		JMeterHandler.writeControllers(controllers,out);
  +		JMeterHandler.writeTimers(save.getTimers(),out);
  +		JMeterHandler.writeListeners(save.getListeners(),out);
  +		out.write("</ThreadGroup>\n");
  +	}
  +
  +	public void setAtts(Attributes atts) throws java.lang.Exception
  +	{
  +		group = new ThreadGroup();
  +		group.setName(atts.getValue("name"));
  +		try
  +		{
  +			group.setNumThreads(Integer.parseInt(atts.getValue("numThreads")));
  +		}
  +		catch (Exception ex)
  +		{
  +			ex.printStackTrace();
  +		}
  +
  +	}
  +
  +	public void notifySubElementEnded(Object childObj)
  +	{
  +		if(childObj instanceof SamplerController)
  +		{
  +			Iterator children = xmlParent.takeChildObjects(this).iterator();
  +			if(children.hasNext())
  +			{
  +				group.setSamplerController((SamplerController)((TagHandler)children.next()).getModel());
  +			}
  +		}
  +	}
  +
  +	public String getPrimaryTagName()
  +	{
  +		return "ThreadGroup";
  +	}
  +
  +	public Object getModel()
  +	{
  +		return group;
  +	}
   }
  
  
  
  1.6       +285 -281  jakarta-jmeter/src/org/apache/jmeter/save/xml/TagHandler.java
  
  Index: TagHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/save/xml/TagHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TagHandler.java	2001/07/26 00:34:51	1.5
  +++ TagHandler.java	2001/07/27 21:04:38	1.6
  @@ -1,282 +1,286 @@
  -/*
  - * ====================================================================
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - * notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - * notice, this list of conditions and the following disclaimer in
  - * the documentation and/or other materials provided with the
  - * distribution.
  - *
  - * 3. The end-user documentation included with the redistribution,
  - * if any, must include the following acknowledgment:
  - * "This product includes software developed by the
  - * Apache Software Foundation (http://www.apache.org/)."
  - * Alternately, this acknowledgment may appear in the software itself,
  - * if and wherever such third-party acknowledgments normally appear.
  - *
  - * 4. The names "Apache" and "Apache Software Foundation" and
  - * "Apache JMeter" must not be used to endorse or promote products
  - * derived from this software without prior written permission. For
  - * written permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache",
  - * "Apache JMeter", nor may "Apache" appear in their name, without
  - * prior written permission of the Apache Software Foundation.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - */
  - package org.apache.jmeter.save.xml;
  -
  -import java.util.*;
  -import java.lang.reflect.*;
  -import java.io.*;
  -
  -import org.xml.sax.Attributes;
  -
  -import org.apache.jmeter.save.SaveHandler;
  -
  -/**
  - * Title:
  - * Description:
  - * Copyright:    Copyright (c) 2000
  - * Company:
  - * @author
  - * @version 1.0
  - */
  -
  -public abstract class TagHandler implements SaveHandler
  -{
  -	private LinkedList tagsIn = new LinkedList();
  -	private boolean done = false;
  -	protected String tagName;
  -	protected XmlHandler xmlParent;
  -
  -	private StringBuffer dataStore;
  -
  -
  -	public abstract void setAtts(Attributes atts) throws Exception;
  -
  -	public void setXmlParent(XmlHandler xml)
  -	{
  -		xmlParent = xml;
  -	}
  -
  -	public void startSave(Writer out) throws IOException
  -	{
  -		out.write("<?xml version=\"1.0\"?>\n\n");
  -	}
  -
  -	/************************************************************
  -	 *  Indicates whether this tag has been completely parsed
  -	 *
  -	 *@return    True or false whether this tag is done being parsed
  -	 ***********************************************************/
  -	public boolean isDone()
  -	{
  -		return done;
  -	}
  -
  -	protected void setDone(boolean done)
  -	{
  -		this.done = done;
  -	}
  -
  -	public void unknownTagStart(String name,Attributes atts)
  -	{
  -	}
  -
  -	public void unknownTagEnd(String name)
  -	{
  -	}
  -
  -	public void setData(String data)
  -	{
  -	}
  -
  -	public String getTagName()
  -	{
  -		return tagName;
  -	}
  -
  -	public void setTagName(String tagName)
  -	{
  -		this.tagName = tagName;
  -	}
  -
  -	public abstract Object getModel();
  -
  -	/************************************************************
  -	 *  Handles character data passed to this class
  -	 *
  -	 *@param  data  The data within the XML tag to be handled
  -	 ***********************************************************/
  -	public void handleData(String data)
  -	{
  -		this.callTagCombo(data);
  -	}
  -
  -	protected void startTag(String tag)
  -	{
  -		if(!tagName.equals(tag))
  -			tagsIn.addLast(tag);
  -	}
  -
  -	protected void endTag(String tag)
  -	{
  -		if(tagName.equals(tag))
  -		{
  -			setDone(true);
  -		}
  -		else
  -		{
  -			tagsIn.removeLast();
  -		}
  -	}
  -
  -	protected String getMethodName()
  -	{
  -		StringBuffer methodName = new StringBuffer();
  -		boolean first = true;
  -		for (Iterator it = tagsIn.iterator(); it.hasNext(); )
  -		{
  -			if (!first)
  -			{
  -				methodName.append("_");
  -			}
  -			else
  -			{
  -				first = false;
  -			}
  -			methodName.append(it.next());
  -		}
  -		return methodName.toString();
  -	}
  -
  -	protected void callTagCombo(Attributes atts)
  -	{
  -		try
  -		{
  -			Method method = this.getClass().getMethod(getMethodName(), new Class[]{Attributes.class});
  -			method.invoke(this, new Object[]{atts});
  -		}
  -		catch(NoSuchMethodException e)
  -		{
  -		}
  -		catch (Exception e)
  -		{
  -			e.printStackTrace();
  -		}
  -	}
  -
  -	protected void callTagCombo(String data)
  -	{
  -		if(dataStore == null)
  -		{
  -			dataStore = new StringBuffer();
  -		}
  -		dataStore.append(data);
  -	}
  -
  -	private void releaseData()
  -	{
  -		if(dataStore != null)
  -		{
  -			try
  -			{
  -				if(getMethodName().equals(""))
  -				{
  -					setData(dataStore.toString());
  -				}
  -				else
  -				{
  -					Method method = this.getClass().getMethod(getMethodName(), new Class[]{String.class});
  -					method.invoke(this, new Object[]{dataStore.toString()});
  -				}
  -			}
  -			catch(NoSuchMethodException e)
  -			{
  -			}
  -			catch (Exception ex)
  -			{
  -				ex.printStackTrace();
  -			}
  -		}
  -		dataStore = null;
  -	}
  -
  -	protected void passToHandler(String localName, Attributes atts)
  -	{
  -		releaseData();
  -		try
  -		{
  -			Class handler = this.getClass();
  -			startTag(localName);
  -			Method method = handler.getMethod(localName + "TagStart", new Class[]{Attributes.class});
  -			method.invoke(this, new Object[]{atts});
  -		}
  -		catch (NoSuchMethodException e)
  -		{
  -			unknownTagStart(localName,atts);
  -		}
  -		catch(InvocationTargetException e)
  -		{
  -			e.printStackTrace();
  -		}
  -		catch(IllegalAccessException e)
  -		{
  -			e.printStackTrace();
  -		}
  -		callTagCombo(atts);
  -	}
  -
  -	protected void passToHandler(String localName)
  -	{
  -		releaseData();
  -		try
  -		{
  -			Class handler = this.getClass();
  -			endTag(localName);
  -			Method method = handler.getMethod(localName + "TagEnd", new Class[0]);
  -			method.invoke(this, new Object[0]);
  -		}
  -		catch (NoSuchMethodException e)
  -		{
  -			unknownTagEnd(localName);
  -		}
  -		catch(InvocationTargetException e)
  -		{
  -			e.printStackTrace();
  -		}
  -		catch(IllegalAccessException e)
  -		{
  -			e.printStackTrace();
  -		}
  -	}
  +/*
  + * ====================================================================
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + * notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + * notice, this list of conditions and the following disclaimer in
  + * the documentation and/or other materials provided with the
  + * distribution.
  + *
  + * 3. The end-user documentation included with the redistribution,
  + * if any, must include the following acknowledgment:
  + * "This product includes software developed by the
  + * Apache Software Foundation (http://www.apache.org/)."
  + * Alternately, this acknowledgment may appear in the software itself,
  + * if and wherever such third-party acknowledgments normally appear.
  + *
  + * 4. The names "Apache" and "Apache Software Foundation" and
  + * "Apache JMeter" must not be used to endorse or promote products
  + * derived from this software without prior written permission. For
  + * written permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache",
  + * "Apache JMeter", nor may "Apache" appear in their name, without
  + * prior written permission of the Apache Software Foundation.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + */
  + package org.apache.jmeter.save.xml;
  +
  +import java.util.*;
  +import java.lang.reflect.*;
  +import java.io.*;
  +
  +import org.xml.sax.Attributes;
  +
  +import org.apache.jmeter.save.SaveHandler;
  +
  +/**
  + * Title:
  + * Description:
  + * Copyright:    Copyright (c) 2000
  + * Company:
  + * @author
  + * @version 1.0
  + */
  +
  +public abstract class TagHandler implements SaveHandler
  +{
  +	private LinkedList tagsIn = new LinkedList();
  +	private boolean done = false;
  +	protected String tagName;
  +	protected XmlHandler xmlParent;
  +
  +	private StringBuffer dataStore;
  +
  +
  +	public abstract void setAtts(Attributes atts) throws Exception;
  +
  +	public void setXmlParent(XmlHandler xml)
  +	{
  +		xmlParent = xml;
  +	}
  +
  +	public void startSave(Writer out) throws IOException
  +	{
  +		out.write("<?xml version=\"1.0\"?>\n\n");
  +	}
  +
  +	/************************************************************
  +	 *  Indicates whether this tag has been completely parsed
  +	 *
  +	 *@return    True or false whether this tag is done being parsed
  +	 ***********************************************************/
  +	public boolean isDone()
  +	{
  +		return done;
  +	}
  +
  +	protected void setDone(boolean done)
  +	{
  +		this.done = done;
  +	}
  +
  +	public void unknownTagStart(String name,Attributes atts)
  +	{
  +	}
  +
  +	public void unknownTagEnd(String name)
  +	{
  +	}
  +
  +	public void setData(String data)
  +	{
  +	}
  +
  +	public String getTagName()
  +	{
  +		return tagName;
  +	}
  +
  +	public void setTagName(String tagName)
  +	{
  +		this.tagName = tagName;
  +	}
  +
  +	public abstract Object getModel();
  +
  +	/************************************************************
  +	 *  Handles character data passed to this class
  +	 *
  +	 *@param  data  The data within the XML tag to be handled
  +	 ***********************************************************/
  +	public void handleData(String data)
  +	{
  +		this.callTagCombo(data);
  +	}
  +
  +	protected void startTag(String tag)
  +	{
  +		if(!tagName.equals(tag))
  +			tagsIn.addLast(tag);
  +	}
  +
  +	protected void endTag(String tag)
  +	{
  +		if(tagName.equals(tag))
  +		{
  +			setDone(true);
  +		}
  +		else
  +		{
  +			tagsIn.removeLast();
  +		}
  +	}
  +
  +	protected String getMethodName()
  +	{
  +		StringBuffer methodName = new StringBuffer();
  +		boolean first = true;
  +		for (Iterator it = tagsIn.iterator(); it.hasNext(); )
  +		{
  +			if (!first)
  +			{
  +				methodName.append("_");
  +			}
  +			else
  +			{
  +				first = false;
  +			}
  +			methodName.append(it.next());
  +		}
  +		return methodName.toString();
  +	}
  +
  +	protected void callTagCombo(Attributes atts)
  +	{
  +		try
  +		{
  +			Method method = this.getClass().getMethod(getMethodName(), new Class[]{Attributes.class});
  +			method.invoke(this, new Object[]{atts});
  +		}
  +		catch(NoSuchMethodException e)
  +		{
  +		}
  +		catch (Exception e)
  +		{
  +			e.printStackTrace();
  +		}
  +	}
  +
  +	protected void callTagCombo(String data)
  +	{
  +		if(dataStore == null)
  +		{
  +			dataStore = new StringBuffer();
  +		}
  +		dataStore.append(data);
  +	}
  +
  +	private void releaseData()
  +	{
  +		if(dataStore != null)
  +		{
  +			try
  +			{
  +				if(getMethodName().equals(""))
  +				{
  +					setData(dataStore.toString());
  +				}
  +				else
  +				{
  +					Method method = this.getClass().getMethod(getMethodName(), new Class[]{String.class});
  +					method.invoke(this, new Object[]{dataStore.toString()});
  +				}
  +			}
  +			catch(NoSuchMethodException e)
  +			{
  +			}
  +			catch (Exception ex)
  +			{
  +				ex.printStackTrace();
  +			}
  +		}
  +		dataStore = null;
  +	}
  +
  +	protected void passToHandler(String localName, Attributes atts)
  +	{
  +		releaseData();
  +		try
  +		{
  +			Class handler = this.getClass();
  +			startTag(localName);
  +			Method method = handler.getMethod(localName + "TagStart", new Class[]{Attributes.class});
  +			method.invoke(this, new Object[]{atts});
  +		}
  +		catch (NoSuchMethodException e)
  +		{
  +			unknownTagStart(localName,atts);
  +		}
  +		catch(InvocationTargetException e)
  +		{
  +			e.printStackTrace();
  +		}
  +		catch(IllegalAccessException e)
  +		{
  +			e.printStackTrace();
  +		}
  +		callTagCombo(atts);
  +	}
  +
  +	protected void passToHandler(String localName)
  +	{
  +		releaseData();
  +		try
  +		{
  +			Class handler = this.getClass();
  +			endTag(localName);
  +			Method method = handler.getMethod(localName + "TagEnd", new Class[0]);
  +			method.invoke(this, new Object[0]);
  +		}
  +		catch (NoSuchMethodException e)
  +		{
  +			unknownTagEnd(localName);
  +		}
  +		catch(InvocationTargetException e)
  +		{
  +			e.printStackTrace();
  +		}
  +		catch(IllegalAccessException e)
  +		{
  +			e.printStackTrace();
  +		}
  +	}
  +
  +	public void notifySubElementEnded(Object childObj)
  +	{
  +	}
   }
  
  
  
  1.7       +319 -311  jakarta-jmeter/src/org/apache/jmeter/save/xml/XmlHandler.java
  
  Index: XmlHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/save/xml/XmlHandler.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XmlHandler.java	2001/07/26 00:34:51	1.6
  +++ XmlHandler.java	2001/07/27 21:04:38	1.7
  @@ -1,311 +1,319 @@
  -/* Project: Mako
  - *  Copyright (c) Xerox Corporation 1999-2001. All rights reserved.  Xerox, The
  - *			Document Company, and the stylized X are trademarks of the Xerox
  - *			Corporation. All other products are trademarks of their respective
  - *			companies.
  - *
  - *  All rights reserved
  - * $Header: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/save/xml/XmlHandler.java,v 1.6 2001/07/26 00:34:51 mstover1 Exp $
  - */
  -package org.apache.jmeter.save.xml;
  -
  -import org.xml.sax.helpers.DefaultHandler;
  -import org.xml.sax.SAXException;
  -import org.xml.sax.Attributes;
  -import org.xml.sax.InputSource;
  -import org.xml.sax.SAXParseException;
  -import org.apache.xerces.parsers.SAXParser;
  -import java.util.*;
  -import java.lang.reflect.*;
  -
  -import org.apache.jmeter.util.*;
  -
  -/************************************************************
  - *  Title: Description: Copyright: Copyright (c) 2000 Company:
  - *
  - *@author
  - *@created    $Date: 2001/07/26 00:34:51 $
  - *@version    1.0
  - ***********************************************************/
  -
  -public class XmlHandler extends DefaultHandler
  -{
  -	protected LinkedList objectStack;
  -
  -	NameSpaceHandler informer;
  -	List finalHandlers;
  -	ListedHashTree objectHierarchy = new ListedHashTree();
  -	boolean replaced = false;
  -
  -	/************************************************************
  -	 *  !ToDo (Constructor description)
  -	 *
  -	 *@param  informer  !ToDo (Parameter description)
  -	 ***********************************************************/
  -	public XmlHandler(NameSpaceHandler informer)
  -	{
  -		this.informer = informer;
  -		objectStack = new LinkedList();
  -		finalHandlers = new LinkedList();
  -	}
  -
  -	/************************************************************
  -	 *  !ToDoo (Method description)
  -	 *
  -	 *@return    !ToDo (Return description)
  -	 ***********************************************************/
  -	public ListedHashTree getDataTree()
  -	{
  -		if (!replaced)
  -		{
  -			replaceWithModels(objectHierarchy);
  -		}
  -		replaced = true;
  -		return objectHierarchy;
  -	}
  -
  -	/************************************************************
  -	 *  HandlerBase implementation This reports an error that has occured. This
  -	 *  indicates that a rule was broken in validation, but that parsing can
  -	 *  continue.
  -	 *
  -	 *@param  e                 !ToDo (Parameter description)
  -	 *@exception  SAXException  !ToDo (Exception description)
  -	 ***********************************************************/
  -	public void fatalError(SAXParseException e) throws SAXException
  -	{
  -		System.out.println("***Parsing Fatal Error**\n" +
  -				" Line:   " + e.getLineNumber() + "\n" +
  -				" URI:    " + e.getSystemId() + "\n" +
  -				" Message: " + e.getMessage());
  -		throw new SAXException("Fatal Error encountered");
  -	}
  -
  -	/************************************************************
  -	 *  HandlerBase implementation This reports a fatal error that has occured.
  -	 *  This indicates that a rule was broken that makes continued parsing
  -	 *  impossible.
  -	 *
  -	 *@param  errs              parse error message
  -	 *@exception  SAXException  !ToDo (Exception description)
  -	 ***********************************************************/
  -	public void error(SAXParseException errs) throws SAXException
  -	{
  -		System.out.println("***Parsing Error**\n" +
  -				" Line:   " + errs.getLineNumber() + "\n" +
  -				" URI:    " + errs.getSystemId() + "\n" +
  -				" Message: " + errs.getMessage());
  -		throw new SAXException("Error encountered");
  -	}
  -
  -	/************************************************************
  -	 *  HandlerBase implementation This reports a warning that has occured; this
  -	 *  indicates that while no XML rules were broken, something appears to be
  -	 *  incorrect or missing.
  -	 *
  -	 *@param  err               parse warning message
  -	 *@exception  SAXException  !ToDo (Exception description)
  -	 ***********************************************************/
  -	public void warning(SAXParseException err) throws SAXException
  -	{
  -		System.out.println("***Parsing Warning**\n" +
  -				" Line:   " + err.getLineNumber() + "\n" +
  -				" URI:    " + err.getSystemId() + "\n" +
  -				" Message: " + err.getMessage());
  -		throw new SAXException("Warning encountered");
  -	}
  -
  -	/************************************************************
  -	 *  !ToDo (Method description)
  -	 *
  -	 *@param  chardata          !ToDo (Parameter description)
  -	 *@param  start             !ToDo (Parameter description)
  -	 *@param  end               !ToDo (Parameter description)
  -	 *@exception  SAXException  !ToDo (Exception description)
  -	 ***********************************************************/
  -	public void characters(char[] chardata, int start, int end) throws SAXException
  -	{
  -		try
  -		{
  -			getCurrentHandler().handleData(new String(chardata, start, end - start));
  -		}
  -		catch (NoCurrentHandlerException e)
  -		{
  -		}
  -	}
  -
  -	/************************************************************
  -	 *  !ToDo (Method description)
  -	 *
  -	 *@param  uri        !ToDo (Parameter description)
  -	 *@param  localName  !ToDo (Parameter description)
  -	 *@param  qName      !ToDo (Parameter description)
  -	 *@param  atts       !ToDo (Parameter description)
  -	 ***********************************************************/
  -	public void startElement(String uri, String localName, String qName, Attributes atts)
  -	{
  -		//documentElement(localName, atts);
  -		TagHandler newXmlObject = informer.getXmlObject(localName, atts);
  -		if (newXmlObject == null)
  -		{
  -			try
  -			{
  -				getCurrentHandler().passToHandler(localName, atts);
  -			}
  -			catch (Exception ex)
  -			{
  -				System.out.println("No current Handler for " + localName);
  -			}
  -		}
  -		else
  -		{
  -			newXmlObject.setXmlParent(this);
  -			objectHierarchy.add(objectStack, newXmlObject);
  -			objectStack.addLast(newXmlObject);
  -			try
  -			{
  -				getCurrentHandler().passToHandler(localName, atts);
  -			}
  -			catch (Exception ex)
  -			{
  -				System.out.println("(2)No current Handler for " + localName);
  -			}
  -		}
  -	}
  -
  -	/************************************************************
  -	 *  HandlerBase implementation
  -	 *
  -	 *@param  uri               !ToDo (Parameter description)
  -	 *@param  localName         !ToDo (Parameter description)
  -	 *@param  qName             !ToDo (Parameter description)
  -	 *@exception  SAXException  !ToDo (Exception description)
  -	 ***********************************************************/
  -	public void endElement(java.lang.String uri, java.lang.String localName,
  -			java.lang.String qName) throws SAXException
  -	{
  -		try
  -		{
  -			getCurrentHandler().passToHandler(localName);
  -		}
  -		catch (Exception ex)
  -		{
  -			//ex.printStackTrace();
  -		}
  -		if (currentHandlerIsDone())
  -		{
  -			TagHandler currentHandler = (TagHandler)objectStack.removeLast();
  -		}
  -	}
  -
  -	/************************************************************
  -	 *  !ToDo (Method description)
  -	 *
  -	 *@param  handler  !ToDo (Parameter description)
  -	 *@return          !ToDo (Return description)
  -	 ***********************************************************/
  -	public List takeChildObjects(TagHandler handler)
  -	{
  -		List stack = new LinkedList();
  -		Iterator iter = objectStack.iterator();
  -		while (iter.hasNext())
  -		{
  -			Object item = iter.next();
  -			stack.add(item);
  -			if (item.equals(handler))
  -			{
  -				break;
  -			}
  -		}
  -		ListedHashTree subTree = objectHierarchy.get(stack);
  -		if (subTree == null)
  -		{
  -			return new LinkedList();
  -		}
  -		List items = new LinkedList(subTree.list());
  -		iter = items.iterator();
  -		while (iter.hasNext())
  -		{
  -			Object item = iter.next();
  -			replaceSubItems(subTree, item);
  -			subTree.remove(item);
  -		}
  -		return items;
  -	}
  -
  -
  -	/************************************************************
  -	 *  !ToDoo (Method description)
  -	 *
  -	 *@param  tagName  !ToDo (Parameter description)
  -	 *@param  atts     !ToDo (Parameter description)
  -	 *@return          !ToDo (Return description)
  -	 ***********************************************************/
  -	protected TagHandler getXmlObject(String tagName, Attributes atts)
  -	{
  -		return informer.getXmlObject(tagName, atts);
  -	}
  -
  -	/************************************************************
  -	 *  !ToDoo (Method description)
  -	 *
  -	 *@return                                !ToDo (Return description)
  -	 *@exception  NoCurrentHandlerException  !ToDo (Exception description)
  -	 ***********************************************************/
  -	protected TagHandler getCurrentHandler() throws NoCurrentHandlerException
  -	{
  -		if (objectStack.size() == 0)
  -		{
  -			throw new NoCurrentHandlerException();
  -		}
  -		else
  -		{
  -			return (TagHandler)objectStack.getLast();
  -		}
  -	}
  -
  -	private void replaceWithModels(ListedHashTree tree)
  -	{
  -		Iterator iter = new LinkedList(tree.list()).iterator();
  -		while (iter.hasNext())
  -		{
  -			TagHandler item = (TagHandler)iter.next();
  -			tree.set(item.getModel(), tree.get(item));
  -			tree.remove(item);
  -			replaceWithModels(tree.get(item.getModel()));
  -		}
  -	}
  -
  -	private boolean currentHandlerIsDone()
  -	{
  -		try
  -		{
  -			return getCurrentHandler().isDone();
  -		}
  -		catch (NoCurrentHandlerException e)
  -		{
  -			return false;
  -		}
  -	}
  -
  -	private void documentElement(String name, Attributes atts)
  -	{
  -		System.out.println("startElement= " + name);
  -		for (int i = 0; i < atts.getLength(); i++)
  -		{
  -			System.out.println(" Attribute= " + atts.getLocalName(i) + "=" + atts.getValue(i));
  -		}
  -	}
  -
  -	private void replaceSubItems(ListedHashTree subTree, Object item)
  -	{
  -		ListedHashTree subSubTree = subTree.get(item);
  -		List subItems = subSubTree.list();
  -		Iterator iter2 = subItems.iterator();
  -		while (iter2.hasNext())
  -		{
  -			Object subItem = iter2.next();
  -			subTree.set(subItem, subSubTree.get(subItem));
  -		}
  -	}
  -}
  +/* Project: Mako
  + *  Copyright (c) Xerox Corporation 1999-2001. All rights reserved.  Xerox, The
  + *			Document Company, and the stylized X are trademarks of the Xerox
  + *			Corporation. All other products are trademarks of their respective
  + *			companies.
  + *
  + *  All rights reserved
  + * $Header: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/save/xml/XmlHandler.java,v 1.7 2001/07/27 21:04:38 mstover1 Exp $
  + */
  +package org.apache.jmeter.save.xml;
  +
  +import org.xml.sax.helpers.DefaultHandler;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.Attributes;
  +import org.xml.sax.InputSource;
  +import org.xml.sax.SAXParseException;
  +import org.apache.xerces.parsers.SAXParser;
  +import java.util.*;
  +import java.lang.reflect.*;
  +
  +import org.apache.jmeter.util.*;
  +
  +/************************************************************
  + *  Title: Description: Copyright: Copyright (c) 2000 Company:
  + *
  + *@author
  + *@created    $Date: 2001/07/27 21:04:38 $
  + *@version    1.0
  + ***********************************************************/
  +
  +public class XmlHandler extends DefaultHandler
  +{
  +	protected LinkedList objectStack;
  +
  +	NameSpaceHandler informer;
  +	List finalHandlers;
  +	ListedHashTree objectHierarchy = new ListedHashTree();
  +	boolean replaced = false;
  +
  +	/************************************************************
  +	 *  !ToDo (Constructor description)
  +	 *
  +	 *@param  informer  !ToDo (Parameter description)
  +	 ***********************************************************/
  +	public XmlHandler(NameSpaceHandler informer)
  +	{
  +		this.informer = informer;
  +		objectStack = new LinkedList();
  +		finalHandlers = new LinkedList();
  +	}
  +
  +	/************************************************************
  +	 *  !ToDoo (Method description)
  +	 *
  +	 *@return    !ToDo (Return description)
  +	 ***********************************************************/
  +	public ListedHashTree getDataTree()
  +	{
  +		if (!replaced)
  +		{
  +			replaceWithModels(objectHierarchy);
  +		}
  +		replaced = true;
  +		return objectHierarchy;
  +	}
  +
  +	/************************************************************
  +	 *  HandlerBase implementation This reports an error that has occured. This
  +	 *  indicates that a rule was broken in validation, but that parsing can
  +	 *  continue.
  +	 *
  +	 *@param  e                 !ToDo (Parameter description)
  +	 *@exception  SAXException  !ToDo (Exception description)
  +	 ***********************************************************/
  +	public void fatalError(SAXParseException e) throws SAXException
  +	{
  +		System.out.println("***Parsing Fatal Error**\n" +
  +				" Line:   " + e.getLineNumber() + "\n" +
  +				" URI:    " + e.getSystemId() + "\n" +
  +				" Message: " + e.getMessage());
  +		throw new SAXException("Fatal Error encountered");
  +	}
  +
  +	/************************************************************
  +	 *  HandlerBase implementation This reports a fatal error that has occured.
  +	 *  This indicates that a rule was broken that makes continued parsing
  +	 *  impossible.
  +	 *
  +	 *@param  errs              parse error message
  +	 *@exception  SAXException  !ToDo (Exception description)
  +	 ***********************************************************/
  +	public void error(SAXParseException errs) throws SAXException
  +	{
  +		System.out.println("***Parsing Error**\n" +
  +				" Line:   " + errs.getLineNumber() + "\n" +
  +				" URI:    " + errs.getSystemId() + "\n" +
  +				" Message: " + errs.getMessage());
  +		throw new SAXException("Error encountered");
  +	}
  +
  +	/************************************************************
  +	 *  HandlerBase implementation This reports a warning that has occured; this
  +	 *  indicates that while no XML rules were broken, something appears to be
  +	 *  incorrect or missing.
  +	 *
  +	 *@param  err               parse warning message
  +	 *@exception  SAXException  !ToDo (Exception description)
  +	 ***********************************************************/
  +	public void warning(SAXParseException err) throws SAXException
  +	{
  +		System.out.println("***Parsing Warning**\n" +
  +				" Line:   " + err.getLineNumber() + "\n" +
  +				" URI:    " + err.getSystemId() + "\n" +
  +				" Message: " + err.getMessage());
  +		throw new SAXException("Warning encountered");
  +	}
  +
  +	/************************************************************
  +	 *  !ToDo (Method description)
  +	 *
  +	 *@param  chardata          !ToDo (Parameter description)
  +	 *@param  start             !ToDo (Parameter description)
  +	 *@param  end               !ToDo (Parameter description)
  +	 *@exception  SAXException  !ToDo (Exception description)
  +	 ***********************************************************/
  +	public void characters(char[] chardata, int start, int end) throws SAXException
  +	{
  +		try
  +		{
  +			getCurrentHandler().handleData(new String(chardata, start, end - start));
  +		}
  +		catch (NoCurrentHandlerException e)
  +		{
  +		}
  +	}
  +
  +	/************************************************************
  +	 *  !ToDo (Method description)
  +	 *
  +	 *@param  uri        !ToDo (Parameter description)
  +	 *@param  localName  !ToDo (Parameter description)
  +	 *@param  qName      !ToDo (Parameter description)
  +	 *@param  atts       !ToDo (Parameter description)
  +	 ***********************************************************/
  +	public void startElement(String uri, String localName, String qName, Attributes atts)
  +	{
  +		//documentElement(localName, atts);
  +		TagHandler newXmlObject = informer.getXmlObject(localName, atts);
  +		if (newXmlObject == null)
  +		{
  +			try
  +			{
  +				getCurrentHandler().passToHandler(localName, atts);
  +			}
  +			catch (Exception ex)
  +			{
  +				System.out.println("No current Handler for " + localName);
  +			}
  +		}
  +		else
  +		{
  +			newXmlObject.setXmlParent(this);
  +			objectHierarchy.add(objectStack, newXmlObject);
  +			objectStack.addLast(newXmlObject);
  +			try
  +			{
  +				getCurrentHandler().passToHandler(localName, atts);
  +			}
  +			catch (Exception ex)
  +			{
  +				System.out.println("(2)No current Handler for " + localName);
  +			}
  +		}
  +	}
  +
  +	/************************************************************
  +	 *  HandlerBase implementation
  +	 *
  +	 *@param  uri               !ToDo (Parameter description)
  +	 *@param  localName         !ToDo (Parameter description)
  +	 *@param  qName             !ToDo (Parameter description)
  +	 *@exception  SAXException  !ToDo (Exception description)
  +	 ***********************************************************/
  +	public void endElement(java.lang.String uri, java.lang.String localName,
  +			java.lang.String qName) throws SAXException
  +	{
  +		try
  +		{
  +			getCurrentHandler().passToHandler(localName);
  +		}
  +		catch (Exception ex)
  +		{
  +			//ex.printStackTrace();
  +		}
  +		if (currentHandlerIsDone())
  +		{
  +			TagHandler currentHandler = (TagHandler)objectStack.removeLast();
  +			try
  +			{
  +				TagHandler previousHandler = (TagHandler)objectStack.getLast();
  +				previousHandler.notifySubElementEnded(currentHandler.getModel());
  +			}
  +			catch(Exception e)
  +			{
  +			}
  +		}
  +	}
  +
  +	/************************************************************
  +	 *  !ToDo (Method description)
  +	 *
  +	 *@param  handler  !ToDo (Parameter description)
  +	 *@return          !ToDo (Return description)
  +	 ***********************************************************/
  +	public List takeChildObjects(TagHandler handler)
  +	{
  +		List stack = new LinkedList();
  +		Iterator iter = objectStack.iterator();
  +		while (iter.hasNext())
  +		{
  +			Object item = iter.next();
  +			stack.add(item);
  +			if (item.equals(handler))
  +			{
  +				break;
  +			}
  +		}
  +		ListedHashTree subTree = objectHierarchy.get(stack);
  +		if (subTree == null)
  +		{
  +			return new LinkedList();
  +		}
  +		List items = new LinkedList(subTree.list());
  +		iter = items.iterator();
  +		while (iter.hasNext())
  +		{
  +			Object item = iter.next();
  +			replaceSubItems(subTree, item);
  +			subTree.remove(item);
  +		}
  +		return items;
  +	}
  +
  +
  +	/************************************************************
  +	 *  !ToDoo (Method description)
  +	 *
  +	 *@param  tagName  !ToDo (Parameter description)
  +	 *@param  atts     !ToDo (Parameter description)
  +	 *@return          !ToDo (Return description)
  +	 ***********************************************************/
  +	protected TagHandler getXmlObject(String tagName, Attributes atts)
  +	{
  +		return informer.getXmlObject(tagName, atts);
  +	}
  +
  +	/************************************************************
  +	 *  !ToDoo (Method description)
  +	 *
  +	 *@return                                !ToDo (Return description)
  +	 *@exception  NoCurrentHandlerException  !ToDo (Exception description)
  +	 ***********************************************************/
  +	protected TagHandler getCurrentHandler() throws NoCurrentHandlerException
  +	{
  +		if (objectStack.size() == 0)
  +		{
  +			throw new NoCurrentHandlerException();
  +		}
  +		else
  +		{
  +			return (TagHandler)objectStack.getLast();
  +		}
  +	}
  +
  +	private void replaceWithModels(ListedHashTree tree)
  +	{
  +		Iterator iter = new LinkedList(tree.list()).iterator();
  +		while (iter.hasNext())
  +		{
  +			TagHandler item = (TagHandler)iter.next();
  +			tree.set(item.getModel(), tree.get(item));
  +			tree.remove(item);
  +			replaceWithModels(tree.get(item.getModel()));
  +		}
  +	}
  +
  +	private boolean currentHandlerIsDone()
  +	{
  +		try
  +		{
  +			return getCurrentHandler().isDone();
  +		}
  +		catch (NoCurrentHandlerException e)
  +		{
  +			return false;
  +		}
  +	}
  +
  +	private void documentElement(String name, Attributes atts)
  +	{
  +		System.out.println("startElement= " + name);
  +		for (int i = 0; i < atts.getLength(); i++)
  +		{
  +			System.out.println(" Attribute= " + atts.getLocalName(i) + "=" + atts.getValue(i));
  +		}
  +	}
  +
  +	private void replaceSubItems(ListedHashTree subTree, Object item)
  +	{
  +		ListedHashTree subSubTree = subTree.get(item);
  +		List subItems = subSubTree.list();
  +		Iterator iter2 = subItems.iterator();
  +		while (iter2.hasNext())
  +		{
  +			Object subItem = iter2.next();
  +			subTree.set(subItem, subSubTree.get(subItem));
  +		}
  +	}
  +}
  
  
  

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