A converter that can convert a byte sequence from a charset into a 16-bit Unicode character sequence. The input byte sequence is wrapped by a java.nio.ByteBuffer ByteBuffer and the output character sequence is a java.nio.CharBuffer CharBuffer. A decoder instance should be used in
| 84 | * @see java.nio.charset.CharsetEncoder |
| 85 | */ |
| 86 | public abstract class CharsetDecoder { |
| 87 | |
| 88 | /* |
| 89 | * internal status consts |
| 90 | */ |
| 91 | private static final int INIT = 0; |
| 92 | |
| 93 | private static final int ONGOING = 1; |
| 94 | |
| 95 | private static final int END = 2; |
| 96 | |
| 97 | private static final int FLUSH = 3; |
| 98 | |
| 99 | // average number of chars for one byte |
| 100 | private float averChars; |
| 101 | |
| 102 | // maximum number of chars for one byte |
| 103 | private float maxChars; |
| 104 | |
| 105 | // charset for this decoder |
| 106 | private Charset cs; |
| 107 | |
| 108 | // specify the action if malformed input error encountered |
| 109 | private CodingErrorAction malformAction; |
| 110 | |
| 111 | // specify the action if unmappable character error encountered |
| 112 | private CodingErrorAction unmapAction; |
| 113 | |
| 114 | // the replacement string |
| 115 | private String replace; |
| 116 | |
| 117 | // the current status |
| 118 | private int status; |
| 119 | |
| 120 | /** |
| 121 | * Constructs a new <code>CharsetDecoder</code> using the given |
| 122 | * <code>Charset</code>, average number and maximum number of characters |
| 123 | * created by this decoder for one input byte, and the default replacement |
| 124 | * string "\uFFFD". |
| 125 | * |
| 126 | * @param charset |
| 127 | * the <code>Charset</code> to be used by this decoder. |
| 128 | * @param averageCharsPerByte |
| 129 | * the average number of characters created by this decoder for |
| 130 | * one input byte, must be positive. |
| 131 | * @param maxCharsPerByte |
| 132 | * the maximum number of characters created by this decoder for |
| 133 | * one input byte, must be positive. |
| 134 | * @throws IllegalArgumentException |
| 135 | * if <code>averageCharsPerByte</code> or |
| 136 | * <code>maxCharsPerByte</code> is negative. |
| 137 | */ |
| 138 | protected CharsetDecoder(Charset charset, float averageCharsPerByte, |
| 139 | float maxCharsPerByte) { |
| 140 | if (averageCharsPerByte <= 0 || maxCharsPerByte <= 0) { |
| 141 | // niochar.00=Characters number for one byte must be positive. |
| 142 | throw new IllegalArgumentException(Messages.getString("niochar.00")); //$NON-NLS-1$ |
| 143 | } |
nothing calls this directly
no outgoing calls
no test coverage detected