Package net.timewalker.ffmq3.utils

Examples of net.timewalker.ffmq3.utils.RawDataBuffer.readByte()


    // Double
    msg = new StreamMessageImpl();
    msg.writeByte((byte)123);
    msg.markAsReadOnly();
    try { msg.readDouble(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */ }
    assertEquals(123,msg.readByte());
   
    // String
    msg = new StreamMessageImpl();
    msg.writeByte((byte)123);
    msg.markAsReadOnly();
View Full Code Here


    // Bytes
    msg = new StreamMessageImpl();
    msg.writeByte((byte)123);
    msg.markAsReadOnly();
    try { msg.readBytes(new byte[1]); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertEquals(123,msg.readByte());
  }
 
  public void testShortConversion() throws Exception
  {
    StreamMessageImpl msg;
View Full Code Here

   
    // Byte
    msg = new StreamMessageImpl();
    msg.writeShort((short)123);
    msg.markAsReadOnly();
    try { msg.readByte(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertEquals(123,msg.readShort());
   
    // Short
    msg = new StreamMessageImpl();
    msg.writeShort((short)123);
View Full Code Here

   
    // Byte
    msg = new StreamMessageImpl();
    msg.writeChar('c');
    msg.markAsReadOnly();
    try { msg.readByte(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertEquals('c',msg.readChar());
   
    // Short
    msg = new StreamMessageImpl();
    msg.writeChar('c');
View Full Code Here

   
    // Byte
    msg = new StreamMessageImpl();
    msg.writeInt(123);
    msg.markAsReadOnly();
    try { msg.readByte(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertEquals(123,msg.readInt());
   
    // Short
    msg = new StreamMessageImpl();
    msg.writeInt(123);
View Full Code Here

   
    // Byte
    msg = new StreamMessageImpl();
    msg.writeString("123");
    msg.markAsReadOnly();
    assertEquals((byte)123,msg.readByte());
   
    // Short
    msg = new StreamMessageImpl();
    msg.writeString("123");
    msg.markAsReadOnly();
View Full Code Here

   
    // Byte
    msg = new StreamMessageImpl();
    msg.writeBytes(dummy);
    msg.markAsReadOnly();
    try { msg.readByte(); fail("Should have failed"); } catch (MessageFormatException e) { /* OK */  }
    assertEquals(3,msg.readBytes(new byte[3]));
   
    // Short
    msg = new StreamMessageImpl();
    msg.writeBytes(dummy);
View Full Code Here

     * Unserialize a message
     */
    public static AbstractMessage unserialize( byte[] rawData , boolean asInternalCopy )
    {
      RawDataBuffer rawIn = new RawDataBuffer(rawData);
        byte type = rawIn.readByte();
        AbstractMessage message = MessageType.createInstance(type);
        message.initializeFromRaw(rawIn);
        if (asInternalCopy)
          message.setInternalCopy(true);
       
View Full Code Here

    {
      int size = rawIn.readInt();
     
      // Extract a sub buffer
      RawDataBuffer rawMessage = new RawDataBuffer(rawIn.readBytes(size));
        byte type = rawMessage.readByte();
        AbstractMessage message = MessageType.createInstance(type);
        message.initializeFromRaw(rawMessage);
        if (asInternalCopy)
            message.setInternalCopy(true);
View Full Code Here

      // Only read a few bytes of the message to read the priority field
      byte[] msgHeader = ((AbstractBlockBasedDataStore)dataStore).retrieveHeader(handle, AbstractMessage.PRIORITY_OFFSET+1);
      RawDataBuffer buf = new RawDataBuffer(msgHeader);
      if (buf.skipBytes(AbstractMessage.PRIORITY_OFFSET) != AbstractMessage.PRIORITY_OFFSET)
          throw new DataStoreException("Cannot skip to priority field offset");
      return buf.readByte();
    }
   
    private byte[] serialize( AbstractMessage message )
    {
    return MessageSerializer.serialize(message,((AbstractBlockBasedDataStore)dataStore).getBlockSize());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.