1 8 9 package com.sleepycat.je.log.entry; 10 11 import java.nio.ByteBuffer ; 12 13 import com.sleepycat.je.DatabaseException; 14 import com.sleepycat.je.log.LogReadable; 15 16 19 public class SingleItemLogEntry implements LogEntry { 20 21 private Class logClass; 22 LogReadable item; 23 24 public SingleItemLogEntry(Class logClass) { 25 this.logClass = logClass; 26 } 27 28 31 public void readEntry(ByteBuffer entryBuffer, 32 int entrySize, 33 byte entryTypeVersion, 34 boolean readFullItem) 35 throws DatabaseException { 36 37 try { 38 item = (LogReadable) logClass.newInstance(); 39 item.readFromLog(entryBuffer, entryTypeVersion); 40 } catch (IllegalAccessException e) { 41 throw new DatabaseException(e); 42 } catch (InstantiationException e) { 43 throw new DatabaseException(e); 44 } 45 } 46 47 50 public StringBuffer dumpEntry(StringBuffer sb, boolean verbose) { 51 item.dumpLog(sb, verbose); 52 return sb; 53 } 54 55 58 public Object getMainItem() { 59 return item; 60 } 61 62 65 public Object clone() 66 throws CloneNotSupportedException { 67 68 return super.clone(); 69 } 70 71 74 public boolean isTransactional() { 75 return item.logEntryIsTransactional(); 76 } 77 78 81 public long getTransactionId() { 82 return item.getTransactionId(); 83 } 84 85 88 public LogEntry getNewInstance() 89 throws DatabaseException { 90 91 try { 92 return (LogEntry) logClass.newInstance(); 93 } catch (InstantiationException e){ 94 throw new DatabaseException(e); 95 } catch (IllegalAccessException e){ 96 throw new DatabaseException(e); 97 } 98 } 99 } 100 | Popular Tags |