Java Code Examples for java.io.ObjectInput#readUnsignedShort()

The following examples show how to use java.io.ObjectInput#readUnsignedShort() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: ignite   File: GridDhtPartitionMap.java    License: Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    nodeId = U.readUuid(in);

    updateSeq = in.readLong();

    int size = in.readInt();

    map = new GridPartitionStateMap();

    for (int i = 0; i < size; i++) {
        int ordinal = in.readUnsignedByte();
        int part = in.readUnsignedShort();

        put(part, GridDhtPartitionState.fromOrdinal(ordinal));
    }

    long ver = in.readLong();
    int minorVer = in.readInt();

    if (ver != 0)
        top = new AffinityTopologyVersion(ver, minorVer);
}
 
Example 2
Source Project: gemfirexd-oss   File: SQLBinary.java    License: Apache License 2.0 4 votes vote down vote up
/**
    * Read the encoded length of the value from the on-disk format.
    * 
    * @see SQLBinary
   */
private static int readBinaryLength(ObjectInput in) throws IOException {
	
	int bl = in.read();
	if (bl == -1)
		throw new java.io.EOFException();
       
       byte li = (byte) bl;

       int len;
	if ((li & ((byte) 0x80)) != 0)
	{
		if (li == ((byte) 0xC0))
		{             
			len = in.readInt();
			}
		else if (li == ((byte) 0xA0))
		{
			len = in.readUnsignedShort();
		}
		else
		{
			len = li & 0x1F;
		}
	}
	else
	{
           
		// old length in bits
		int v2 = in.read();
		int v3 = in.read();
		int v4 = in.read();
		if (v2 == -1 || v3 == -1 || v4 == -1)
			throw new java.io.EOFException();
           int lenInBits = (((bl & 0xff) << 24) | ((v2 & 0xff) << 16) | ((v3 & 0xff) << 8) | (v4 & 0xff));

		len = lenInBits / 8;
		if ((lenInBits % 8) != 0)
			len++;
		}
	return len;
}
 
Example 3
Source Project: gemfirexd-oss   File: SQLBinary.java    License: Apache License 2.0 4 votes vote down vote up
/**
    * Read the encoded length of the value from the on-disk format.
    * 
    * @see SQLBinary
   */
private static int readBinaryLength(ObjectInput in) throws IOException {
	
	int bl = in.read();
	if (bl == -1)
		throw new java.io.EOFException();
       
       byte li = (byte) bl;

       int len;
	if ((li & ((byte) 0x80)) != 0)
	{
		if (li == ((byte) 0xC0))
		{             
			len = in.readInt();
			}
		else if (li == ((byte) 0xA0))
		{
			len = in.readUnsignedShort();
		}
		else
		{
			len = li & 0x1F;
		}
	}
	else
	{
           
		// old length in bits
		int v2 = in.read();
		int v3 = in.read();
		int v4 = in.read();
		if (v2 == -1 || v3 == -1 || v4 == -1)
			throw new java.io.EOFException();
           int lenInBits = (((bl & 0xff) << 24) | ((v2 & 0xff) << 16) | ((v3 & 0xff) << 8) | (v4 & 0xff));

		len = lenInBits / 8;
		if ((lenInBits % 8) != 0)
			len++;
		}
	return len;
}
 
Example 4
/**
 * Read the encoded length of the value from the on-disk format.
 * 
 * @see SQLBinary
*/
private static int readBinaryLength(ObjectInput in) throws IOException {

    int bl = in.read();
    if (bl == -1)
        throw new java.io.EOFException();
    
    byte li = (byte) bl;

    int len;
    if ((li & ((byte) 0x80)) != 0)
    {
        if (li == ((byte) 0xC0))
        {
            len = in.readInt();
         }
        else if (li == ((byte) 0xA0))
        {
            len = in.readUnsignedShort();
        }
        else
        {
            len = li & 0x1F;
        }
    }
    else
    {
        
        // old length in bits
        int v2 = in.read();
        int v3 = in.read();
        int v4 = in.read();
        if (v2 == -1 || v3 == -1 || v4 == -1)
            throw new java.io.EOFException();
        int lenInBits = (((bl & 0xff) << 24) | ((v2 & 0xff) << 16) | ((v3 & 0xff) << 8) | (v4 & 0xff));

        len = lenInBits / 8;
        if ((lenInBits % 8) != 0)
            len++;
     }
    return len;
}