net.sourceforge.jmodbus
Class ByteUtils

java.lang.Object
  |
  +--net.sourceforge.jmodbus.ByteUtils

public class ByteUtils
extends java.lang.Object

This class contains basic utilities for dumping byte arrays to standout oputput. These are probably implemented somewhere in in the java API, but I can't find where. This class does not use string is a particulary efficient and may have a sever performace impact on small footprint machines that do not handle string well, such as a Dalllas Semi TINI.


Constructor Summary
ByteUtils()
           
 
Method Summary
static java.lang.String toHex(byte b)
          Convert a single byte into a string representation of the byte as two hexadecimal characters.
static java.lang.String toHex(byte[] b, int length)
          Convert a byte array into a string hex dump of the bytes with a coulmn width of 8 bytes and a 2 byte offset number printed on the side.
static java.lang.String toHex(short s)
          Convert a single short into a string representation of the short as four hexadecimal characters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteUtils

public ByteUtils()
Method Detail

toHex

public static java.lang.String toHex(byte b)
Convert a single byte into a string representation of the byte as two hexadecimal characters.
Parameters:
b - The byte to convert
Returns:
String representation of the input byte.

toHex

public static java.lang.String toHex(short s)
Convert a single short into a string representation of the short as four hexadecimal characters.
Parameters:
s - The short to convert
Returns:
String representation of the input short.

toHex

public static java.lang.String toHex(byte[] b,
                                     int length)
Convert a byte array into a string hex dump of the bytes with a coulmn width of 8 bytes and a 2 byte offset number printed on the side. This function will add the required new line characters.
Parameters:
b - The byte array to dump
length - The length of the array that is required to be dumped
Returns:
String representation of the input byte array.