Size of object?
For instance, here's my message object class:
public class Message {
String Identifer;
String Serial;
String Node;
String NodeAlias;
String Manager;
String Agent;
String AlertGroup;
String AlertKey;
String Severity;
String Summary;
String StateChange;
String FirstOccurance;
String LastOccurance;
String InternalLast;
String EventId;
String LocalNodeAlias;
//these are datamembers that will be used during
//the sending of the message to the reciever
//packetID should be incremented each time a new message is created
public static Integer PacketID;
Integer sizeOfPacket; //I'll store the message's size in this data member.
String packetType;
Message()
{
Identifer = "";
Serial = "";
Node = "";
NodeAlias = "";
Manager = "";
Agent = "";
AlertGroup = "";
AlertKey = "";
Severity = "";
Summary = "";
StateChange = "";
FirstOccurance = "";
LastOccurance = "";
InternalLast = "";
EventId = "";
LocalNodeAlias = "";
}
void print()
{
System.out.println("\nIdentifer: " + this.Identifer + '\n'
+ "Serial: " + this.Serial + '\n'
+ "Node: " + this.Node + '\n'
+ "NodeAlias: " + this.NodeAlias + '\n'
+ "Manager: " + this.Manager + '\n'
+ "Agent: " + this.Agent + '\n'
+ "AlertGroup: " + this.AlertGroup + '\n'
+ "AlertKey: " + this.AlertKey + '\n'
+ "Severity: " + this.Severity + '\n'
+ "Summary: " + this.Summary + '\n'
+ "StateChange: " + this.StateChange + '\n'
+ "FirstOccurance: " + this.FirstOccurance + '\n'
+ "LastOccurance: " + this.LastOccurance + '\n'
+ "InternalLast: " + this.InternalLast + '\n'
+ "EventId: " + this.EventId + '\n'
+ "LocalNodeAlias: " + this.LocalNodeAlias + '\n');
}
}
Once I get a message from an event server, I create an object and populate the message's data members.
Now I want to know how big that message is, meaning all the messages datamembers once I fill them up.
The "real" size isn't what is important, the important thing is when I send this message object to the reciever the reciever is going to compare how many bytes it got, and look at the message's data member, Integer sizeOfPacket;
If the sizeOfPacket matches how much the reciever got then all is well. If not then packet loss must of occured so resend the message.
any help would be great! thanks!

