View | Details | Raw Unified | Return to bug 55617
Collapse All | Expand All

(-)a/src/jorphan/org/apache/jorphan/collections/HashTree.java (-49 / +9 lines)
Lines 25-30 import java.io.Serializable; Link Here
25
import java.util.Arrays;
25
import java.util.Arrays;
26
import java.util.Collection;
26
import java.util.Collection;
27
import java.util.HashMap;
27
import java.util.HashMap;
28
import java.util.HashSet;
28
import java.util.Iterator;
29
import java.util.Iterator;
29
import java.util.Map;
30
import java.util.Map;
30
import java.util.Set;
31
import java.util.Set;
Lines 51-58 public class HashTree implements Serializable, Map<Object, HashTree>, Cloneable Link Here
51
52
52
    private static final long serialVersionUID = 240L;
53
    private static final long serialVersionUID = 240L;
53
54
54
//    private static final Logger log = LoggingManager.getLoggerForClass();
55
    
56
    // Used for the RuntimeException to short-circuit the traversal
55
    // Used for the RuntimeException to short-circuit the traversal
57
    private static final String FOUND = "found"; // $NON-NLS-1$
56
    private static final String FOUND = "found"; // $NON-NLS-1$
58
57
Lines 185-192 public class HashTree implements Serializable, Map<Object, HashTree>, Cloneable Link Here
185
     *            sub tree to add to the node created for the first argument.
184
     *            sub tree to add to the node created for the first argument.
186
     */
185
     */
187
    public void add(Object key, HashTree subTree) {
186
    public void add(Object key, HashTree subTree) {
188
        add(key);
187
        add(key).add(subTree);
189
        getTree(key).add(subTree);
190
    }
188
    }
191
189
192
    /**
190
    /**
Lines 197-204 public class HashTree implements Serializable, Map<Object, HashTree>, Cloneable Link Here
197
     */
195
     */
198
    public void add(HashTree newTree) {
196
    public void add(HashTree newTree) {
199
        for (Object item : newTree.list()) {
197
        for (Object item : newTree.list()) {
200
            add(item);
198
            add(item).add(newTree.getTree(item));
201
            getTree(item).add(newTree.getTree(item));
202
        }
199
        }
203
    }
200
    }
204
201
Lines 448-455 public class HashTree implements Serializable, Map<Object, HashTree>, Cloneable Link Here
448
     *            value to be added as a key in the secondary node
445
     *            value to be added as a key in the secondary node
449
     */
446
     */
450
    public HashTree add(Object key, Object value) {
447
    public HashTree add(Object key, Object value) {
451
        add(key);
448
        return add(key).add(value);
452
        return getTree(key).add(value);
453
    }
449
    }
454
450
455
    /**
451
    /**
Lines 463-470 public class HashTree implements Serializable, Map<Object, HashTree>, Cloneable Link Here
463
     *            array of objects to be added as keys in the secondary node
459
     *            array of objects to be added as keys in the secondary node
464
     */
460
     */
465
    public void add(Object key, Object[] values) {
461
    public void add(Object key, Object[] values) {
466
        add(key);
462
        add(key).add(values);
467
        getTree(key).add(values);
468
    }
463
    }
469
464
470
    /**
465
    /**
Lines 478-485 public class HashTree implements Serializable, Map<Object, HashTree>, Cloneable Link Here
478
     *            node
473
     *            node
479
     */
474
     */
480
    public void add(Object key, Collection<?> values) {
475
    public void add(Object key, Collection<?> values) {
481
        add(key);
476
        add(key).add(values);
482
        getTree(key).add(values);
483
    }
477
    }
484
478
485
    /**
479
    /**
Lines 576-583 public class HashTree implements Serializable, Map<Object, HashTree>, Cloneable Link Here
576
    protected HashTree addTreePath(Collection<?> treePath) {
570
    protected HashTree addTreePath(Collection<?> treePath) {
577
        HashTree tree = this;
571
        HashTree tree = this;
578
        for (Object temp : treePath) {
572
        for (Object temp : treePath) {
579
            tree.add(temp);
573
            tree = tree.add(temp);
580
            tree = tree.getTree(temp);
581
        }
574
        }
582
        return tree;
575
        return tree;
583
    }
576
    }
Lines 716-722 public class HashTree implements Serializable, Map<Object, HashTree>, Cloneable Link Here
716
        if (temp != null) {
709
        if (temp != null) {
717
            return temp.list();
710
            return temp.list();
718
        }
711
        }
719
        return new HashTree().list();
712
        return new HashSet<Object>();
720
    }
713
    }
721
714
722
    /**
715
    /**
Lines 763-769 public class HashTree implements Serializable, Map<Object, HashTree>, Cloneable Link Here
763
        if (tree != null) {
756
        if (tree != null) {
764
            return tree.list();
757
            return tree.list();
765
        }
758
        }
766
        return new HashTree().list();
759
        return new HashSet<Object>();
767
    }
760
    }
768
761
769
    /**
762
    /**
Lines 881-919 public class HashTree implements Serializable, Map<Object, HashTree>, Cloneable Link Here
881
            return false;
874
            return false;
882
        }
875
        }
883
        return data.equals(oo.data);
876
        return data.equals(oo.data);
884
885
        // boolean flag = true;
886
        // if (o instanceof HashTree)
887
        // {
888
        // HashTree oo = (HashTree) o;
889
        // Iterator it = data.keySet().iterator();
890
        // while (it.hasNext())
891
        // {
892
        // if (!oo.containsKey(it.next()))
893
        // {
894
        // flag = false;
895
        // break;
896
        // }
897
        // }
898
        // if (flag)
899
        // {
900
        // it = data.keySet().iterator();
901
        // while (it.hasNext())
902
        // {
903
        // Object temp = it.next();
904
        // flag = get(temp).equals(oo.get(temp));
905
        // if (!flag)
906
        // {
907
        // break;
908
        // }
909
        // }
910
        // }
911
        // }
912
        // else
913
        // {
914
        // flag = false;
915
        // }
916
        // return flag;
917
    }
877
    }
918
878
919
    /**
879
    /**
(-)a/src/jorphan/org/apache/jorphan/collections/ListedHashTree.java (-46 lines)
Lines 25-31 import java.io.Serializable; Link Here
25
import java.util.Collection;
25
import java.util.Collection;
26
import java.util.LinkedList;
26
import java.util.LinkedList;
27
import java.util.List;
27
import java.util.List;
28
import java.util.Set;
29
28
30
import org.apache.jorphan.util.JMeterError;
29
import org.apache.jorphan.util.JMeterError;
31
30
Lines 206-257 public class ListedHashTree extends HashTree implements Serializable, Cloneable Link Here
206
        }
205
        }
207
        ListedHashTree lht = (ListedHashTree) o;
206
        ListedHashTree lht = (ListedHashTree) o;
208
        return (super.equals(lht) && order.equals(lht.order));
207
        return (super.equals(lht) && order.equals(lht.order));
209
210
        // boolean flag = true;
211
        // if (o instanceof ListedHashTree)
212
        // {
213
        // ListedHashTree oo = (ListedHashTree) o;
214
        // Iterator it = order.iterator();
215
        // Iterator it2 = oo.order.iterator();
216
        // if (size() != oo.size())
217
        // {
218
        // flag = false;
219
        // }
220
        // while (it.hasNext() && it2.hasNext() && flag)
221
        // {
222
        // if (!it.next().equals(it2.next()))
223
        // {
224
        // flag = false;
225
        // }
226
        // }
227
        // if (flag)
228
        // {
229
        // it = order.iterator();
230
        // while (it.hasNext() && flag)
231
        // {
232
        // Object temp = it.next();
233
        // flag = get(temp).equals(oo.get(temp));
234
        // }
235
        // }
236
        // }
237
        // else
238
        // {
239
        // flag = false;
240
        // }
241
        // return flag;
242
    }
243
244
    /** {@inheritDoc} */
245
    @Override
246
    public Set<Object> keySet() {
247
        return data.keySet();
248
    }
208
    }
249
209
250
    /** {@inheritDoc} */
251
    @Override
252
    public int size() {
253
        return data.size();
254
    }
255
210
256
    private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
211
    private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
257
        ois.defaultReadObject();
212
        ois.defaultReadObject();
258
- 

Return to bug 55617