org.mobicents.slee.resource.parlay.util
Class Convert

java.lang.Object
  extended by org.mobicents.slee.resource.parlay.util.Convert

public class Convert
extends java.lang.Object

Convert is a utility that provides conversion functions for java types. For example converting a byte[] to a hex string.


Method Summary
static boolean assertEquals(byte[] b1, byte[] b2)
          Compares two byte arrays and returns true if they are equal
static byte[] fromHexString(java.lang.String s)
          Convert a hex string to a byte array.
static byte[] toByteArray(int x)
          Creates a four byte array from an integer.
static java.lang.String toHexString(byte b)
          convert a byte b to 2-char hex string with possible leading zero.
static java.lang.String toHexString(byte[] b)
          Fast convert a byte array to a hex string with possible leading zero.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toHexString

public static java.lang.String toHexString(byte b)
convert a byte b to 2-char hex string with possible leading zero.

Parameters:
b - byte to be converted
Returns:
String hex equivalent of byte

toHexString

public static java.lang.String toHexString(byte[] b)
Fast convert a byte array to a hex string with possible leading zero.

Parameters:
b - hex string rep in byte array
Returns:
String

fromHexString

public static byte[] fromHexString(java.lang.String s)
Convert a hex string to a byte array. Permits upper or lower case hex.

Parameters:
s - String must have even number of characters. and be formed only of digits 0-9 A-F or a-f. No spaces, minus or plus signs.
Returns:
corresponding byte array.

assertEquals

public static boolean assertEquals(byte[] b1,
                                   byte[] b2)
Compares two byte arrays and returns true if they are equal

Parameters:
b1 - the first byte array
b2 - the second byte array
Returns:
a boolean indicating whether the two arrays are equal.

toByteArray

public static byte[] toByteArray(int x)
Creates a four byte array from an integer.

Parameters:
x - the integer to convert
Returns:
byte[]


Copyright © 2009. All Rights Reserved.