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 minimum 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.3<br>
016: */
017: final class MinLeafNodeEntry extends LeafNodeEntry {
018:
019: /**
020: *
021: */
022: private static final long serialVersionUID = -4155706530136083168L;
023: private final Comparable value = new ValueObject(Integer.MIN_VALUE,
024: ValueObject.MIN_COMAPARBLE_VALUE);
025:
026: public MinLeafNodeEntry() {
027:
028: }
029:
030: public Comparable getValue() {
031: return value;
032: }
033:
034: /** Setter for property value.
035: * @param value New value of property value.
036: *
037: */
038:
039: public void setValue(Comparable value) {
040: //not supported
041: }
042:
043: public String toString() {
044: StringBuffer buf = new StringBuffer();
045: buf.append("value:" + value);
046: buf.append(",");
047:
048: return buf.toString();
049: }
050:
051: /** Compares this object with the specified object for order. Returns a
052: * negative integer, zero, or a positive integer as this object is less
053: * than, equal to, or greater than the specified object.<p>
054: *
055: * In the foregoing description, the notation
056: * <tt>sgn(</tt><i>expression</i><tt>)</tt> designates the mathematical
057: * <i>signum</i> function, which is defined to return one of <tt>-1</tt>,
058: * <tt>0</tt>, or <tt>1</tt> according to whether the value of <i>expression</i>
059: * is negative, zero or positive.
060: *
061: * The implementor must ensure <tt>sgn(x.compareTo(y)) ==
062: * -sgn(y.compareTo(x))</tt> for all <tt>x</tt> and <tt>y</tt>. (This
063: * implies that <tt>x.compareTo(y)</tt> must throw an exception iff
064: * <tt>y.compareTo(x)</tt> throws an exception.)<p>
065: *
066: * The implementor must also ensure that the relation is transitive:
067: * <tt>(x.compareTo(y)>0 && y.compareTo(z)>0)</tt> implies
068: * <tt>x.compareTo(z)>0</tt>.<p>
069: *
070: * Finally, the implementer must ensure that <tt>x.compareTo(y)==0</tt>
071: * implies that <tt>sgn(x.compareTo(z)) == sgn(y.compareTo(z))</tt>, for
072: * all <tt>z</tt>.<p>
073: *
074: * It is strongly recommended, but <i>not</i> strictly required that
075: * <tt>(x.compareTo(y)==0) == (x.equals(y))</tt>. Generally speaking, any
076: * class that implements the <tt>Comparable</tt> interface and violates
077: * this condition should clearly indicate this fact. The recommended
078: * language is "Note: this class has a natural ordering that is
079: * inconsistent with equals."
080: *
081: * @param o the Object to be compared.
082: * @return a negative integer, zero, or a positive integer as this object
083: * is less than, equal to, or greater than the specified object.
084: *
085: * @throws ClassCastException if the specified object's type prevents it
086: * from being compared to this Object.
087: *
088: */
089: public int compareTo(Object o) {
090: if (o instanceof MinLeafNodeEntry) {
091: return 0;
092: }
093: return -1;
094: }
095:
096: public boolean equals(Object o) {
097: if (o == this ) {
098: return true;
099: }
100: return false;
101: }
102:
103: }
|