Examples of asCharBuffer()


Examples of java.nio.ByteBuffer.asCharBuffer()

     */
    public void testBufferView() {
        ByteBuffer b = ByteBuffer.allocateDirect(100);
        assertTrue(b.isDirect());
        assertView("duplicate", b, b.duplicate(), 1);
        assertView("char view", b, b.asCharBuffer(), 2);
        assertView("short view", b, b.asShortBuffer(), 2);
        assertView("int view", b, b.asIntBuffer(), 4);
        assertView("float view", b, b.asFloatBuffer(), 4);
        assertView("double view", b, b.asDoubleBuffer(), 8);
        assertView("long view", b, b.asLongBuffer(), 8);
View Full Code Here

Examples of java.nio.ByteBuffer.asCharBuffer()

        int returnCode = charsetMap.recode(lengths, collation, collationUTF16,
                byteBuffer, outputByteBuffer);
        switch (returnCode) {
            case CharsetMapConst.RecodeStatus.RECODE_OK:
                outputByteBuffer.limit(lengths[1]);
                CharBuffer charBuffer = outputByteBuffer.asCharBuffer();
                return charBuffer.toString();
            case CharsetMapConst.RecodeStatus.RECODE_BAD_CHARSET:
                throw new ClusterJFatalInternalException(local.message("ERR_Decode_Bad_Charset",
                        collation));
            case CharsetMapConst.RecodeStatus.RECODE_BAD_SRC:
View Full Code Here

Examples of java.nio.ByteBuffer.asCharBuffer()

        int returnCode = charsetMap.recode(lengths, collation, collationUTF16,
                inputByteBuffer, outputByteBuffer);
        switch (returnCode) {
            case CharsetMapConst.RecodeStatus.RECODE_OK:
                outputByteBuffer.limit(lengths[1]);
                CharBuffer charBuffer = outputByteBuffer.asCharBuffer();
                return charBuffer.toString();
            case CharsetMapConst.RecodeStatus.RECODE_BAD_CHARSET:
                throw new ClusterJFatalInternalException(local.message("ERR_Decode_Bad_Charset",
                        collation));
            case CharsetMapConst.RecodeStatus.RECODE_BAD_SRC:
View Full Code Here

Examples of java.nio.ByteBuffer.asCharBuffer()

     */
    public static ByteBuffer encodeToByteBuffer(CharSequence string, int collation, int prefixLength) {
        if (string == null) return null;
        int inputLength = (string.length() * 2);
        ByteBuffer inputByteBuffer = ByteBuffer.allocateDirect(inputLength);
        CharBuffer charBuffer = inputByteBuffer.asCharBuffer();
        charBuffer.append(string);
        int outputLength = (2 * inputLength) + prefixLength;
        ByteBuffer outputByteBuffer = ByteBuffer.allocateDirect(outputLength);
        outputByteBuffer.position(prefixLength);
        int[] lengths = new int[] {inputLength, outputLength - prefixLength};
View Full Code Here

Examples of java.nio.ByteBuffer.asCharBuffer()

       
        {
            out.println("     --> RECODE TEST 6: convert an actual java string to UTF-8");
            // Load the string into a ByteBuffer
            ByteBuffer str_bb = ByteBuffer.allocateDirect(16);
            CharBuffer cb = str_bb.asCharBuffer();
            cb.append("\u00FClker");
            cb.rewind();
            ByteBuffer result_buff       = ByteBuffer.allocateDirect(16);           
            int[] lengths = new int[]  { 12 , 16 };
View Full Code Here

Examples of java.nio.ByteBuffer.asCharBuffer()

        System.arraycopy(bytes, 0, buffer.array(), 0, 4);
        byte[] portBytes = new byte[2];
        System.arraycopy(bytes, 4, portBytes, 0, portBytes.length);
        try
        {
            CharBuffer charBuffer = buffer.asCharBuffer();
            String host = hostNames_.get(charBuffer);
            if (host == null)
            {              
                host = InetAddress.getByAddress(buffer.array()).getHostAddress();             
                hostNames_.put(charBuffer, host);
View Full Code Here

Examples of java.nio.ByteBuffer.asCharBuffer()

    tmpIntBuffer.put(checkBuffer);
    tmpBuffer.rewind();
    channel.write(tmpBuffer);
   
    tmpBuffer = ByteBuffer.allocate(tailBuffer.capacity() * 2);
    CharBuffer tmpCharBuffer = tmpBuffer.asCharBuffer();
    tmpCharBuffer.put(tailBuffer);
    tmpBuffer.rewind();
    channel.write(tmpBuffer);
   
    raf.close();
View Full Code Here

Examples of java.nio.ByteBuffer.asCharBuffer()

    trie.checkBuffer = tmpCheckBuffer.asIntBuffer().asReadOnlyBuffer();

    ByteBuffer tmpTailBuffer = ByteBuffer.allocateDirect(tailSize * 2);      // The size is 2 times the tailSize since it is the length of array
    channel.read(tmpTailBuffer);
    tmpTailBuffer.rewind();
    trie.tailBuffer = tmpTailBuffer.asCharBuffer().asReadOnlyBuffer();

    is.close();
    return trie;
  }
 
View Full Code Here

Examples of java.nio.ByteBuffer.asCharBuffer()

        ByteBuffer buffer = getTableBuffer(gaspTag);
        if (buffer == null) {
            return gaspTable = new char[0];
        }

        CharBuffer cbuffer = buffer.asCharBuffer();
        char format = cbuffer.get();
        /* format "1" has appeared for some Windows Vista fonts.
         * Its presently undocumented but the existing values
         * seem to be still valid so we can use it.
         */
 
View Full Code Here

Examples of java.nio.ByteBuffer.asCharBuffer()

   
    ShortBuffer sBuffer = buffer.asShortBuffer();
    sBuffer.position(1);
    System.out.println(Memory.getPosition(sBuffer));
   
    CharBuffer cBuffer = buffer.asCharBuffer();
    cBuffer.position(1);
    System.out.println(Memory.getPosition(cBuffer));
   
    IntBuffer iBuffer = buffer.asIntBuffer();
    iBuffer.position(1);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.