1 24 package org.objectweb.jalisto.se.storage.raf; 25 26 import java.io.*; 27 28 public class RecordReader { 29 30 public RecordReader(String key, byte[] data) { 31 this.key = key; 32 this.data = data; 33 in = DbByteArrayInputStream.getInstance(data); 34 } 35 36 public byte[] getData() { 37 return data; 38 } 39 40 public InputStream getInputStream() { 41 return in; 42 } 43 44 public String getKey() { 45 return key; 46 } 47 48 public ObjectInputStream getObjectInputStream() throws IOException { 49 if (objIn == null) { 50 objIn = new ObjectInputStream(in); 51 } 52 53 return objIn; 54 } 55 56 59 public Object readObject() 60 throws IOException, ClassNotFoundException { 61 return getObjectInputStream().readObject(); 62 } 63 64 public void reset() { 65 in.reset(); 66 } 67 68 ByteArrayInputStream in; 69 ObjectInputStream objIn; 70 String key; 71 byte[] data; 72 } 73 | Popular Tags |