(context: EncoderContext)
| 11 | } |
| 12 | |
| 13 | public encode(context: EncoderContext) { |
| 14 | // step F |
| 15 | const buffer = new StringBuilder(); |
| 16 | while (context.hasMoreCharacters()) { |
| 17 | const c = context.getCurrentChar(); |
| 18 | this.encodeChar(c, buffer); |
| 19 | context.pos++; |
| 20 | |
| 21 | const count = buffer.length(); |
| 22 | if (count >= 4) { |
| 23 | context.writeCodewords(this.encodeToCodewords(buffer.toString())); |
| 24 | |
| 25 | const test = buffer.toString().substring(4); |
| 26 | buffer.setLengthToZero(); |
| 27 | buffer.append(test); |
| 28 | |
| 29 | // buffer.delete(0, 4); |
| 30 | // for (let i = 0; i < 4; i++) { |
| 31 | // buffer.deleteCharAt(i); |
| 32 | // } |
| 33 | |
| 34 | const newMode = HighLevelEncoder.lookAheadTest( |
| 35 | context.getMessage(), |
| 36 | context.pos, |
| 37 | this.getEncodingMode() |
| 38 | ); |
| 39 | if (newMode !== this.getEncodingMode()) { |
| 40 | // Return to ASCII encodation, which will actually handle latch to new mode |
| 41 | context.signalEncoderChange(ASCII_ENCODATION); |
| 42 | break; |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | buffer.append(StringUtils.getCharAt(31)); // Unlatch |
| 47 | this.handleEOD(context, buffer); |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Handle "end of data" situations |
nothing calls this directly
no test coverage detected