1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.millscript.millscript.datatypes;
22
23
24 import java.io.Serializable;
25 import java.util.Comparator;
26 import java.util.Map;
27 import java.util.SortedMap;
28 import java.util.TreeMap;
29
30 /**
31 * This interface provides a version of the usual <code>TreeMap</code> that
32 * includes a notion of a default which can be exploited by the MillScript
33 * index operator. Because the default compareTo's can throw
34 * ClassCastExceptions we must take over the Comparator.
35 *
36 * @deprecated As of MillScript 10.2.0, this functionallity has been subsumed
37 * by the MillScript-Util project and it's Map API, see
38 * {@link org.millscript.commons.util.map.EBinaryTreeMap}.
39 * @see org.millscript.millscript.datatypes.GeneralComparator
40 */
41 @Deprecated
42 public class TreeMapWithDefault extends TreeMap< Object, Object > implements MapWithDefault< Object, Object >, Serializable {
43
44 /**
45 * This is the ID from the release 10.0.0 for future compatibility.
46 */
47 private static final long serialVersionUID = 1909162462951110403L;
48
49 /**
50 * The general comparator we will use for our tree map's with default
51 * values, to avoid unnecessary ClassCastExceptions.
52 */
53 private static GeneralComparator gc = new GeneralComparator();
54
55 /**
56 * This hash map's default value.
57 */
58 private Object def = null;
59
60 /**
61 * @see org.millscript.millscript.datatypes.MapWithDefault#getDefault()
62 */
63 public Object getDefault() {
64 return def;
65 }
66
67 /**
68 * @see org.millscript.millscript.datatypes.MapWithDefault#setDefault(java.lang.Object)
69 */
70 public void setDefault( final Object d ) {
71 def = d;
72 }
73
74 /**
75 * Constructs a new empty tree map with default, sorted using our default
76 * comparator.
77 */
78 public TreeMapWithDefault() {
79 super( gc );
80 }
81
82 /**
83 * Constructs a new tree map with default, containing all the mappings in
84 * the specified map, sorted using our default comparator.
85 *
86 * @param m the map to copy into this map
87 */
88 public TreeMapWithDefault( final SortedMap< ?, ? > m ) {
89 super( gc );
90 putAll( m );
91 }
92
93 /**
94 * Constructs a new empty tree map with default, sorted according to the
95 * specified comparator.
96 *
97 * @param c the compartor to use for sorting this map
98 */
99 public TreeMapWithDefault( final Comparator< Object > c ) {
100 super( c );
101 }
102
103 /**
104 * Constructs a new tree map with default, containing all the mappings in
105 * the specified map, sorted using our default comparator.
106 *
107 * @param m the map to copy into this map
108 */
109 public TreeMapWithDefault( final Map< ?, ? > m ) {
110 super( gc );
111 putAll( m );
112 }
113
114 }