| 32 | class LStringType50 extends LStringType { |
| 33 | |
| 34 | @Override |
| 35 | public LString parse(final ByteBuffer buffer, BHeader header) { |
| 36 | BInteger sizeT = header.sizeT.parse(buffer, header); |
| 37 | final StringBuilder b = this.b.get(); |
| 38 | b.setLength(0); |
| 39 | sizeT.iterate(new Runnable() { |
| 40 | |
| 41 | @Override |
| 42 | public void run() { |
| 43 | b.append((char) (0xFF & buffer.get())); |
| 44 | } |
| 45 | |
| 46 | }); |
| 47 | if(b.length() == 0) { |
| 48 | return LString.NULL; |
| 49 | } else { |
| 50 | char last = b.charAt(b.length() - 1); |
| 51 | if(last != '\0') { |
| 52 | throw new IllegalStateException("String value does not have a null terminator"); |
| 53 | } |
| 54 | b.delete(b.length() - 1, b.length()); |
| 55 | String s = b.toString(); |
| 56 | if(header.debug) { |
| 57 | System.out.println("-- parsed <string> \"" + s + "\""); |
| 58 | } |
| 59 | return new LString(s); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public void write(OutputStream out, BHeader header, LString string) throws IOException { |