## org.apache.poi.contrib.poibrowser
Class Codec

    java.lang.Object
      org.apache.poi.contrib.poibrowser.Codec

public class Codec
extends java.lang.Object

Provides utility methods for encoding and decoding hexadecimal data.

Since:
  2002-01-24
Version:
  $Id: Codec.java,v 1.3.4.1 2004/02/22 11:22:14 glens Exp $
Author:
  Rainer Klute (klute@rainer-klute.de) - with portions from Tomcat

Field Summary
`protected static byte[]` `hexval` The nibbles' hexadecimal values.

Constructor Summary
`Codec()`

Method Summary
`protected static byte` `decodeNibble(char c)` Decodes a nibble.
`static byte[]` `hexDecode(java.lang.String s)` Decodes the hexadecimal representation of a sequence of bytes into a byte array.
`static java.lang.String` `hexEncode(byte b)` Converts a single byte into its hexadecimal notation.
`static java.lang.String` `hexEncode(byte[] s)` Converts a byte array into its hexadecimal notation.
`static java.lang.String` `hexEncode(byte[] s, int offset, int length)` Converts a part of a byte array into its hexadecimal notation.
`static java.lang.String` `hexEncode(ClassID classID)` Converts a class ID into its hexadecimal notation.
`static java.lang.String` `hexEncode(int i)` Converts an int value (32-bit) into its hexadecimal notation.
`static java.lang.String` `hexEncode(long l)` Converts a long value (64-bit) into its hexadecimal notation.
`static java.lang.String` `hexEncode(short s)` Converts a short value (16-bit) into its hexadecimal notation.
`static java.lang.String` `hexEncode(java.lang.String s)` Converts a string into its hexadecimal notation.
`static void` `main(java.lang.String[] args)` For testing.

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

Field Detail

### hexval

    protected static final byte[] hexval

  The nibbles' hexadecimal values. A nibble is a half byte.

Constructor Detail

### Codec

    public Codec()

Method Detail

### hexEncode

    public static java.lang.String hexEncode(java.lang.String s)

  Converts a string into its hexadecimal notation.

  FIXME: If this method is called frequently, it should directly implement the algorithm in the called method in order to avoid creating a string instance.

### hexEncode

    public static java.lang.String hexEncode(byte[] s)

  Converts a byte array into its hexadecimal notation.

### hexEncode

    public static java.lang.String hexEncode(byte[] s,
                                             int offset,
                                             int length)

  Converts a part of a byte array into its hexadecimal notation.

### hexEncode

    public static java.lang.String hexEncode(byte b)

  Converts a single byte into its hexadecimal notation.

### hexEncode

    public static java.lang.String hexEncode(short s)

  Converts a short value (16-bit) into its hexadecimal notation.

### hexEncode

    public static java.lang.String hexEncode(int i)

  Converts an int value (32-bit) into its hexadecimal notation.

### hexEncode

    public static java.lang.String hexEncode(long l)

  Converts a long value (64-bit) into its hexadecimal notation.

### hexEncode

    public static java.lang.String hexEncode(ClassID classID)

  Converts a class ID into its hexadecimal notation.

### hexDecode

    public static byte[] hexDecode(java.lang.String s)

  Decodes the hexadecimal representation of a sequence of bytes into a byte array. Each character in the string represents a nibble (half byte) and must be one of the characters '0'-'9', 'A'-'F' or 'a'-'f'.

  Parameters:
    `s` - The string to be decoded
  Returns:
    The bytes

### decodeNibble

    protected static byte decodeNibble(char c)

  Decodes a nibble.

  Parameters:
    `c` - A character in the range '0'-'9' or 'A'-'F'. Lower case is not supported here.
  Returns:
    The decoded nibble in the range 0-15
  Throws:
    `java.lang.IllegalArgumentException` - if c is not a permitted character

### main

    public static void main(java.lang.String[] args)
                     throws java.io.IOException

  For testing.

  Throws:
    `java.io.IOException`

Copyright © 2003 Apache Software Foundation.