class ASCIIHexFilter extends Filter
{
    private static final Logger LOG = LogManager.getLogger(ASCIIHexFilter.class);

    private static final int[] REVERSE_HEX = {
      /*   0 */  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      /*  10 */  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      /*  20 */  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      /*  30 */  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      /*  40 */  -1, -1, -1, -1, -1, -1, -1, -1,  0,  1,
      /*  50 */   2,  3,  4,  5,  6,  7,  8,  9, -1, -1,
      /*  60 */  -1, -1, -1, -1, -1, 10, 11, 12, 13, 14,
      /*  70 */  15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      /*  80 */  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      /*  90 */  -1, -1, -1, -1, -1, -1, -1, 10, 11, 12,
      /* 100 */  13, 14, 15, -1, -1, -1, -1, -1, -1, -1,
      /* 110 */  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      /* 120 */  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      /* 130 */  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      /* 140 */  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      /* 150 */  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      /* 160 */  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      /* 170 */  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      /* 180 */  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      /* 190 */  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      /* 200 */  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      /* 210 */  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      /* 220 */  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      /* 230 */  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      /* 240 */  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
      /* 250 */  -1, -1, -1, -1, -1, -1
    };

    @Override
    public DecodeResult decode(InputStream encoded, OutputStream decoded,
                                         COSDictionary parameters, int index) throws IOException
    {
        int value, firstByte, secondByte;
        while ((firstByte = encoded.read()) != -1)
        {
            // always after first char
            while (isWhitespace(firstByte))
            {
                firstByte = encoded.read();
            }
            if (firstByte == -1 || isEOD(firstByte))
            {
                break;
            }
       
            if (REVERSE_HEX[firstByte] == -1)
            {
                LOG.error("Invalid hex, int: {} char: {}", firstByte, (char) firstByte);
            }
            value = REVERSE_HEX[firstByte] * 16;
            secondByte = encoded.read();
       
            if (secondByte == -1 || isEOD(secondByte)) 
            {
                // second value behaves like 0 in case of EOD
                decoded.write(value);
                break;
            }
            if (REVERSE_HEX[secondByte] == -1)
            {
                LOG.error("Invalid hex, int: {} char: {}", secondByte, (char) secondByte);
            }
            value += REVERSE_HEX[secondByte];
            decoded.write(value);
        }
        decoded.flush();
        return new DecodeResult(parameters);
    }

    // whitespace
    //   0  0x00  Null (NUL)
    //   9  0x09  Tab (HT)
    //  10  0x0A  Line feed (LF)
    //  12  0x0C  Form feed (FF)
    //  13  0x0D  Carriage return (CR)
    //  32  0x20  Space (SP)
    private static boolean isWhitespace(int c)
    {<FILL_FUNCTION_BODY>}

    private static boolean isEOD(int c)
    {
        return c == '>';
    }

    @Override
    public void encode(InputStream input, OutputStream encoded, COSDictionary parameters)
        throws IOException
    {
        int byteRead;
        while ((byteRead = input.read()) != -1)
        {
            Hex.writeHexByte((byte)byteRead, encoded);
        }
        encoded.flush();
    }
}

        switch (c)
        {
        case 0:
        case 9:
        case 10:
        case 12:
        case 13:
        case 32:
            return true;
        default:
            return false;
        }
    
<methods>public abstract org.apache.pdfbox.filter.DecodeResult decode(java.io.InputStream, java.io.OutputStream, org.apache.pdfbox.cos.COSDictionary, int) throws java.io.IOException,public org.apache.pdfbox.filter.DecodeResult decode(java.io.InputStream, java.io.OutputStream, org.apache.pdfbox.cos.COSDictionary, int, org.apache.pdfbox.filter.DecodeOptions) throws java.io.IOException,public static org.apache.pdfbox.io.RandomAccessRead decode(java.io.InputStream, List<org.apache.pdfbox.filter.Filter>, org.apache.pdfbox.cos.COSDictionary, org.apache.pdfbox.filter.DecodeOptions, List<org.apache.pdfbox.filter.DecodeResult>) throws java.io.IOException,public final void encode(java.io.InputStream, java.io.OutputStream, org.apache.pdfbox.cos.COSDictionary, int) throws java.io.IOException,public static final javax.imageio.ImageReader findImageReader(java.lang.String, java.lang.String) throws org.apache.pdfbox.filter.MissingImageReaderException,public static int getCompressionLevel() <variables>private static final Logger LOG,public static final java.lang.String SYSPROP_DEFLATELEVEL