001: package com.jofti.store;
002:
003: import java.io.Serializable;
004:
005: import com.jofti.core.IStoreKey;
006:
007: public class StoreKey implements IStoreKey, Cloneable, Serializable {
008:
009: /**
010: *
011: */
012: private static final long serialVersionUID = 6668445940104260505L;
013:
014: long id = 0;
015: private volatile int hashCode = 0;
016: FilePositionHolder[] filePositions = null;
017: int size = 0;
018: int number = 0;
019:
020: public boolean newKey = false;
021:
022: public StoreKey() {
023:
024: }
025:
026: public StoreKey(long id) {
027: this .id = id;
028: }
029:
030: public boolean equals(Object obj) {
031: if (obj instanceof IStoreKey) {
032: IStoreKey temp = (IStoreKey) obj;
033:
034: return temp.getId() == id;
035:
036: }
037: return false;
038: }
039:
040: public int hashCode() {
041: if (hashCode == 0) {
042: hashCode = (int) (id ^ id >> 32);
043: }
044: return hashCode;
045: }
046:
047: public String toString() {
048: return "ID:" + id + " size:" + size + " new:" + newKey;
049: }
050:
051: /* (non-Javadoc)
052: * @see com.jofti.core.IStoreKey#getNextPositions()
053: */
054: public FilePositionHolder[] getFilePositions() {
055: return filePositions;
056: }
057:
058: public void setFilePositions(FilePositionHolder[] filePositions) {
059: this .filePositions = filePositions;
060: }
061:
062: public boolean isNewKey() {
063: return newKey;
064: }
065:
066: public void setNewKey(boolean newKey) {
067: this .newKey = newKey;
068:
069: }
070:
071: /**
072: * @return Returns the size.
073: */
074: public int getSize() {
075: return size;
076: }
077:
078: /**
079: * @param size The size to set.
080: */
081: public void setSize(int size) {
082: this .size = size;
083: }
084:
085: public Object clone() {
086: StoreKey key = new StoreKey();
087: key.id = id;
088: if (filePositions != null) {
089: key.filePositions = (FilePositionHolder[]) filePositions
090: .clone();
091: }
092: key.size = size;
093: key.newKey = newKey;
094: key.number = number;
095: return key;
096:
097: }
098:
099: /* (non-Javadoc)
100: * @see com.jofti.core.IStoreKey#getId()
101: */
102: public long getId() {
103: return id;
104: }
105:
106: public int getNumber() {
107: return number;
108: }
109:
110: public void setNumber(int number) {
111: this.number = number;
112: }
113: }
|