protocol.core
Class UtilsByte

java.lang.Object
  extended by protocol.core.UtilsByte

public class UtilsByte
extends java.lang.Object

Classe de utilidades para conversão de valores e bytes

Author:
Leonardo Fernandes

Nested Class Summary
static class UtilsByte.Endianness
           
static class UtilsByte.Modificator
           
 
Constructor Summary
UtilsByte()
           
 
Method Summary
static java.lang.Float bytesToFloat(byte[] b, UtilsByte.Endianness en)
          Convert array of bytes into float
static int bytesToInt(byte[] b, int offset, UtilsByte.Modificator mod, UtilsByte.Endianness en)
          Convert array of bytes into integer
static int bytesToInt(byte[] b, UtilsByte.Endianness en)
          Convert array of bytes into integer
static int bytesToLong(byte[] b, UtilsByte.Endianness en)
          Convert array of bytes into integer
static byte[] floatToBytes(java.lang.Float value, UtilsByte.Modificator mod, UtilsByte.Endianness en)
          Convert integer value into array of bytes
static byte[] intToBytes(java.lang.Integer value, UtilsByte.Modificator mod, UtilsByte.Endianness en)
          Convert integer value into array of bytes
static byte[] longToBytes(java.lang.Long value, UtilsByte.Modificator mod, UtilsByte.Endianness en)
          Convert integer value into array of bytes
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UtilsByte

public UtilsByte()
Method Detail

intToBytes

public static byte[] intToBytes(java.lang.Integer value,
                                UtilsByte.Modificator mod,
                                UtilsByte.Endianness en)
Convert integer value into array of bytes

Parameters:
value - Integer value
mod - Modificator type
en - Endianness type
Returns:
Array of bytes

longToBytes

public static byte[] longToBytes(java.lang.Long value,
                                 UtilsByte.Modificator mod,
                                 UtilsByte.Endianness en)
Convert integer value into array of bytes

Parameters:
value - Integer value
mod - Modificator type
en - Endianness type
Returns:
Array of bytes

floatToBytes

public static byte[] floatToBytes(java.lang.Float value,
                                  UtilsByte.Modificator mod,
                                  UtilsByte.Endianness en)
Convert integer value into array of bytes

Parameters:
value - Float value
mod - Modificator type
en - Endianness type
Returns:
Array of bytes

bytesToInt

public static int bytesToInt(byte[] b,
                             UtilsByte.Endianness en)
Convert array of bytes into integer

Parameters:
b - Array of bytes
en - Endianness type
Returns:
Integer value

bytesToLong

public static int bytesToLong(byte[] b,
                              UtilsByte.Endianness en)
Convert array of bytes into integer

Parameters:
b - Array of bytes
en - Endianness type
Returns:
Integer value

bytesToFloat

public static java.lang.Float bytesToFloat(byte[] b,
                                           UtilsByte.Endianness en)
Convert array of bytes into float

Parameters:
b - Array of bytes
en - Endianness type
Returns:
Float value

bytesToInt

public static int bytesToInt(byte[] b,
                             int offset,
                             UtilsByte.Modificator mod,
                             UtilsByte.Endianness en)
Convert array of bytes into integer

Parameters:
b - Array of bytes
offset - Offset into array b
en - Endianness type
Returns:
Integer value