1 19 package org.netbeans.mdr.persistence; 20 21 import java.util.Collections ; 22 import java.util.Arrays ; 23 24 32 public interface Storage { 33 35 public static final class EntryType { 36 37 public static final EntryType MOFID = new EntryType ((byte) 1, "MOFID"); 38 39 43 public static final EntryType STREAMABLE =new EntryType ((byte) 2, "STREAMABLE"); 44 45 46 public static final EntryType STRING =new EntryType ((byte) 3, "STRING"); 47 48 49 public static final EntryType INT =new EntryType ((byte) 4, "INT"); 50 51 private static final EntryType[] all = new EntryType[] {MOFID, STREAMABLE, STRING, INT}; 52 53 private final byte id; 54 private final String textId; 55 56 private EntryType(byte id, String textId) { 57 this.id = id; 58 this.textId = textId; 59 } 60 61 64 public static java.util.Collection getEntryTypes () { 65 return Collections.unmodifiableCollection(Arrays.asList(all)); 66 } 67 68 public static Storage.EntryType decodeEntryType (String name) { 69 for (int i = 0; i < all.length; i++){ 70 if (all[i].textId.equals(name)) { 71 return all[i]; 72 } 73 } 74 return null; 75 } 76 77 public static Storage.EntryType decodeEntryType (byte code) { 78 if (code > 0 && code <= 4) return all[code-1]; 79 return null; 80 } 81 82 public String toString() { 83 return textId; 84 } 85 86 public byte encode() { 87 return id; 88 } 89 } 90 91 public String getName(); 92 93 public String getStorageId (); 94 95 public long getSerialNumber (); 96 97 102 public MOFID readMOFID (java.io.InputStream inputStream) throws StorageException; 103 104 109 public void writeMOFID (java.io.OutputStream outputStream, MOFID mofid) throws StorageException; 110 111 114 public SinglevaluedIndex getPrimaryIndex() throws StorageException; 115 116 117 public boolean exists() throws StorageException; 118 119 122 public boolean delete() throws StorageException; 123 124 133 public void create (boolean replace, ObjectResolver resolver) throws StorageException; 134 135 139 public void open(boolean createOnNoExist, ObjectResolver resolver) throws StorageException; 140 141 142 public void close() throws StorageException; 143 144 150 public SinglevaluedIndex createSinglevaluedIndex(String name, EntryType keyType, EntryType valueType) throws StorageException; 151 158 public MultivaluedOrderedIndex createMultivaluedOrderedIndex(String name, EntryType keyType, EntryType valueType, boolean unique) throws StorageException; 159 167 public MultivaluedIndex createMultivaluedIndex(String name, EntryType keyType, EntryType valueType, boolean unique) throws StorageException; 168 169 173 public Index getIndex(String name) throws StorageException; 174 178 public SinglevaluedIndex getSinglevaluedIndex(String name) throws StorageException; 179 183 public MultivaluedIndex getMultivaluedIndex(String name) throws StorageException; 184 188 public MultivaluedOrderedIndex getMultivaluedOrderedIndex(String name) throws StorageException; 189 192 public void dropIndex(String name) throws StorageException; 193 194 203 public void objectStateWillChange (Object key) throws StorageException; 204 205 210 public void objectStateChanged (Object key) throws StorageException; 211 212 216 public void commitChanges() throws StorageException; 217 218 225 public void rollBackChanges () throws StorageException; 226 227 230 public void shutDown() throws StorageException; 231 232 } 243 | Popular Tags |