package com.drew.lang;

public class ByteUtil
{
    public static int getInt16(byte[] buffer, int offset, boolean bigEndian)
    {
        if (bigEndian) {
            return
                ((buffer[offset    ] & 0xFF) << 8) |
                ((buffer[offset + 1] & 0xFF)     );
        } else {
            return
                ((buffer[offset    ] & 0xFF)     ) |
                ((buffer[offset + 1] & 0xFF) << 8);
        }
    }

    public static int getInt32(byte[] buffer, int offset, boolean bigEndian)
    {
        if (bigEndian) {
            return
                ((buffer[offset    ] & 0xFF) << 24) |
                ((buffer[offset + 1] & 0xFF) << 16) |
                ((buffer[offset + 2] & 0xFF) <<  8) |
                ((buffer[offset + 3] & 0xFF));
        } else {
            return
                ((buffer[offset    ] & 0xFF)      ) |
                ((buffer[offset + 1] & 0xFF) <<  8) |
                ((buffer[offset + 2] & 0xFF) << 16) |
                ((buffer[offset + 3] & 0xFF) << 24);
        }
    }

    public static long getLong64(byte[] buffer, int offset, boolean bigEndian)
    {
        if (bigEndian) {
            return
                ((buffer[offset    ] & 0xFF) << 56) |
                ((buffer[offset + 1] & 0xFF) << 48) |
                ((buffer[offset + 2] & 0xFF) << 40) |
                ((buffer[offset + 3] & 0xFF) << 32) |
                ((buffer[offset + 4] & 0xFF) << 24) |
                ((buffer[offset + 5] & 0xFF) << 16) |
                ((buffer[offset + 6] & 0xFF) <<  8) |
                ((buffer[offset + 7] & 0xFF));

        } else {
            return
                ((buffer[offset    ] & 0xFF)      ) |
                ((buffer[offset + 1] & 0xFF) <<  8) |
                ((buffer[offset + 2] & 0xFF) << 16) |
                ((buffer[offset + 3] & 0xFF) << 24) |
                ((buffer[offset + 4] & 0xFF) << 32) |
                ((buffer[offset + 5] & 0xFF) << 40) |
                ((buffer[offset + 6] & 0xFF) << 48) |
                ((buffer[offset + 7] & 0xFF) << 56);
        }
    }

    public static long getUnsignedInt32(byte[] buffer, int offset, boolean bigEndian)
    {
        int firstByte = (0x000000FF & ((int)buffer[offset]));
        int secondByte = (0x000000FF & ((int)buffer[offset+1]));
        int thirdByte = (0x000000FF & ((int)buffer[offset+2]));
        int fourthByte = (0x000000FF & ((int)buffer[offset+3]));

        return ((long) (firstByte << 24
            | secondByte << 16
            | thirdByte << 8
            | fourthByte))
            & 0xFFFFFFFFL;

    }

    public static long getLong32(byte[] buffer, int offset, boolean bigEndian)
    {
        if (bigEndian) {
            return (buffer[offset] << 24 & 0xFF000000) |
                (buffer[offset + 1] << 16 & 0xFF0000) |
                (buffer[offset + 2] << 8 & 0xFF00) |
                (buffer[offset + 3] & 0xFF);
        } else {
            return (buffer[offset + 3] << 24 & 0xFF000000) |
                (buffer[offset + 2] << 16 & 0xFF0000) |
                (buffer[offset + 1] << 8 & 0xFF00) |
                (buffer[offset] & 0xFF);
        }
    }
}

@@ -2076,1084 +2076,7 @@
    %7D
-%0A%0A    public static long getUnsignedInt32(byte%5B%5D buffer, int offset, boolean bigEndian)%0A    %7B%0A        int firstByte = (0x000000FF & ((int)buffer%5Boffset%5D));%0A        int secondByte = (0x000000FF & ((int)buffer%5Boffset+1%5D));%0A        int thirdByte = (0x000000FF & ((int)buffer%5Boffset+2%5D));%0A        int fourthByte = (0x000000FF & ((int)buffer%5Boffset+3%5D));%0A%0A        return ((long) (firstByte %3C%3C 24%0A            %7C secondByte %3C%3C 16%0A            %7C thirdByte %3C%3C 8%0A            %7C fourthByte))%0A            & 0xFFFFFFFFL;%0A%0A    %7D%0A%0A    public static long getLong32(byte%5B%5D buffer, int offset, boolean bigEndian)%0A    %7B%0A        if (bigEndian) %7B%0A            return (buffer%5Boffset%5D %3C%3C 24 & 0xFF000000) %7C%0A                (buffer%5Boffset + 1%5D %3C%3C 16 & 0xFF0000) %7C%0A                (buffer%5Boffset + 2%5D %3C%3C 8 & 0xFF00) %7C%0A                (buffer%5Boffset + 3%5D & 0xFF);%0A        %7D else %7B%0A            return (buffer%5Boffset + 3%5D %3C%3C 24 & 0xFF000000) %7C%0A                (buffer%5Boffset + 2%5D %3C%3C 16 & 0xFF0000) %7C%0A                (buffer%5Boffset + 1%5D %3C%3C 8 & 0xFF00) %7C%0A                (buffer%5Boffset%5D & 0xFF);%0A        %7D%0A    %7D
 %0A%7D%0A

Remove unused methods