Decode the contents of the input ByteBuffer into a CharBuffer.

@param endOfInput indicates end of input
@throws IOException if an I/O error occurs
970371
private void processInput(boolean endOfInput) throws IOException {
        // Prepare decoderIn for reading
        decoderIn.flip();
        CoderResult coderResult;
        while (true) {
            coderResult = decoder.decode(decoderIn, decoderOut, endOfInput);
            if (coderResult.isOverflow()) {
                flushOutput();
            } else if (coderResult.isUnderflow()) {
                break;
            } else {
                // The decoder is configured to replace malformed input and unmappable characters,
                // so we should not get here.
                throw new IOException("Unexpected coder result");
            }
        }
        // Discard the bytes that have been read
        decoderIn.compact();
    }
239003
private static void check(byte[] encoding) throws IOException {
        int length = encoding.length;
        if (length < 1 ||      // too short
                (encoding[length - 1] & 0x80) != 0) {  // not ended
            throw new IOException("ObjectIdentifier() -- " +
                    "Invalid DER encoding, not ended");
        }
        for (int i=0; i<length; i++) {
            // 0x80 at the beginning of a subidentifier
            if (encoding[i] == (byte)0x80 &&
                    (i==0 || (encoding[i-1] & 0x80) == 0)) {
                throw new IOException("ObjectIdentifier() -- " +
                        "Invalid DER encoding, useless extra octet detected");
            }
        }
    }
806506
private void skipToEndOfLine() throws IOException {
        while (pos < limit || fillBuffer(1)) {
            char c = buffer[pos++];
            if (c == '\r' || c == '\n') {
                break;
            }
        }
    }
656705
public void decode(InputStream is, OutputStream os) throws IOException {
	   int read, idx=0;
	   int prev=0, index;
	   	while((read = is.read())>=0) {
	   		index = convert.convert(read);
	   		if(index>=0) {
	    		switch(++idx) { // 1 based cases, slightly faster ++
	    			case 1: // index goes into first 6 bits of prev
	    				prev = index<<2; 
	    				break;
	    			case 2: // write second 2 bits of into prev, write byte, last 4 bits go into prev
	    				os.write((byte)(prev|(index>>4)));
	    				prev = index<<4;
	    				break;
	    			case 3: // first 4 bits of index goes into prev, write byte, last 2 bits go into prev
	    				os.write((byte)(prev|(index>>2)));
	    				prev = index<<6;
	    				break;
	    			default: // (3+) | prev and last six of index
	    				os.write((byte)(prev|(index&0x3F)));
	    				idx = prev = 0;
	    		}
	   		}
	   	};
	   	os.flush();
   }
922409
public final byte[] decode(String in) {

        // sanitize the parameters
        if (in == null) {
            throw new NullPointerException();
        }

        // create the result buffer
        byte[] out = new byte[in.length() * bits / 8];

        // decode
        int outCount = 0; // number of output bytes produced
        int inCount = 0; // number of input characters consumed
        int buf = 0; // buffer of input bits not yet sent to output
        int bufBits = 0; // number of bits in the bit buffer
        while (inCount < in.length()) {
            int next = in.codePointAt(inCount);
            inCount++;
            if (next < min || next > max) {
                continue;
            }
            next = values[next - min];
            if (next == -1) {
                continue;
            }
            buf = (buf << bits) | next;
            bufBits += bits;
            while (bufBits >= 8) {
                out[outCount] = (byte) ((buf >>> (bufBits - 8)) & 0xff);
                bufBits -= 8;
                outCount++;
            }
        }

        // trim the result if there were any skipped characters
        if (outCount < out.length) {
            byte[] tmp = out;
            out = new byte[outCount];
            System.arraycopy(tmp, 0, out, 0, outCount);
        }
        return out;
    }
155241
private void fillBuffer() throws IOException {
        if (!endOfInput && (lastCoderResult == null || lastCoderResult.isUnderflow())) {
            encoderIn.compact();
            int position = encoderIn.position();
            // We don't use Reader#read(CharBuffer) here because it is more efficient
            // to write directly to the underlying char array (the default implementation
            // copies data to a temporary char array).
            int c = reader.read(encoderIn.array(), position, encoderIn.remaining());
            if (c == -1) {
                endOfInput = true;
            } else {
                encoderIn.position(position + c);
            }
            encoderIn.flip();
        }
        encoderOut.compact();
        lastCoderResult = encoder.encode(encoderIn, encoderOut, endOfInput);
        encoderOut.flip();
    }
944882
public void readExternal(ObjectInput in) throws IOException {
        type = in.readByte();
        object = readInternal(type, in);
    }
108375
public static void decodeSingle(final byte[] input, final int inoff,
                                    final byte[] output, final int outoff) {

        if (output == null) {
            throw new NullPointerException("output");
        }

        if (outoff < 0) {
            throw new IllegalArgumentException("outoff(" + outoff + ") < 0");
        }

        if (outoff >= output.length) {
            throw new IllegalArgumentException(
                "outoff(" + outoff + ") >= output.length(" + output.length
                + ")");
        }

        output[outoff] = (byte) decodeSingle(input, inoff);
    }
523365
private boolean decodeBulkStringContent(ByteBuf in, List<Object> out) throws Exception {
        final int readableBytes = in.readableBytes();
        if (readableBytes == 0 || remainingBulkLength == 0 && readableBytes < RedisConstants.EOL_LENGTH) {
            return false;
        }

        // if this is last frame.
        if (readableBytes >= remainingBulkLength + RedisConstants.EOL_LENGTH) {
            ByteBuf content = in.readSlice(remainingBulkLength);
            readEndOfLine(in);
            // Only call retain after readEndOfLine(...) as the method may throw an exception.
            out.add(new DefaultLastBulkStringRedisContent(content.retain()));
            resetDecoder();
            return true;
        }

        // chunked write.
        int toRead = Math.min(remainingBulkLength, readableBytes);
        remainingBulkLength -= toRead;
        out.add(new DefaultBulkStringRedisContent(in.readSlice(toRead).retain()));
        return true;
    }
413388
public int decode(final InputStream stream, final ByteBuffer buffer) throws IOException {
        if (reachedEOF) {
            return -1;
        }

        // TODO: Don't decode more than single runs, because some writers add pad bytes inside the stream...
        while (buffer.hasRemaining()) {
            int n;
            
            if (splitRun) {
                // Continue run
                n = leftOfRun;
                splitRun = false;
            }
            else {
                // Start new run
                int b = stream.read();
                if (b < 0) {
                    reachedEOF = true;
                    break;
                }
                n = (byte) b;
            }

            // Split run at or before max
            if (n >= 0 && n + 1 > buffer.remaining()) {
                leftOfRun = n;
                splitRun = true;
                break;
            }
            else if (n < 0 && -n + 1 > buffer.remaining()) {
                leftOfRun = n;
                splitRun = true;
                break;
            }

            try {
                if (n >= 0) {
                    // Copy next n + 1 bytes literally
                    readFully(stream, buffer, sample.length * (n + 1));
                }
                // Allow -128 for compatibility, see above
                else if (disableNoOp || n != -128) {
                    // Replicate the next byte -n + 1 times
                    for (int s = 0; s < sample.length; s++) {
                        sample[s] = readByte(stream);
                    }

                    for (int i = -n + 1; i > 0; i--) {
                        buffer.put(sample);
                    }
                }
                // else NOOP (-128)
            }
            catch (IndexOutOfBoundsException e) {
                throw new DecodeException("Error in PackBits decompression, data seems corrupt", e);
            }
        }

        return buffer.position();
    }
5851
public static byte[] decodeToBytes(CharSequence in) throws IOException{
		if(in == null) return null;
		ByteArrayOutputStream baos = new ByteArrayOutputStream(in.length());
		decode(in, baos);
		return baos.toByteArray();
	}
756390
private byte[] decode(byte[] input) throws DecoderException
    {
        if (decoder != null)
        {
            return decoder.decode(input);
        }
        else
        {
            return DEFAULT_CODER.decode(input);
        }
    }
982449
@Override
    public void readExternal(ObjectInput s) throws IOException, ClassNotFoundException {
        String type = (String) s.readObject();
        String endian = (String) s.readObject();

        // read in serialized data
        byte[] bytes = (byte[]) s.readObject();

        if (type.equals("ND")) {
            // wrap the bytes into a non-direct buffer. We don't want to
            // get the ByteBuffer from the pool since we would have to copy the
            // bytes from this byte array into the new ByteBuffer.
            // wrap will use a non-direct ByteBuffer
            this.oByteBuffer = ByteBuffer.wrap(bytes);
            if (endian.equals("B")) {
                this.oByteBuffer.order(java.nio.ByteOrder.BIG_ENDIAN);
            } else {
                this.oByteBuffer.order(java.nio.ByteOrder.LITTLE_ENDIAN);
            }
        } else {
            // allocate a Direct Buffer. Do not allocate from a pool since
            // determining the code responsible for releasing the buffer is
            // not clear.
            this.oByteBuffer = ByteBuffer.allocateDirect(bytes.length);

            // Set endian before reading from the buffer
            if (endian.equals("B")) {
                this.oByteBuffer.order(java.nio.ByteOrder.BIG_ENDIAN);
            } else {
                this.oByteBuffer.order(java.nio.ByteOrder.LITTLE_ENDIAN);
            }
            this.oByteBuffer.put(bytes);
        }

        this.oByteBuffer.position(Integer.parseInt((String) s.readObject()));
        this.oByteBuffer.limit(Integer.parseInt((String) s.readObject()));

        String rOnly = (String) s.readObject();
        if (rOnly.equals("R")) {
            this.readOnly = true;
        } else {
            this.readOnly = false;
        }

        // 262860 New buffer will need the Pool Manager for duplicates/slices
        this.oWsByteBufferPoolManager = (WsByteBufferPoolManagerImpl) WsByteBufferPoolManagerImpl.getRef();
        this.trusted = this.oWsByteBufferPoolManager.isTrustedUsers();

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "readExternal:  trusted set to: " + this.trusted);
        }
        // If we can serialize, then this was/is true.
        this.removedFromLeakDetection = true;
    }
184536
@Override
    public void decode(byte[] bytes, StringBuilder buffer) {
        if (bytes == null) {
            // append nothing
            return;
        }

        char[] table = CHAR_TABLE;
        for (int i = 0; i < bytes.length; i++) {
            int code = (int)bytes[i] & 0x000000ff;
            if (code == EXTENDED_ESCAPE) {
                // take next char from extension table
                table = EXT_CHAR_TABLE;
            } else {
                buffer.append((code >= table.length) ? '?' : table[code]);
                // go back to the default table
                table = CHAR_TABLE;
            }
        }
    }
255081
@Override
  public void readFully(byte[] b) throws IOException {
    if (inner.read(b) < b.length) {
      throw new EOFException();
    }
  }
19114
public static long readUnsignedIntegerLittleEndian(InputStream io) throws IOException {
		long value = io.read();
		if (value < 0) throw new EOFException();
		int i = io.read();
		if (i < 0) throw new EOFException();
		value |= i << 8;
		i = io.read();
		if (i < 0) throw new EOFException();
		value |= i << 16;
		i = io.read();
		if (i < 0) throw new EOFException();
		value |= ((long)i) << 24;
		return value;
	}
907586
public static char bigChar(InputStream input) throws IOException {
        int hi = input.read();
        if (hi < 0) {
            throw new EOFException();
        }
        int lo = input.read();
        if (lo < 0) {
            throw new EOFException();
        }
        return (char)((hi << 8) | lo);
    }