Code example for ObjectInputStream

Methods: readBoolean, readLong, readShort

0
	@Override 
	public BDBMessage unmarshall(byte[] data) throws Throwable
	{ 
		BDBMessage message = new BDBMessage();
 
		ObjectInputStream oIn = new ObjectInputStream(new UnsynchronizedByteArrayInputStream(data));
 
		short version = oIn.readShort();
 
		if (version != 2)
		{ 
			String errorMessage = String.format("Incorrect serialization version: ", version);
			throw new RuntimeException(errorMessage);
		} 
 
		message.setVersion(version);
		message.setSequence(oIn.readLong());
		message.setPreferLocalConsumer(oIn.readBoolean());
		message.setReserveTimeout(oIn.readLong());
 
		//byte[] buf = new byte[oIn.available()]; 
 
	 
		NetMessage nmsg = serializer.unmarshal(oIn);
 
		//message.setRawPacket(buf); 
		message.setMessage(nmsg);
 
		return message;