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.engine;
20:
21: import java.util.LinkedList;
22:
23: import org.apache.jmeter.engine.util.NoThreadClone;
24: import org.apache.jmeter.testelement.TestElement;
25: import org.apache.jorphan.collections.HashTree;
26: import org.apache.jorphan.collections.HashTreeTraverser;
27: import org.apache.jorphan.collections.ListedHashTree;
28:
29: public class TreeCloner implements HashTreeTraverser {
30:
31: private ListedHashTree newTree;
32:
33: private LinkedList objects = new LinkedList();
34:
35: private boolean forThread = true;
36:
37: public TreeCloner() {
38: this (true);
39: }
40:
41: public TreeCloner(boolean forThread) {
42: newTree = new ListedHashTree();
43: this .forThread = forThread;
44: }
45:
46: public void addNode(Object node, HashTree subTree) {
47: if ((!forThread || !(node instanceof NoThreadClone))
48: && (node instanceof TestElement)) {
49: node = ((TestElement) node).clone();
50: newTree.add(objects, node);
51: } else {
52: newTree.add(objects, node);
53: }
54: objects.addLast(node);
55: }
56:
57: public void subtractNode() {
58: objects.removeLast();
59: }
60:
61: public ListedHashTree getClonedTree() {
62: return newTree;
63: }
64:
65: public void processPath() {
66: }
67:
68: }
|