A converter that can converts a 16-bit Unicode character sequence to a byte sequence in some charset. The input character sequence is wrapped by a java.nio.CharBuffer CharBuffer and the output character sequence is a java.nio.ByteBuffer ByteBuffer. An encoder instance should be u
| 84 | * @see java.nio.charset.CharsetDecoder |
| 85 | */ |
| 86 | public abstract class CharsetEncoder { |
| 87 | |
| 88 | /* |
| 89 | * internal status consts |
| 90 | */ |
| 91 | private static final int READY = 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 | private static final int INIT = 4; |
| 100 | |
| 101 | // the Charset which creates this encoder |
| 102 | private Charset cs; |
| 103 | |
| 104 | // average bytes per character created by this encoder |
| 105 | private float averBytes; |
| 106 | |
| 107 | // maximum bytes per character can be created by this encoder |
| 108 | private float maxBytes; |
| 109 | |
| 110 | // replacement byte array |
| 111 | private byte[] replace; |
| 112 | |
| 113 | // internal status |
| 114 | private int status; |
| 115 | |
| 116 | // internal status indicates encode(CharBuffer) operation is finished |
| 117 | private boolean finished; |
| 118 | |
| 119 | // action for malformed input |
| 120 | private CodingErrorAction malformAction; |
| 121 | |
| 122 | // action for unmapped char input |
| 123 | private CodingErrorAction unmapAction; |
| 124 | |
| 125 | // decoder instance for this encoder's charset, used for replacement value |
| 126 | // checking |
| 127 | private CharsetDecoder decoder; |
| 128 | |
| 129 | /** |
| 130 | * Constructs a new <code>CharsetEncoder</code> using the given |
| 131 | * <code>Charset</code>, average number and maximum number of bytes |
| 132 | * created by this encoder for one input character. |
| 133 | * |
| 134 | * @param cs |
| 135 | * the <code>Charset</code> to be used by this encoder. |
| 136 | * @param averageBytesPerChar |
| 137 | * average number of bytes created by this encoder for one input |
| 138 | * character, must be positive. |
| 139 | * @param maxBytesPerChar |
| 140 | * maximum number of bytes which can be created by this encoder |
| 141 | * for one input character, must be positive. |
| 142 | * @throws IllegalArgumentException |
| 143 | * if <code>maxBytesPerChar</code> or |
nothing calls this directly
no outgoing calls
no test coverage detected