FileDocCategorySizeDatePackage
Charset_TestGenerator.javaAPI DocAndroid 1.5 API12773Wed May 06 22:41:04 BST 2009tests.api.java.nio.charset

Charset_TestGenerator

public class Charset_TestGenerator extends Object
Super class for concrete charset test suites.

Fields Summary
Charset
charset
CharsetDecoder
decoder
CharsetEncoder
encoder
static final int[]
codes
static final char[]
chars
Constructors Summary
Methods Summary
static voidgenCodes()

        CodesGenerator gen = new CodesGenerator1();
        int code = 0;
        while (code < (1 << 10)) {
            while (!gen.isAccepted(code)) code ++;
            gen.consume(code);
            code += 3;
        }
        while (code < (1 << 15)) {
            while (!gen.isAccepted(code)) code ++;
            gen.consume(code);
            code += 33;
        }
    
static voidgenDecoded(java.nio.charset.Charset charset, java.nio.ByteBuffer bb)

        CharsetDecoder decoder = charset.newDecoder();
//        System.out.println(code);
//        bytes[0] = (byte) code;
//        System.out.println(bytes[0]);
//        ByteBuffer inputBB = ByteBuffer.wrap(bytes);
//        CharBuffer outputCB;
//        try {
//            outputCB = decoder.decode(inputBB);
//            outputCB.rewind();
//            System.out.println(outputCB);
//        } catch (CharacterCodingException e) {
//            System.out.println(e);
////                e.printStackTrace();
//        }
    
static voidgenEncoded(java.nio.charset.Charset charset, java.nio.CharBuffer cb)

        System.out.println(charset.name());
        Dumper out = new Dumper1();
        CharsetEncoder encoder = charset.newEncoder();
        encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
        try {
            ByteBuffer bb = encoder.encode(cb);
//            bb.rewind();
            while (bb.hasRemaining()) {
                out.consume(bb.get());
            }
        } catch (CharacterCodingException e) {
            System.out.println(e);
//                e.printStackTrace();
        }
    
public static voidmain(java.lang.String[] args)

//        charset = Charset.defaultCharset();
//        decoder = charset.newDecoder();
//        System.out.println(charset.name());
        genEncoded(Charset.forName("MacRoman"), CharBuffer.wrap(chars));
//        genEncoded(Charset.forName(charsetNames[37]), CharBuffer.wrap(chars));