@@ -0,0 +1,2220 @@
+package dk.statsbiblioteket.util;%0A%0Aimport dk.statsbiblioteket.util.qa.QAInfo;%0A%0Aimport java.io.IOException;%0A%0A/**%0A * Utillity class for working with bytes, bytearrays, and strings.%0A */%0A@QAInfo(level = QAInfo.Level.NORMAL,%0A        state = QAInfo.State.IN_DEVELOPMENT,%0A        author = %22kfc, mke%22,%0A        reviewers = %7B%22abr, mke%22%7D)%0Apublic class Bytes %7B%0A    /**%0A     * The hexidecimal characters in numeric order from %7B@code 0-f%7D%0A     */%0A    public static final char%5B%5D HEX_DIGITS =%0A            %7B'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',%0A                'a', 'b', 'c', 'd', 'e', 'f'%7D;%0A%0A    /** The number of bits in a nibble (used for shifting). */%0A    private static final byte BITS_IN_NIBBLE = 4;%0A    /** A bitmask for a nibble (used for %22and'ing%22 out the bits. */%0A    private static final byte BITMASK_FOR_NIBBLE = 0x0f;%0A%0A    /** Utility class, don't initialise. */%0A    private Bytes() %7B%0A    %7D%0A%0A    /**%0A     * Converts a byte array to a hex-string.%0A     *%0A     * @param ba the bytearray to be converted%0A     * @return ba the byte array to convert to a hex-string%0A     */%0A    public static String toHex(final byte%5B%5D ba) %7B%0A        StringBuilder sb = new StringBuilder(ba.length * 2);%0A        try %7B%0A            toHex(sb, ba);%0A        %7D catch (IOException e) %7B%0A            throw new RuntimeException(%0A                    %22Unexpected IOException while appending to StringBuilder%22);%0A        %7D%0A%0A        return sb.toString();%0A    %7D%0A%0A    /**%0A     * Converts a byte array to a hex-string and write the result to an%0A     * %7B@code Appendable%7D (such as a %7B@code StringBuilder%7D).%0A     *%0A     * @param buf the appendable to write to%0A     * @param ba the byte array to convert to a hex-string%0A     * @return always returns %7B@code buf%7D%0A     * @throws IOException upon errors writing to %7B@code buf%7D%0A     */%0A    public static Appendable toHex(Appendable buf, byte%5B%5D ba)%0A                                                            throws IOException %7B%0A        int baLen = ba.length;%0A        for (int i = 0; i %3C baLen; i++) %7B%0A            buf.append(%0A                    HEX_DIGITS%5B(ba%5Bi%5D %3E%3E BITS_IN_NIBBLE) & BITMASK_FOR_NIBBLE%5D);%0A            buf.append(HEX_DIGITS%5Bba%5Bi%5D & BITMASK_FOR_NIBBLE%5D);%0A        %7D%0A%0A        return buf;%0A    %7D%0A%0A%0A%7D%0A

Rename ByteString to Bytes