01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2002,2008 Oracle. All rights reserved.
05: *
06: * $Id: Loggable.java,v 1.3.2.3 2008/01/07 15:14:13 cwl Exp $
07: */
08:
09: package com.sleepycat.je.log;
10:
11: import java.nio.ByteBuffer;
12:
13: /**
14: * A class that implements Loggable knows how to read and write itself into
15: * a ByteBuffer in a format suitable for the JE log or JE replication messages.
16: */
17: public interface Loggable {
18:
19: /*
20: * Writing to a byte buffer
21: */
22:
23: /**
24: * @return number of bytes used to store this object.
25: */
26: public int getLogSize();
27:
28: /**
29: * Serialize this object into the buffer.
30: * @param logBuffer is the destination buffer
31: */
32: public void writeToLog(ByteBuffer logBuffer);
33:
34: /*
35: * Reading from a byte buffer
36: */
37:
38: /**
39: * Initialize this object from the data in itemBuf.
40: * @param itemBuf the source buffer
41: */
42: public void readFromLog(ByteBuffer itemBuffer, byte entryTypeVersion)
43: throws LogException;
44:
45: /**
46: * Write the object into the string buffer for log dumping. Each object
47: * should be dumped without indentation or new lines and should be valid
48: * XML.
49: * @param sb destination string buffer
50: * @param verbose if true, dump the full, verbose version
51: */
52: public void dumpLog(StringBuffer sb, boolean verbose);
53:
54: /**
55: * @return the transaction id embedded within this loggable object. Objects
56: * that have no transaction id should return 0.
57: */
58: public long getTransactionId();
59: }
|