01: // $Id: Header.java,v 1.9 2005/08/08 09:47:19 belaban Exp $
02:
03: package org.jgroups;
04:
05: import java.io.Externalizable;
06:
07: /**
08: Abstract base class for all headers to be added to a Message.
09: @author Bela Ban
10: */
11: public abstract class Header implements Externalizable {
12: public static final long HDR_OVERHEAD = 100; // estimated size of a header (used to estimate the size of the entire msg)
13:
14: public Header() {
15:
16: }
17:
18: /**
19: * To be implemented by subclasses. Return the size of this object for the serialized version of it.
20: * I.e. how many bytes this object takes when flattened into a buffer. This may be different for each instance,
21: * or can be the same. This may also just be an estimation. E.g. FRAG uses it on Message to determine whether
22: * or not to fragment the message. Fragmentation itself will be accurate, because the entire message will actually
23: * be serialized into a byte buffer, so we can determine the exact size.
24: */
25: public long size() {
26: return HDR_OVERHEAD;
27: }
28:
29: // public void writeTo(DataOutputStream out) throws IOException {
30: // ;
31: // }
32: //
33: // public void readFrom(DataInputStream in) throws IOException, IllegalAccessException, InstantiationException {
34: // ;
35: // }
36:
37: public String toString() {
38: return '[' + getClass().getName() + " Header]";
39: }
40:
41: }
|