Accessing message body

I have incoming packets filtered based on type, I am accepting Message packets. When they get to the PacketListener they are still Packet objects and I can’‘t find a good way to access the Message body ( Packet doesn’'t have a getBody() method ). What am I missing? Right now I use toXML() and manually parse the packet but that is pretty ugly.

If you know that the packet is a Message object, you can cast it to get to the message:

public void processPacket(Packet packet); if (packet instanceof Message){
   Message msg = (Message)packet;
   String body = msg.getBody();
   //... }
}

i am retarted. thanks