Example #1
0
 @Override
 public int getCachedSize() {
   // Approximate the size of the object in bytes by calculating the size
   // of each field.
   int size = 0;
   size += CacheSizes.sizeOfObject(); // overhead of object
   size += nodeID.toByteArray().length; // Node ID
   size += CacheSizes.sizeOfBoolean(); // available
   return size;
 }
Example #2
0
 @Override
 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
   byte[] bytes = ExternalizableUtil.getInstance().readByteArray(in);
   // Retrieve the NodeID but try to use the singleton instance
   if (XMPPServer.getInstance().getNodeID().equals(bytes)) {
     nodeID = XMPPServer.getInstance().getNodeID();
   } else {
     nodeID = NodeID.getInstance(bytes);
   }
   available = ExternalizableUtil.getInstance().readBoolean(in);
 }
Example #3
0
 @Override
 public void writeExternal(ObjectOutput out) throws IOException {
   ExternalizableUtil.getInstance().writeByteArray(out, nodeID.toByteArray());
   ExternalizableUtil.getInstance().writeBoolean(out, available);
 }