1 11 package org.eclipse.core.internal.indexing; 12 13 public class ObjectID implements Insertable { 14 15 private static final int Size = 8; 16 private static final int ObjectNumberOffset = 0; 17 private long objectNumber; 18 19 public ObjectID(byte[] b) throws IndexedStoreException { 20 if (b.length != Size) { 21 throw new IndexedStoreException(IndexedStoreException.ObjectIDInvalid); 22 } 23 Buffer buf = new Buffer(b); 24 objectNumber = buf.getLong(ObjectNumberOffset, 8); 25 } 26 27 public ObjectID(long objectNumber) { 28 this.objectNumber = objectNumber; 29 } 30 31 public boolean equals(Object anObject) { 32 if (!(anObject instanceof ObjectID)) 33 return false; 34 ObjectID id = (ObjectID) anObject; 35 if (this.objectNumber != id.objectNumber) 36 return false; 37 return true; 38 } 39 40 public int hashCode() { 41 return (int) objectNumber; 42 } 43 44 public byte[] toByteArray() { 45 Buffer buf = new Buffer(Size); 46 buf.put(ObjectNumberOffset, 8, objectNumber); 47 return buf.get(); 48 } 49 } 50 | Popular Tags |