Overview | Package | Class | Tree | Deprecated | Index | Help
| SOA © 2004 SoS Group All Rights Reserved
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## sos.koa
Class Hex

    java.lang.Object
      sos.koa.Hex

public class Hex
extends java.lang.Object

Some static helper methods for dealing with hexadecimal notation.

Version:
  $Id: Hex.java,v 1.2 2004/05/04 19:51:52 martijno Exp $
Author:
  Martijn Oostdijk (martijno@cs.kun.nl)

Constructor Summary
`private` | `Hex()` This private constructor makes it impossible to create instances of this class.

Method Summary
`static java.lang.String` | `bytesToHexString(byte[] text)` Converts a byte array to capitalized hexadecimal text.
`static java.lang.String` | `bytesToHexString(byte[] text, int offset, int length)` Converts part of a byte array to capitalized hexadecimal text.
`static java.lang.String` | `byteToHexString(int n)` Converts the byte `n` to capitalized hexadecimal text.
`private static int` | `hexCharToInt(char c)` Interprets the character `c` as hexadecimal digit.
`static byte[]` | `hexStringToBytes(java.lang.String text)` Converts the hexadecimal string in `text` to a byte array.
`static short` | `hexStringToShort(java.lang.String text)`
`static java.lang.String` | `intToHexString(int n)` Converts the integer `n` to capitalized hexadecimal text.
`static java.lang.String` | `shortToHexString(int n)` Converts the short `n` to capitalized hexadecimal text.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Hex

    private Hex()

  This private constructor makes it impossible to create instances of this class.

Method Detail

### byteToHexString

    public static java.lang.String byteToHexString(int n)

  Converts the byte `n` to capitalized hexadecimal text.

  Parameters:
    `n` - The byte to convert.
  Returns:
    Capitalized hexadecimal text representation of `n`.

### shortToHexString

    public static java.lang.String shortToHexString(int n)

  Converts the short `n` to capitalized hexadecimal text.

  Parameters:
    `n` - The short to convert.
  Returns:
    Capitalized hexadecimal text representation of `n`.

### intToHexString

    public static java.lang.String intToHexString(int n)

  Converts the integer `n` to capitalized hexadecimal text.

  Parameters:
    `n` - The integer to convert.
  Returns:
    Capitalized hexadecimal text representation of `n`.

### bytesToHexString

    public static java.lang.String bytesToHexString(byte[] text)

  Converts a byte array to capitalized hexadecimal text.

  Parameters:
    `text` - The byte array to convert.
  Returns:
    Capitalized hexadecimal text representation of `text`.

### bytesToHexString

    public static java.lang.String bytesToHexString(byte[] text,
                                                    int offset,
                                                    int length)

  Converts part of a byte array to capitalized hexadecimal text. Conversion starts at index `offset` until (excluding) index `offset+length`.

  Parameters:
    `text` - The byte array to convert.
    `offset` - Where to start.
    `length` - How many bytes to convert.
  Returns:
    Capitalized hexadecimal text representation of `text`.

### hexStringToShort

    public static short hexStringToShort(java.lang.String text)
                                  throws java.lang.NumberFormatException

  Throws:
    `java.lang.NumberFormatException`

### hexStringToBytes

    public static byte[] hexStringToBytes(java.lang.String text)
                                   throws java.lang.NumberFormatException

  Converts the hexadecimal string in `text` to a byte array. If `text` has an odd number of characters, a `0` is inserted at the beginning.

  Parameters:
    `text` - The string to convert.
  Returns:
    The byte array representation of the hexadecimal string in `text`.
  Throws:
    `java.lang.NumberFormatException`

### hexCharToInt

    private static int hexCharToInt(char c)
                             throws java.lang.NumberFormatException

  Interprets the character `c` as hexadecimal digit.

  Parameters:
    `c` - A character from `0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F`.
  Returns:
    The decimal-hexadecimal digit interpretation of `c`.
  Throws:
    `java.lang.NumberFormatException`

Overview | Package | Class | Tree | Deprecated | Index | Help
| SOA © 2004 SoS Group All Rights Reserved
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD