unsigned
Class uByte

java.lang.Object
  extended by unsigned.uByte

public class uByte
extends java.lang.Object

Written by Evangelos Haleplidis, e_halep at yahoo dot gr, and Sean R Owens, sean at guild dot net, released to the public domain. Share and enjoy. Since some people argue that it is impossible to release software to the public domain, you are also free to use this code under any version of the GPL, LPGL, or BSD licenses, or contact the authors for use of another license. The unsigned Integer Class.


Constructor Summary
uByte()
          Unsigned Byte constructor with no value.
uByte(byte unsigned)
          Unsigned Byte constructor with an already read unsigned Byte to be converted to Java format.
uByte(byte[] bytes, int offset)
          Unsigned Byte constructor that gets an already read unsigned Byte that exists inside a Byte Array at position offset and converts it into the proper format for Java
uByte(java.nio.ByteBuffer bb, int offset)
          Unsigned Byte constructor that read gets an already read unsigned Byte that exists inside a ByteBuffer at position offset and converts it into the proper format for Java Caution, the position of the bytebuffer is not changed inside the constructor.
uByte(short tobecomeunsigned)
          Unsigned Byte constructor with a value in Java format.
 
Method Summary
 short getValue()
          getValue returns the actual value of the unsigned byte.
 void read(byte i)
          Read gets an already read unsigned byte and converts it into the proper format for Java
 void read(byte[] bytes, int offset)
          Read gets an already read unsigned Short that exists inside a Byte Array at position offset and converts it into the proper format for Java
 void read(java.nio.ByteBuffer bb, int offset)
          Read gets an already read unsigned Byte that exists inside a ByteBuffer at position offset and converts it into the proper format for Java Caution, the position of the bytebuffer is not changed inside this read call.
 void setValue(short value)
          SetValue sets an byte value.
 byte write()
          WriteUnByte prepares the unsigned Byte from Java format to be written into the proper unsigned format for the wire.
 boolean write(byte[] bytes, int offset)
          Write prepares the unsigned Byte from Java format to be written into the proper unsigned format for the wire and puts it at a ByteArray at position equal to offset.
 boolean write(java.nio.ByteBuffer bb, int offset)
          Write prepares the unsigned Byte from Java format to be written into the proper unsigned format for the wire and puts it at a ByteBuffer at position equal to offset.
 byte[] writeByteArray()
          WriteUnByte prepares the unsigned Byte from Java format to be written into the proper unsigned format for the wire in a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

uByte

public uByte()
Unsigned Byte constructor with no value.


uByte

public uByte(byte unsigned)
Unsigned Byte constructor with an already read unsigned Byte to be converted to Java format.

Parameters:
unsigned - The already read unsigned Int that needs to be converted to Java format.

uByte

public uByte(short tobecomeunsigned)
Unsigned Byte constructor with a value in Java format.

Parameters:
tobecomeunsigned - The value in javaformat.

uByte

public uByte(java.nio.ByteBuffer bb,
             int offset)
Unsigned Byte constructor that read gets an already read unsigned Byte that exists inside a ByteBuffer at position offset and converts it into the proper format for Java Caution, the position of the bytebuffer is not changed inside the constructor.

Parameters:
bb - The ByteBuffer in which the already read unsigned Byte exists
offset - The position that the byte of the unsigned Byte starts

uByte

public uByte(byte[] bytes,
             int offset)
Unsigned Byte constructor that gets an already read unsigned Byte that exists inside a Byte Array at position offset and converts it into the proper format for Java

Parameters:
bytes - The byte array
offset - The position that the byte of the unsigned Byte starts
Method Detail

read

public void read(byte i)
Read gets an already read unsigned byte and converts it into the proper format for Java

Parameters:
i - The read unsigned byte that needs to be converted to Java format.

read

public void read(java.nio.ByteBuffer bb,
                 int offset)
Read gets an already read unsigned Byte that exists inside a ByteBuffer at position offset and converts it into the proper format for Java Caution, the position of the bytebuffer is not changed inside this read call.

Parameters:
bb - The ByteBuffer in which the already read unsigned Byte exists
offset - The position that the byte of the unsigned Byte starts

read

public void read(byte[] bytes,
                 int offset)
Read gets an already read unsigned Short that exists inside a Byte Array at position offset and converts it into the proper format for Java

Parameters:
bytes - The byte array
offset - The position that the byte of the unsigned byte starts

write

public byte write()
WriteUnByte prepares the unsigned Byte from Java format to be written into the proper unsigned format for the wire.

Returns:
Returns the unsigned byte in a byte format

write

public boolean write(java.nio.ByteBuffer bb,
                     int offset)
Write prepares the unsigned Byte from Java format to be written into the proper unsigned format for the wire and puts it at a ByteBuffer at position equal to offset.

Parameters:
bb - The Bytebuffer to put the Unsigned Byte
offset - The position to start putting the byte
Returns:
Returns true if the byte was written, false if the offset was wrong.

write

public boolean write(byte[] bytes,
                     int offset)
Write prepares the unsigned Byte from Java format to be written into the proper unsigned format for the wire and puts it at a ByteArray at position equal to offset.

Parameters:
bytes - The Byte Array to put the Unsigned Short
offset - The position to start putting the byte
Returns:
Returns true if the Byte was written, false if the offset was wrong.

writeByteArray

public byte[] writeByteArray()
WriteUnByte prepares the unsigned Byte from Java format to be written into the proper unsigned format for the wire in a byte array.

Returns:
Returns the unsigned byte in a byte array format

getValue

public short getValue()
getValue returns the actual value of the unsigned byte. Caution, returns a short.

Returns:
Returns the actual value of the unsigned byte, in short data type.

setValue

public void setValue(short value)
SetValue sets an byte value.

Parameters:
value - The value.