private void enlargeBuffer()
 {
     java.nio.CharBuffer newBuf = java.nio.CharBuffer.allocate(cBuf.capacity() * 2);
     newBuf.put((char[])cBuf.array(), cBuf.arrayOffset(), cBuf.position());
     cBuf = newBuf;
     //ThreadLocalCache.charBuffer.set(cBuf);
 }
Esempio n. 2
0
 /*
  * original output is full and doesn't have remaining. allocate more space
  * to new CharBuffer and return it, the contents in the given buffer will be
  * copied into the new buffer.
  */
 private java.nio.CharBuffer allocateMore(java.nio.CharBuffer output)
 {
     if (output.capacity() == 0)
     {
         return(java.nio.CharBuffer.allocate(1));
     }
     java.nio.CharBuffer result = java.nio.CharBuffer.allocate(output.capacity() * 2);
     output.flip();
     result.put(output);
     return(result);
 }
Esempio n. 3
0
        protected override java.nio.charset.CoderResult decodeLoop(java.nio.ByteBuffer inJ, java.nio.CharBuffer outJ)
        {
            Encoding enc = this.cs.getEncoding();

            byte[] input = new byte[inJ.remaining()];
            inJ.get(input);
            char[] output = new char[input.Length * CharsetEncoderImpl.fiveValue];
            int    size   = enc.GetDecoder().GetChars(input, 0, input.Length, output, 0, true);

            outJ.put(output, 0, size);
            return(java.nio.charset.CoderResult.UNDERFLOW);
        }
Esempio n. 4
0
        /**
         * Reads characters and puts them into the {@code target} character buffer.
         *
         * @param target
         *            the destination character buffer.
         * @return the number of characters put into {@code target} or -1 if the end
         *         of this reader has been reached before a character has been read.
         * @throws IOException
         *             if any I/O error occurs while reading from this reader.
         * @throws NullPointerException
         *             if {@code target} is {@code null}.
         * @throws ReadOnlyBufferException
         *             if {@code target} is read-only.
         */
        public virtual int read(java.nio.CharBuffer target)// throws IOException
        {
            if (null == target)
            {
                throw new java.lang.NullPointerException();
            }
            int length = target.length();

            char[] buf = new char[length];
            length = java.lang.Math.min(length, read(buf));
            if (length > 0)
            {
                target.put(buf, 0, length);
            }
            return(length);
        }