com.google.code.proto.streamio
Class PBWireByteMarkerHelper

java.lang.Object
  extended by com.google.code.proto.streamio.AbstractPBWireByteMarkerHelper
      extended by com.google.code.proto.streamio.PBWireByteMarkerHelper
All Implemented Interfaces:
IPBWireByteMarkerHelper

public class PBWireByteMarkerHelper
extends AbstractPBWireByteMarkerHelper

A utility class to help write delimiting byte markers for Google protocol buffer generated messages used with PBStreamReader. The delimeter is a byte array holding the size of the generated message that will follow. The delimiter is an unsigned byte marker so can't be used by clients that can only process ASCII strings (for example, web browsers that don't support the Blob API).

Author:
nichole

Constructor Summary
PBWireByteMarkerHelper()
           
 
Method Summary
 int bytesToInteger(byte[] marker)
          Convert the marker byte array to an integer where each item is part of byte shifted integer The byte array has been restricted to the signed portion to accommodate clients that can only process strings (ascii being 0-127).
 byte[] integerToBytesBigEndian(int sz)
          Convert the integer into a byte array composed of byte shifted parts of the integer.
 
Methods inherited from class com.google.code.proto.streamio.AbstractPBWireByteMarkerHelper
createMessageDelimiter, estimateTotalContentLength, getByteMarkerSize, getDelimiterSize, getMarkerForStart
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PBWireByteMarkerHelper

public PBWireByteMarkerHelper()
Method Detail

integerToBytesBigEndian

public byte[] integerToBytesBigEndian(int sz)
Convert the integer into a byte array composed of byte shifted parts of the integer. The byte array has been restricted to the signed portion to accommodate clients that can only process strings (ascii being 0-127).

Specified by:
integerToBytesBigEndian in interface IPBWireByteMarkerHelper
Specified by:
integerToBytesBigEndian in class AbstractPBWireByteMarkerHelper
Parameters:
sz - the integer to be represented by the returned byte array
Returns:

bytesToInteger

public int bytesToInteger(byte[] marker)
Convert the marker byte array to an integer where each item is part of byte shifted integer The byte array has been restricted to the signed portion to accommodate clients that can only process strings (ascii being 0-127). The maximum value that can be returned is 2^(8*byteMarkerSize - 1) which is 2GB for a byteMarkerSize = 4.

Specified by:
bytesToInteger in interface IPBWireByteMarkerHelper
Specified by:
bytesToInteger in class AbstractPBWireByteMarkerHelper
Parameters:
marker -
Returns:


Copyright © 2011. All Rights Reserved.