1 11 package org.eclipse.core.internal.indexing; 12 13 class BinarySmallObject extends IndexedStoreObject { 14 public static final int TYPE = 5; 15 public static final int VALUE_OFFSET = 2; 16 protected byte[] value; 17 18 21 public BinarySmallObject(byte[] value) { 22 super(); 23 this.value = new Buffer(value).get(); 24 } 25 26 29 public BinarySmallObject(Field f, ObjectStore store, ObjectAddress address) throws ObjectStoreException { 30 super(f, store, address); 31 } 32 33 39 protected void insertValues(Field f) { 40 super.insertValues(f); 41 f.subfield(VALUE_OFFSET).put(value); 42 } 43 44 47 protected void extractValues(Field f) throws ObjectStoreException { 48 super.extractValues(f); 49 value = f.subfield(VALUE_OFFSET).get(); 50 } 51 52 56 protected int getMaximumSize() { 57 return 6000 + VALUE_OFFSET; 58 } 59 60 protected int length() { 61 return value.length + VALUE_OFFSET; 62 } 63 64 68 protected int getMinimumSize() { 69 return VALUE_OFFSET; 70 } 71 72 76 protected int getRequiredType() { 77 return TYPE; 78 } 79 80 83 public byte[] getValue() { 84 return new Field(value).get(); 85 } 86 87 90 public String toString() { 91 int n = 10; 92 StringBuffer b = new StringBuffer (); 93 b.append("BSOB("); b.append(value.length); 95 b.append(" ["); for (int i = 0; i < value.length; i++) { 97 if (i > 0) 98 b.append(" "); if (i == n) 100 break; 101 b.append(value[i]); 102 } 103 if (value.length > n) 104 b.append(" ..."); b.append("])"); return b.toString(); 107 } 108 109 } 110 | Popular Tags |