Examples of charset()


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

        /*
         * ------------------------ Exceptional cases -------------------------
         */
        // Normal case: null charset
        ec = new MockCharsetDecoder(null, 1, MAX_BYTES);
        assertNull(ec.charset());
        assertEquals(1.0, ec.averageCharsPerByte(), 0.0);
        assertTrue(ec.maxCharsPerByte() == MAX_BYTES);

        ec = new MockCharsetDecoder(new CharsetEncoderTest.MockCharset("mock",
                new String[0]), 1, MAX_BYTES);
View Full Code Here

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

        if (encoding != null) {
            CharsetDecoder decoder = getDecoder(encoding);
            // Create buffer for characters decoding
            CharBuffer charBuffer = CharBuffer.allocate(buffer.length);
            // Create buffer for bytes
            float bytesPerChar = decoder.charset().newEncoder().maxBytesPerChar();
            ByteBuffer byteBuffer = ByteBuffer.allocate((int) (buffer.length + bytesPerChar));
            if (buffers != null) {
                for (byte[] bytes : buffers) {
                    decodeAndWriteOut(out, bytes, bytes.length, byteBuffer, charBuffer, decoder, false);
                }
View Full Code Here

Examples of java.nio.charset.CharsetEncoder.charset()

     *        java.nio.charset.Charset, float, float)
     */
    public void test_ConstructorLjava_nio_charset_CharsetNull() {
        // Regression for HARMONY-491
        CharsetEncoder ech = new MockCharsetEncoderForHarmony491(null, 1, 1);
        assertNull(ech.charset());
    }

    /**
     * Helper for constructor tests
     */
 
View Full Code Here

Examples of java.nio.charset.CharsetEncoder.charset()

    assertSame(encoder, encoder
        .onUnmappableCharacter(CodingErrorAction.IGNORE));

    // normal case
    CharsetEncoder ec = new MockCharsetEncoder(cs, 1, MAX_BYTES);
    assertSame(ec.charset(), cs);
    assertEquals(1.0, ec.averageBytesPerChar(), 0);
    assertTrue(ec.maxBytesPerChar() == MAX_BYTES);

    /*
     * ------------------------ Exceptional cases -------------------------
View Full Code Here

Examples of java.nio.charset.CharsetEncoder.charset()

   */
  public void testCharsetEncoderCharsetfloatfloatbyteArray() {
    byte[] ba = getLegalByteArray();
    // normal case
    CharsetEncoder ec = new MockCharsetEncoder(cs, 1, MAX_BYTES, ba);
    assertSame(ec.charset(), cs);
    assertEquals(1.0, ec.averageBytesPerChar(), 0.0);
    assertTrue(ec.maxBytesPerChar() == MAX_BYTES);
    assertSame(ba, ec.replacement());

    /*
 
View Full Code Here

Examples of java.nio.charset.CharsetEncoder.charset()

     *        java.nio.charset.Charset, float, float)
     */
    public void test_ConstructorLjava_nio_charset_CharsetNull() {
        // Regression for HARMONY-491
        CharsetEncoder ech = new MockCharsetEncoderForHarmony491(null, 1, 1);
        assertNull(ech.charset());
    }

    /**
     * Helper for constructor tests
     */
 
View Full Code Here

Examples of java.nio.charset.CharsetEncoder.charset()

    assertSame(encoder, encoder
        .onUnmappableCharacter(CodingErrorAction.IGNORE));

    // normal case
    CharsetEncoder ec = new MockCharsetEncoder(cs, 1, MAX_BYTES);
    assertSame(ec.charset(), cs);
    assertEquals(1.0, ec.averageBytesPerChar(), 0);
    assertTrue(ec.maxBytesPerChar() == MAX_BYTES);

    /*
     * ------------------------ Exceptional cases -------------------------
View Full Code Here

Examples of java.nio.charset.CharsetEncoder.charset()

   */
  public void testCharsetEncoderCharsetfloatfloatbyteArray() {
    byte[] ba = getLegalByteArray();
    // normal case
    CharsetEncoder ec = new MockCharsetEncoder(cs, 1, MAX_BYTES, ba);
    assertSame(ec.charset(), cs);
    assertEquals(1.0, ec.averageBytesPerChar(), 0.0);
    assertTrue(ec.maxBytesPerChar() == MAX_BYTES);
    assertSame(ba, ec.replacement());

    /*
 
View Full Code Here

Examples of java.nio.charset.CharsetEncoder.charset()

        long failCount = 0;
       
        // Parse each message and extract an EmailMessage structure
        for (CharBufferWrapper message : mboxIterator) {
            try {
                Message msg = messageBuilder.parseMessage(message.asInputStream(theEncoder.charset()));
                emails.add(extractEmail(msg));
            } catch (IOException ex) {
                logger.log(Level.WARNING, "Failed to get message from mbox: {0}", ex.getMessage()); //NON-NLS
                failCount++;
            }
View Full Code Here

Examples of ninja.Result.charset()

        context.init(servletContext, httpServletRequest, httpServletResponse);

        //this must be Content-Type: application/json; encoding=utf-8
        Result result = Results.json();
        //force a characterset that is not there. Stupid but tests that its working.
        result.charset(null);

        context.finalizeHeaders(result);

        //make sure utf-8 is used under all circumstances:
        verify(httpServletResponse).setCharacterEncoding(NinjaConstant.UTF_8);
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.