01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18:
19: package org.apache.jmeter.save.converters;
20:
21: import org.apache.jmeter.samplers.SampleEvent;
22:
23: import com.thoughtworks.xstream.converters.Converter;
24: import com.thoughtworks.xstream.converters.MarshallingContext;
25: import com.thoughtworks.xstream.converters.UnmarshallingContext;
26: import com.thoughtworks.xstream.io.HierarchicalStreamReader;
27: import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
28:
29: /**
30: * XStream Converter for the SampleResult class
31: */
32: public class SampleEventConverter implements Converter {
33: /**
34: * Returns the converter version; used to check for possible
35: * incompatibilities
36: */
37: public static String getVersion() {
38: return "$Revision: 594390 $"; //$NON-NLS-1$
39: }
40:
41: /*
42: * (non-Javadoc)
43: *
44: * @see com.thoughtworks.xstream.converters.Converter#canConvert(java.lang.Class)
45: */
46: public boolean canConvert(Class arg0) {
47: return SampleEvent.class.equals(arg0);
48: }
49:
50: // TODO save hostname; save sample type (plain or http)
51: public void marshal(Object source, HierarchicalStreamWriter writer,
52: MarshallingContext context) {
53: SampleEvent evt = (SampleEvent) source;
54: Object res = evt.getResult();
55: context.convertAnother(res);
56: }
57:
58: // TODO does not work yet; need to determine the sample type
59: public Object unmarshal(HierarchicalStreamReader reader,
60: UnmarshallingContext context) {
61: SampleEvent evt = new SampleEvent();
62: return evt;
63: }
64: }
|