KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgroups > Header


1 // $Id: Header.java,v 1.7 2005/04/24 11:45:40 belaban Exp $
2

3 package org.jgroups;
4
5 import java.io.Externalizable JavaDoc;
6
7
8 /**
9  Abstract base class for all headers to be added to a Message.
10  @author Bela Ban
11  */

12 public abstract class Header implements Externalizable JavaDoc {
13     public static final long HDR_OVERHEAD=100; // estimated size of a header (used to estimate the size of the entire msg)
14

15
16     public Header() {
17
18     }
19
20
21     /**
22      * To be implemented by subclasses. Return the size of this object for the serialized version of it.
23      * I.e. how many bytes this object takes when flattened into a buffer. This may be different for each instance,
24      * or can be the same. This may also just be an estimation. E.g. FRAG uses it on Message to determine whether
25      * or not to fragment the message. Fragmentation itself will be accurate, because the entire message will actually
26      * be serialized into a byte buffer, so we can determine the exact size.
27      */

28     public long size() {
29         return HDR_OVERHEAD;
30     }
31
32
33     public String JavaDoc toString() {
34         return '[' + getClass().getName() + " Header]";
35     }
36
37 }
38
Popular Tags