oracle.panama.util
Class Conversion

java.lang.Object
  |
  +--oracle.panama.util.Conversion

public final class Conversion
extends java.lang.Object

Utility to convert between bytes and character etc.

The only reason for this class is that the standard java conversions are too much resource wasting.

Since:
PANAMA_10

Constructor Summary
Conversion()
           
 
Method Summary
TypeMethod
static java.lang.String formatInt(long num, int padCh, int lpad)
          Returns a character padded integer (left).
static byte[] toBytes(java.io.InputStream is)
          Returns the input stream data as a byte array.
static byte[] toBytes(java.lang.String hexString)
          Returns the hex string as a byte array.
static char toHex(int nibble)
          Returns the hex representation of a nible.
static java.lang.String toHexString(byte b)
          Returns the hex string of one byte.
static java.lang.String toHexString(byte[] bytes)
          Returns a hex string out of a byte array.
static java.lang.String toHexString(java.io.InputStream is)
          Returns a hex string out of a byte array.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Conversion

public Conversion()
Method Detail

toHex

public static char toHex(int nibble)
Returns the hex representation of a nible.
Parameters:
nibble - the nibble to convert.
Returns:
the hex character.

toHexString

public static java.lang.String toHexString(byte b)
Returns the hex string of one byte.
Parameters:
b - the byte.
Returns:
the hex string.

toHexString

public static java.lang.String toHexString(byte[] bytes)
Returns a hex string out of a byte array.
Parameters:
bytes - the array of bytes.
Returns:
the hex string.

toHexString

public static java.lang.String toHexString(java.io.InputStream is)
                                    throws java.io.IOException
Returns a hex string out of a byte array.
Parameters:
is - the input stream.
Returns:
the hex string.

toBytes

public static byte[] toBytes(java.lang.String hexString)
Returns the hex string as a byte array.
Parameters:
hexString - the hex string produced by toHexString
Returns:
a byte array from a hex String previosly created with toHexString
See Also:
toHexString(byte)

toBytes

public static byte[] toBytes(java.io.InputStream is)
                      throws java.io.IOException
Returns the input stream data as a byte array.
Parameters:
is - the input stream.
Returns:
the bytes of the complete input stream

formatInt

public static java.lang.String formatInt(long num,
                                         int padCh,
                                         int lpad)
Returns a character padded integer (left).
Parameters:
num - the number.
padCh - the character to pad with.
lpad - number of zeros to left pad with.
Returns:
the padded number as a string.