KickJava   Java API By Example, From Geeks To Geeks.

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


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
13 /**
14  *
15  * This is a special object in the tree and is used to represent an absolute maximum leaf entry for the whole tree. <br>
16  * Class cast issues are taken care of in the Value Object class .<p>
17  *
18  * @author Steve Woodcock
19  * @version 1.7<br>
20  */

21 public class MaxLeafNodeEntry extends LeafNodeEntry {
22     
23      
24   
25     
26     /**
27      *
28      */

29     private static final long serialVersionUID = 6070643245506500846L;
30
31     public MaxLeafNodeEntry(){
32         value = new ValueObject(Integer.MAX_VALUE,ValueObject.MAX_COMAPARBLE_VALUE);
33     }
34     
35  
36     public Comparable JavaDoc getValue() {
37         return value;
38     }
39     
40     /** Setter for property value.
41      * @param value New value of property value.
42      *
43      */

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

96     public int compareTo(Object JavaDoc o) {
97         if (o instanceof MaxLeafNodeEntry) {
98             return 0;
99         }
100         return 1;
101     }
102     
103     public boolean equals(Object JavaDoc o) {
104         if (o instanceof MaxLeafNodeEntry) {
105             return true;
106         }
107        return false;
108     }
109     
110
111 }
112
Popular Tags