com.legstar.coxb.host
Class HostData

java.lang.Object
  extended by com.legstar.coxb.host.HostData

public class HostData
extends Object

Represents a generic host data content. Mainly a wrapper over a byte array.

Author:
Fady Moussallam

Constructor Summary
HostData(byte[] hostData)
          Contructor from existing host data.
HostData(String hexString)
          Contructor from a hexadecimal String.
 
Method Summary
 byte[] getHostData()
           
 int length()
           
static byte[] toByteArray(String string)
          Helper method to populate a byte array from a hex string representation.
 String toHexString()
          Helper method to dump field content in hexadecimal.
static String toHexString(byte[] hostBytes)
          Helper method to dump field content in hexadecimal.
static String toHexString(byte[] hostBytes, int maxBytes)
          Another pretty printing method but with a limit to the number of bytes printed.
static String toHexString(byte[] hostBytes, int start, int length)
          Helper method to dump field content in hexadecimal.
static String toHexString(byte[] hostBytes, int start, int length, int maxBytes)
          Another pretty printing method but with a limit to the number of bytes printed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HostData

public HostData(byte[] hostData)
Contructor from existing host data.

Parameters:
hostData - byte array representing host field content

HostData

public HostData(String hexString)
Contructor from a hexadecimal String.

Parameters:
hexString - A string of hex representations
Method Detail

toHexString

public String toHexString()
Helper method to dump field content in hexadecimal.

Returns:
a string with hexadecimal representation of the field content

toHexString

public static String toHexString(byte[] hostBytes)
Helper method to dump field content in hexadecimal.

Parameters:
hostBytes - a byte array to get hexadecimal representation for
Returns:
a string with hexadecimal representation of the field content

toHexString

public static String toHexString(byte[] hostBytes,
                                 int start,
                                 int length)
Helper method to dump field content in hexadecimal.

Parameters:
hostBytes - a byte array to get hexadecimal representation for
start - 0-based position of first byte to dump
length - number of bytes to dump
Returns:
a string with hexadecimal representation of the field content

toHexString

public static String toHexString(byte[] hostBytes,
                                 int maxBytes)
Another pretty printing method but with a limit to the number of bytes printed. This method will print an even number of starting and ending bytes leaving a gap between them.

Parameters:
hostBytes - byte array to print
maxBytes - maximum number of bytes to process
Returns:
a pretty string

toHexString

public static String toHexString(byte[] hostBytes,
                                 int start,
                                 int length,
                                 int maxBytes)
Another pretty printing method but with a limit to the number of bytes printed. This method will print an even number of starting and ending bytes leaving a gap between them.

Parameters:
hostBytes - byte array to print
start - 0-based position of first byte to dump
length - total number of bytes to dump
maxBytes - maximum number of bytes to process
Returns:
a pretty string

toByteArray

public static byte[] toByteArray(String string)
Helper method to populate a byte array from a hex string representation.

Parameters:
string - a string of hexadecimal characters to be turned into a byte array
Returns:
an initialized byte array

getHostData

public byte[] getHostData()
Returns:
Returns the hostData.

length

public int length()
Returns:
Returns the hostData length.


Copyright © 2015 LegSem. All Rights Reserved.