1 11 package org.eclipse.core.internal.indexing; 12 13 class IndexedStoreContext extends IndexedStoreObject { 14 15 public static final int SIZE = 32; 16 public static final int TYPE = 2; 17 18 22 private static final int OpenNumberOffset = 2; 23 private static final int OpenNumberLength = 4; 24 private Field openNumberField; 25 private int openNumber; 26 27 private static final int ObjectDirectoryAddressOffset = 6; 28 private static final int ObjectDirectoryAddressLength = 4; 29 private Field objectDirectoryAddressField; 30 private ObjectAddress objectDirectoryAddress; 31 32 private static final int IndexDirectoryAddressOffset = 10; 33 private static final int IndexDirectoryAddressLength = 4; 34 private Field indexDirectoryAddressField; 35 private ObjectAddress indexDirectoryAddress; 36 37 private static final int ObjectNumberOffset = 14; 38 private static final int ObjectNumberLength = 8; 39 private Field objectNumberField; 40 private long objectNumber; 41 42 45 IndexedStoreContext() { 46 super(); 47 indexDirectoryAddress = ObjectAddress.Null; 48 objectDirectoryAddress = ObjectAddress.Null; 49 openNumber = 0; 50 objectNumber = 0; 51 } 52 53 56 IndexedStoreContext(Field f, ObjectStore store, ObjectAddress address) throws ObjectStoreException { 57 super(f, store, address); 58 } 59 60 63 protected void setFields(Field contents) { 64 openNumberField = contents.subfield(OpenNumberOffset, OpenNumberLength); 65 objectDirectoryAddressField = contents.subfield(ObjectDirectoryAddressOffset, ObjectDirectoryAddressLength); 66 indexDirectoryAddressField = contents.subfield(IndexDirectoryAddressOffset, IndexDirectoryAddressLength); 67 objectNumberField = contents.subfield(ObjectNumberOffset, ObjectNumberLength); 68 } 69 70 74 protected void extractValues(Field contents) throws ObjectStoreException { 75 super.extractValues(contents); 76 setFields(contents); 77 openNumber = openNumberField.getInt(); 78 objectDirectoryAddress = new ObjectAddress(objectDirectoryAddressField.get()); 79 indexDirectoryAddress = new ObjectAddress(indexDirectoryAddressField.get()); 80 objectNumber = objectNumberField.getLong(); 81 82 if (openNumber > 0) { 83 objectNumber = (long) openNumber << 32; 84 openNumber = 0; 85 setChanged(); 86 } 87 } 88 89 93 protected void insertValues(Field contents) { 94 super.insertValues(contents); 95 setFields(contents); 96 openNumberField.put(openNumber); 97 objectDirectoryAddressField.put(objectDirectoryAddress); 98 indexDirectoryAddressField.put(indexDirectoryAddress); 99 objectNumberField.put(objectNumber); 100 } 101 102 105 ObjectAddress getIndexDirectoryAddress() { 106 return indexDirectoryAddress; 107 } 108 109 113 protected int getMinimumSize() { 114 return SIZE; 115 } 116 117 120 ObjectAddress getObjectDirectoryAddress() { 121 return objectDirectoryAddress; 122 } 123 124 128 protected int getRequiredType() { 129 return TYPE; 130 } 131 132 136 long getNextObjectNumber() { 137 objectNumber++; 138 setChanged(); 139 return objectNumber; 140 } 141 142 145 void setIndexDirectoryAddress(ObjectAddress address) { 146 this.indexDirectoryAddress = address; 147 setChanged(); 148 } 149 150 153 void setObjectDirectoryAddress(ObjectAddress address) { 154 this.objectDirectoryAddress = address; 155 setChanged(); 156 } 157 158 161 public String toString() { 162 StringBuffer b = new StringBuffer (); 163 b.append("Context("); b.append(objectNumber); 165 b.append(","); b.append(indexDirectoryAddress); 167 b.append(","); b.append(objectDirectoryAddress); 169 b.append(")"); return b.toString(); 171 } 172 173 } 174 | Popular Tags |