KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jofti > btree > MinLeafNodeEntry


1 /*
2  * NodeEntry.java
3  *
4  * Created on 25 May 2003, 09:36
5  */

6
7 package com.jofti.btree;
8
9
10 /**
11  *
12  * This is a special object in the tree and is used to represent an absolute minimum leaf entry for the whole tree. <br>
13  * Class cast issues are taken care of in the Value Object class .<p>
14  *
15  * @author Steve Woodcock
16  * @version 1.3<br>
17  */

18 final class MinLeafNodeEntry extends LeafNodeEntry {
19     
20     /**
21      *
22      */

23     private static final long serialVersionUID = -4155706530136083168L;
24     private final Comparable JavaDoc value = new ValueObject(Integer.MIN_VALUE,ValueObject.MIN_COMAPARBLE_VALUE);
25   
26     public MinLeafNodeEntry(){
27         
28     }
29     
30     public Comparable JavaDoc getValue() {
31         return value;
32     }
33     
34     /** Setter for property value.
35      * @param value New value of property value.
36      *
37      */

38     
39     public void setValue(Comparable JavaDoc value) {
40         //not supported
41
}
42     
43     public String JavaDoc toString(){
44         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
45         buf.append("value:"+value);
46         buf.append(",");
47
48         
49         return buf.toString();
50     }
51     
52     /** Compares this object with the specified object for order. Returns a
53      * negative integer, zero, or a positive integer as this object is less
54      * than, equal to, or greater than the specified object.<p>
55      *
56      * In the foregoing description, the notation
57      * <tt>sgn(</tt><i>expression</i><tt>)</tt> designates the mathematical
58      * <i>signum</i> function, which is defined to return one of <tt>-1</tt>,
59      * <tt>0</tt>, or <tt>1</tt> according to whether the value of <i>expression</i>
60      * is negative, zero or positive.
61      *
62      * The implementor must ensure <tt>sgn(x.compareTo(y)) ==
63      * -sgn(y.compareTo(x))</tt> for all <tt>x</tt> and <tt>y</tt>. (This
64      * implies that <tt>x.compareTo(y)</tt> must throw an exception iff
65      * <tt>y.compareTo(x)</tt> throws an exception.)<p>
66      *
67      * The implementor must also ensure that the relation is transitive:
68      * <tt>(x.compareTo(y)&gt;0 &amp;&amp; y.compareTo(z)&gt;0)</tt> implies
69      * <tt>x.compareTo(z)&gt;0</tt>.<p>
70      *
71      * Finally, the implementer must ensure that <tt>x.compareTo(y)==0</tt>
72      * implies that <tt>sgn(x.compareTo(z)) == sgn(y.compareTo(z))</tt>, for
73      * all <tt>z</tt>.<p>
74      *
75      * It is strongly recommended, but <i>not</i> strictly required that
76      * <tt>(x.compareTo(y)==0) == (x.equals(y))</tt>. Generally speaking, any
77      * class that implements the <tt>Comparable</tt> interface and violates
78      * this condition should clearly indicate this fact. The recommended
79      * language is "Note: this class has a natural ordering that is
80      * inconsistent with equals."
81      *
82      * @param o the Object to be compared.
83      * @return a negative integer, zero, or a positive integer as this object
84      * is less than, equal to, or greater than the specified object.
85      *
86      * @throws ClassCastException if the specified object's type prevents it
87      * from being compared to this Object.
88      *
89      */

90     public int compareTo(Object JavaDoc o) {
91         if (o instanceof MinLeafNodeEntry) {
92             return 0;
93         }
94         return -1;
95     }
96     
97     public boolean equals(Object JavaDoc o) {
98         if (o == this) {
99             return true;
100         }
101        return false;
102     }
103     
104
105 }
106
Popular Tags