/*
 * Created on Jun 19, 2004
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package org.apache.jmeter.save;

import org.apache.jorphan.collections.HashTree;

import com.thoughtworks.xstream.alias.ClassMapper;
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;

/**
 * @author mstover
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
class ScriptWrapperConverter implements Converter
{
   ClassMapper classMapper;
   
   ScriptWrapperConverter(ClassMapper classMapper)
   {
      this.classMapper = classMapper;
   }

   /* (non-Javadoc)
    * @see com.thoughtworks.xstream.converters.Converter#canConvert(java.lang.Class)
    */
   public boolean canConvert(Class arg0)
   {
      return arg0.equals(ScriptWrapper.class);
   }

   /* (non-Javadoc)
    * @see com.thoughtworks.xstream.converters.Converter#marshal(java.lang.Object, com.thoughtworks.xstream.io.HierarchicalStreamWriter, com.thoughtworks.xstream.converters.MarshallingContext)
    */
   public void marshal(Object arg0, HierarchicalStreamWriter writer,
         MarshallingContext context)
   {
      ScriptWrapper wrap = (ScriptWrapper)arg0;
      writer.addAttribute("version",wrap.version);
      writer.startNode(classMapper.lookupName(wrap.testPlan.getClass()));
      context.convertAnother(wrap.testPlan);
      writer.endNode();
   }

   /* (non-Javadoc)
    * @see com.thoughtworks.xstream.converters.Converter#unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader, com.thoughtworks.xstream.converters.UnmarshallingContext)
    */
   public Object unmarshal(HierarchicalStreamReader reader,
         UnmarshallingContext context)
   {
      ScriptWrapper wrap = new ScriptWrapper();
      wrap.version = reader.getAttribute("version");
      reader.moveDown();
      wrap.testPlan = (HashTree)context.convertAnother(wrap,getNextType(reader));
      return wrap;
   }

   protected Class getNextType(HierarchicalStreamReader reader)
   {
      String classAttribute = reader.getAttribute("class");
      Class type;
      if (classAttribute == null) {
          type = classMapper.lookupType(reader.getNodeName());
      } else {
          type = classMapper.lookupType(classAttribute);
      }
      return type;
   }
}

@@ -4,162 +4,617 @@
  * C
-reated on Jun 19, 2004%0A *%0A * To change the template for this generated file go to%0A * Window - Preferences - Java - Code Generation - Code and Comments%0A */
+opyright 2004 The Apache Software Foundation.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *   http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A * %0A*/%0A
 %0Apac
@@ -1263,16 +1263,163 @@
 erter%0A%7B%0A
+    /** Returns the converter version; used to check for possible incompatibilities */%0A%09public static String getVersion()%7B%09return %22$Revision$%22;%7D%0A%09%0A
    Class
@@ -2168,22 +2168,100 @@
 ersion%22,
-wrap.v
+SaveService.version);%0A      writer.addAttribute(%22properties%22,SaveService.propertiesV
 ersion);

Add ASFL V2; added properties version to script header