001: /*
002: * NodeEntry.java
003: *
004: * Created on 25 May 2003, 09:36
005: */
006:
007: package com.jofti.btree;
008:
009: /**
010: *
011: * This is a special object in the tree and is used to represent an absolute maximum leaf entry for the whole tree. <br>
012: * Class cast issues are taken care of in the Value Object class .<p>
013: *
014: * @author Steve Woodcock
015: * @version 1.7<br>
016: */
017: public class MaxLeafNodeEntry extends LeafNodeEntry {
018:
019: /**
020: *
021: */
022: private static final long serialVersionUID = 6070643245506500846L;
023:
024: public MaxLeafNodeEntry() {
025: value = new ValueObject(Integer.MAX_VALUE,
026: ValueObject.MAX_COMAPARBLE_VALUE);
027: }
028:
029: public Comparable getValue() {
030: return value;
031: }
032:
033: /** Setter for property value.
034: * @param value New value of property value.
035: *
036: */
037:
038: public void setValue(Comparable value) {
039: //not supported
040: }
041:
042: public String toString() {
043: StringBuffer buf = new StringBuffer();
044: buf.append("value:" + value);
045: buf.append(",");
046:
047: return buf.toString();
048: }
049:
050: /** Compares this object with the specified object for order. Returns a
051: * negative integer, zero, or a positive integer as this object is less
052: * than, equal to, or greater than the specified object.<p>
053: *
054: * In the foregoing description, the notation
055: * <tt>sgn(</tt><i>expression</i><tt>)</tt> designates the mathematical
056: * <i>signum</i> function, which is defined to return one of <tt>-1</tt>,
057: * <tt>0</tt>, or <tt>1</tt> according to whether the value of <i>expression</i>
058: * is negative, zero or positive.
059: *
060: * The implementor must ensure <tt>sgn(x.compareTo(y)) ==
061: * -sgn(y.compareTo(x))</tt> for all <tt>x</tt> and <tt>y</tt>. (This
062: * implies that <tt>x.compareTo(y)</tt> must throw an exception iff
063: * <tt>y.compareTo(x)</tt> throws an exception.)<p>
064: *
065: * The implementor must also ensure that the relation is transitive:
066: * <tt>(x.compareTo(y)>0 && y.compareTo(z)>0)</tt> implies
067: * <tt>x.compareTo(z)>0</tt>.<p>
068: *
069: * Finally, the implementer must ensure that <tt>x.compareTo(y)==0</tt>
070: * implies that <tt>sgn(x.compareTo(z)) == sgn(y.compareTo(z))</tt>, for
071: * all <tt>z</tt>.<p>
072: *
073: * It is strongly recommended, but <i>not</i> strictly required that
074: * <tt>(x.compareTo(y)==0) == (x.equals(y))</tt>. Generally speaking, any
075: * class that implements the <tt>Comparable</tt> interface and violates
076: * this condition should clearly indicate this fact. The recommended
077: * language is "Note: this class has a natural ordering that is
078: * inconsistent with equals."
079: *
080: * @param o the Object to be compared.
081: * @return a negative integer, zero, or a positive integer as this object
082: * is less than, equal to, or greater than the specified object.
083: *
084: * @throws ClassCastException if the specified object's type prevents it
085: * from being compared to this Object.
086: *
087: */
088: public int compareTo(Object o) {
089: if (o instanceof MaxLeafNodeEntry) {
090: return 0;
091: }
092: return 1;
093: }
094:
095: public boolean equals(Object o) {
096: if (o instanceof MaxLeafNodeEntry) {
097: return true;
098: }
099: return false;
100: }
101:
102: }
|