com.jguild.jrpm.io.datatype
Class RPMUtil

java.lang.Object
  extended by com.jguild.jrpm.io.datatype.RPMUtil

public final class RPMUtil
extends java.lang.Object

Misc utilities functions.

Version:
$Id: RPMUtil.java,v 1.3 2005/11/11 08:27:40 mkuss Exp $
Author:
kuss

Method Summary
static java.lang.String byteArrayToHexString(byte[] barray)
          Method to get a beautyfied representation of an byte array as a hex string.
static java.lang.String byteToHexString(byte b)
          Method to get a beautyfied representation of a byte as a hex string.
static java.lang.String cArrayToString(byte[] data, int offset)
          Method to convert a null terminated C string into a java string using the DEFAULT_ENCODING
static java.lang.String cArrayToString(byte[] data, int offset, java.lang.String enc)
          Method to convert a null terminated C string into a java string using the defined encoding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

byteArrayToHexString

public static java.lang.String byteArrayToHexString(byte[] barray)
Method to get a beautyfied representation of an byte array as a hex string. One byte will always be displayed as two hex digits.

Parameters:
barray - An byte array that should be converted to a hex string
Returns:
The hex string

byteToHexString

public static java.lang.String byteToHexString(byte b)
Method to get a beautyfied representation of a byte as a hex string. The hex block will be displayed always as two digits.

Parameters:
b - A byte that should be converted to a hex string
Returns:
The hex string

cArrayToString

public static java.lang.String cArrayToString(byte[] data,
                                              int offset)
                                       throws java.io.UnsupportedEncodingException
Method to convert a null terminated C string into a java string using the DEFAULT_ENCODING

Parameters:
data - An array of bytes containing a C string
offset - An offset from which to start to read the string from the data array
Returns:
A java string representig a null terminated C string
Throws:
java.io.UnsupportedEncodingException - if the encoding is not supported

cArrayToString

public static java.lang.String cArrayToString(byte[] data,
                                              int offset,
                                              java.lang.String enc)
                                       throws java.io.UnsupportedEncodingException
Method to convert a null terminated C string into a java string using the defined encoding

Parameters:
data - An array of bytes containing a C string
offset - An offset from which to start to read the string from the data array
enc - A encoding as defined in java.lang.String
Returns:
A java string representig a null terminated C string
Throws:
java.io.UnsupportedEncodingException - if the encoding is not supported