Returns the encoded byte sequence. @param __e The encoder to use when writing bytes. @return The bytes from this string. @throws NullPointerException On null arguments. @since 2018/12/08
(Encoder __e)
| 1184 | * @since 2018/12/08 |
| 1185 | */ |
| 1186 | private final byte[] __getBytes(Encoder __e) |
| 1187 | throws NullPointerException |
| 1188 | { |
| 1189 | if (__e == null) |
| 1190 | throw new NullPointerException("NARG"); |
| 1191 | |
| 1192 | // Maximum size of sequences that can be encoded |
| 1193 | int msl; |
| 1194 | byte[] seq = new byte[(msl = __e.maximumSequenceLength())]; |
| 1195 | |
| 1196 | // We operate directly on the sequence |
| 1197 | BasicSequence sequence = this._sequence; |
| 1198 | int n = sequence.length(); |
| 1199 | |
| 1200 | // Write here |
| 1201 | try (ByteArrayOutputStream baos = new ByteArrayOutputStream( |
| 1202 | (int)(n * __e.averageSequenceLength()))) |
| 1203 | { |
| 1204 | // Encode every character! |
| 1205 | for (int i = 0; i < n; i++) |
| 1206 | { |
| 1207 | int sz = __e.encode(sequence.charAt(i), seq, 0, msl); |
| 1208 | |
| 1209 | // Should not occur |
| 1210 | if (sz < 0) |
| 1211 | throw new todo.OOPS(); |
| 1212 | |
| 1213 | baos.write(seq, 0, sz); |
| 1214 | } |
| 1215 | |
| 1216 | // Use this byte array |
| 1217 | return baos.toByteArray(); |
| 1218 | } |
| 1219 | |
| 1220 | // Should not occur |
| 1221 | catch (IOException e) |
| 1222 | { |
| 1223 | throw new todo.OOPS(); |
| 1224 | } |
| 1225 | } |
| 1226 | |
| 1227 | /** |
| 1228 | * Invokes {@code String.valueOf(__c, __o, __l)}. |
no test coverage detected