com.eaio.util.lang
Class Hex

java.lang.Object
  extended by com.eaio.util.lang.Hex

public final class Hex
extends Object

Number-to-hexadecimal and hexadecimal-to-number conversions.

Version:
$Id: Hex.java 1888 2009-03-15 12:43:24Z johann $
Author:
Johann Burkard
See Also:
UUID

Method Summary
static Appendable append(Appendable a, byte[] bytes)
          Turns a byte array into hex octets.
static Appendable append(Appendable a, int in)
          Turns an int into hex octets.
static Appendable append(Appendable a, int in, int length)
          Turns an int into hex octets.
static Appendable append(Appendable a, long in)
          Turns a long into hex octets.
static Appendable append(Appendable a, long in, int length)
          Turns a long into hex octets.
static Appendable append(Appendable a, short in)
          Turns a short into hex octets.
static Appendable append(Appendable a, short in, int length)
          Turns a short into hex octets.
static long parseLong(CharSequence s)
          Parses a long from a hex encoded number.
static short parseShort(String s)
          Parses a short from a hex encoded number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

append

public static Appendable append(Appendable a,
                                short in)
Turns a short into hex octets.

Parameters:
a - the Appendable, may not be null
in - the integer
Returns:
Appendable

append

public static Appendable append(Appendable a,
                                short in,
                                int length)
Turns a short into hex octets.

Parameters:
a - the Appendable, may not be null
in - the integer
length - the number of octets to produce
Returns:
Appendable

append

public static Appendable append(Appendable a,
                                int in)
Turns an int into hex octets.

Parameters:
a - the Appendable, may not be null
in - the integer
Returns:
Appendable

append

public static Appendable append(Appendable a,
                                int in,
                                int length)
Turns an int into hex octets.

Parameters:
a - the Appendable, may not be null
in - the integer
length - the number of octets to produce
Returns:
Appendable

append

public static Appendable append(Appendable a,
                                long in)
Turns a long into hex octets.

Parameters:
a - the Appendable, may not be null
in - the long
Returns:
Appendable

append

public static Appendable append(Appendable a,
                                long in,
                                int length)
Turns a long into hex octets.

Parameters:
a - the Appendable, may not be null
in - the long
length - the number of octets to produce
Returns:
Appendable

append

public static Appendable append(Appendable a,
                                byte[] bytes)
Turns a byte array into hex octets.

Parameters:
a - the Appendable, may not be null
bytes - the byte array
Returns:
Appendable

parseLong

public static long parseLong(CharSequence s)
Parses a long from a hex encoded number. This method will skip all characters that are not 0-9, A-F and a-f.

Returns 0 if the CharSequence does not contain any interesting characters.

Parameters:
s - the CharSequence to extract a long from, may not be null
Returns:
a long
Throws:
NullPointerException - if the CharSequence is null

parseShort

public static short parseShort(String s)
Parses a short from a hex encoded number. This method will skip all characters that are not 0-9, A-F and a-f.

Returns 0 if the CharSequence does not contain any interesting characters.

Parameters:
s - the CharSequence to extract a short from, may not be null
Returns:
a short
Throws:
NullPointerException - if the CharSequence is null


Copyright © 2003-2011. All Rights Reserved.