1 24 package org.objectweb.jalisto.se.storage.raf; 25 26 import java.io.*; 27 28 public class RecordWriter { 29 30 public RecordWriter(String key) { 31 this.key = key; 32 out = DbByteArrayOutputStream.getInstance(); 33 } 34 35 38 public int getDataLength() { 39 return out.size(); 40 } 41 42 public void setKey(String key) { 43 this.key = key; 44 } 45 46 public String getKey() { 47 return key; 48 } 49 50 public ObjectOutputStream getObjectOutputStream() throws IOException { 51 if (objOut == null) { 52 objOut = new ObjectOutputStream(out); 53 } 54 return objOut; 55 } 56 57 public OutputStream getOutputStream() { 58 return out; 59 } 60 61 public DbByteArrayOutputStream getOut() { 62 return out; 63 } 64 65 public void writeObject(Object o) throws IOException { 66 getObjectOutputStream().writeObject(o); 67 getObjectOutputStream().flush(); 68 } 69 70 public void writeDatas(byte[] datas) throws IOException { 71 out.writeDatas(datas); 72 } 73 74 77 public void writeTo(DataOutput str) throws IOException { 78 out.writeTo(str); 79 } 80 81 public void reset() { 82 out.reset(); 83 } 84 85 private DbByteArrayOutputStream out; 86 private ObjectOutputStream objOut; 87 private String key; 88 } 89 | Popular Tags |