1 17 package org.apache.excalibur.store.impl; 18 19 import java.io.IOException ; 20 import java.io.ObjectInput ; 21 import java.io.ObjectOutput ; 22 23 import com.coyotegulch.jisp.KeyObject; 24 25 32 public final class JispKey extends KeyObject 33 { 34 final static long serialVersionUID = -1216913992804571313L; 35 36 protected Object m_Key; 37 38 static protected JispKey NULL_KEY = new JispKey(""); 39 40 public JispKey() { 41 this(""); 42 } 43 44 49 public JispKey(Object keyValue) 50 { 51 m_Key = keyValue; 52 } 53 54 60 61 public int compareTo(KeyObject key) 62 { 63 if (key instanceof JispKey) 64 { 65 final JispKey other = (JispKey)key; 66 if ( other.m_Key.hashCode() == m_Key.hashCode() ) 67 { 68 if ( m_Key == other.m_Key || m_Key.equals(other.m_Key) ) 69 { 70 return KEY_EQUAL; 71 } 72 int comp = m_Key.getClass().getName().compareTo(other.m_Key.getClass().getName()); 78 if ( comp < 0 ) 79 { 80 return KEY_LESS; 81 } 82 return KEY_MORE; 83 } 84 else 85 { 86 if ( m_Key.hashCode() < other.m_Key.hashCode() ) 87 { 88 return KEY_LESS; 89 } 90 return KEY_MORE; 91 } 92 } 93 else 94 { 95 return KEY_ERROR; 96 } 97 } 98 99 104 public KeyObject makeNullKey() 105 { 106 return NULL_KEY; 107 } 108 109 118 public void writeExternal(ObjectOutput out) 119 throws IOException 120 { 121 out.writeObject(m_Key); 122 } 123 124 134 public void readExternal(ObjectInput in) 135 throws IOException , ClassNotFoundException 136 { 137 m_Key = in.readObject(); 138 } 139 140 143 public Object getKey() 144 { 145 return m_Key; 146 } 147 } 148 | Popular Tags |