Package java.nio.charset

Examples of java.nio.charset.CharsetDecoder.reset()


       
        us.clear();
        bs.clear();
       
        //test malform string
        decoder.reset();
        bs.put((byte)0xF5); bs.put((byte)0xB4); bs.put((byte)0x8A); bs.put((byte)0x8C);
        us.put((char)0x0000);
        bs2 = bs.asReadOnlyBuffer();
        us.limit(1);
        us.position(0);
View Full Code Here


        }
       
        bs.clear();
       
        //test overflow
        decoder.reset();
        bs.put((byte)0xF3); bs.put((byte)0xB4); bs.put((byte)0x8A); bs.put((byte)0x8C);
        bs2 = bs.asReadOnlyBuffer();
        us.limit(1);
        us.position(0);
        bs2.limit(4);
View Full Code Here

        if (!result.isOverflow()) {
            errln("Overflow error should have occurred while decoding UTF-8 (5).");
        }
       
        //test overflow
        decoder.reset();
        us.limit(2);
        us.position(0);
        bs2.limit(5);
        bs2.position(0);
       
View Full Code Here

        if (!result.isOverflow()) {
            errln("Overflow error should have occurred while decoding UTF-8 (5).");
        }
       
        //test overflow
        decoder.reset();
        us.limit(1);
        us.position(0);
        bs.limit(5);
        bs.position(0);
       
View Full Code Here

        }
     
        bs.clear();
       
        //test overflow
        decoder.reset();
        bs.put((byte)0x41); bs.put((byte)0x42);
        us.limit(1);
        us.position(0);
        bs.limit(2);
        bs.position(0);
View Full Code Here

       
        us.clear();
        bs.clear();
       
        //test overflow buffer
        decoder.reset();
        decoder = provider.charsetForName("UTF-16BE").newDecoder();
       
        bs.put((byte)0xFF); bs.put((byte)0xFE); bs.put((byte)0x41);
       
        us.limit(0);
View Full Code Here

        bb = ByteBuffer.wrap(bytearray);
        cb = CharBuffer.allocate(20);
       
        ((CharsetDecoderICU)decoder).setToUCallback(CoderResult.OVERFLOW, CharsetCallback.TO_U_CALLBACK_ESCAPE, null)// This callback is not valid.
        for (int i = 0; i < context2.length; i++) {
            decoder.reset();
            cb.position(0);
            bb.position(0);
            ((CharsetDecoderICU)decoder).setToUCallback(CoderResult.malformedForLength(1), CharsetCallback.TO_U_CALLBACK_ESCAPE, context2[i]); // This callback is valid.
           
            result = decoder.decode(bb, cb, true);
View Full Code Here

            }
        }
       
        // Testing decoder skip callback
        for (int i = 0; i < context3.length; i++) {
            decoder.reset();
            cb.position(0);
            bb.position(0);
            ((CharsetDecoderICU)decoder).setToUCallback(CoderResult.malformedForLength(1), CharsetCallback.TO_U_CALLBACK_SKIP, context3[i]);
            result = decoder.decode(bb, cb, true);
            if (!result.isError()) {
View Full Code Here

                }
            } else {
                bs = ByteBuffer.wrap(bytes, x, 3).slice();
                us = CharBuffer.wrap(chars, y, 1).slice();
               
                decoder.reset();
                cr = decoder.decode(bs, us, true);
                bs.rewind();
                us.rewind();
                if (!cr.isMalformed() || cr.length() != 3) {
                    errln("Incorrect result in " + converter + " decoder for 0x"
View Full Code Here

                }
               
                bs = ByteBuffer.wrap(bytes, x, 3).slice();
                us = CharBuffer.wrap(new String(chars, y, 1));
               
                decoder.reset();
                cr = decoder.decode(bs, us, true);
                bs.rewind();
                us.rewind();
                if (!cr.isMalformed() || cr.length() != 3) {
                    errln("Incorrect result in " + converter + " decoder for 0x"
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.