protected final byte[] getBytes() { if (buffer == null) { throw new IllegalStateException("No buffer"); } return buffer.get(); }
@Override public String get() { if (!NULL.equals(this)) { for (int length = 1;; length++) { byte[] bytes = buffer(length).get(); if (bytes[length - 1] == NUL) { return new String(bytes, 0, length - 1, US_ASCII); } } } return null; }
private String readZZString() { if (NULL.equals(this)) { return null; } for (int length = 2;; length++) { byte[] bytes = buffer(length).get(); if (bytes[bytes.length - 1] == NUL && bytes[bytes.length - 2] == NUL) { return new String(bytes, StandardCharsets.US_ASCII); } } }
@Override public String get() { if (!NULL.equals(this)) { for (int size = 2;; size += 2) { byte[] bytes = buffer(size).get(); if (bytes[bytes.length - 1] == 0 && bytes[bytes.length - 2] == 0) { return new String(bytes, 0, size - 2, StandardCharsets.UTF_16LE); } } } return null; }
public Optional<byte[]> getData() { Optional<byte[]> result = Optional.empty(); if (!Pointer.NULL.equals(data)) { result = Optional.of(data.buffer(dataLength.intValue()).get()); } return result; }
public Optional<byte[]> getComparisonData() { Optional<byte[]> result = Optional.empty(); if (getLength() > 0) { result = Optional.of(comparisonData.buffer(getLength()).get()); } return result; }
public byte[] getChipData() { return chipData.buffer(chipDataLength.intValue()).get(); }
public byte[] getData() { return data.buffer(size.intValue()).get(); }
@Override public Map<String, String> get() { Map<String, String> result = Collections.emptyMap(); if (!NULL.equals(this)) { int length = 2; byte[] bytes = null; do { bytes = buffer(length++).get(); } while (bytes[bytes.length - 2] != 0 || bytes[bytes.length - 1] != 0); result = decode(new String(bytes, 0, bytes.length - 2, StandardCharsets.US_ASCII)); } return result; }
public byte[] getKeyValue() { return keyValue.buffer(keyLen.intValue()).get(); }
public byte[] getData() { return data.buffer(size.intValue()).get(); }
public byte[] getData() { return data.buffer(dataLength.intValue()).get(); }
@Override public Map<String, String> get() { Map<String, String> result = Collections.emptyMap(); if (!Pointer.NULL.equals(this)) { int length = bytesPerChar; byte[] buf; do { length += bytesPerChar; buf = buffer(length).get(); } while (!isTerminated(buf)); result = decode(new String(buf, 0, buf.length - (bytesPerChar * 2), charset)); } return result; }
public byte[] getDescription() { byte[] result = Bytes.EMPTY; if (length.intValue() > 0) { result = description.buffer(length.intValue()).get(); } return result; }
public byte[] getDescription() { byte[] result = Bytes.EMPTY; if (length.intValue() > 0) { result = description.buffer(length.intValue()).get(); } return result; }
public byte[] getDescription() { byte[] result = Bytes.EMPTY; if (length.intValue() > 0) { result = description.buffer(length.intValue()).get(); } return result; }
public byte[] getData() { byte[] result = null; if (!Pointer.NULL.equals(data)) { result = data.buffer(getDataLength()).get(); } return result; } }
/** * {@link #data} */ public byte[] getData() { byte[] result = null; if (!Pointer.NULL.equals(data)) { result = data.buffer(getLength()).get(); } return result; }
@Test public final void putAndGet() { byte[] expecteds = getBytes(10); Buffer buffer = factory.createBuffer(expecteds.length); buffer.put(expecteds); Assert.assertArrayEquals(expecteds, buffer.get()); }
@Test public final void subBuffer() { byte[] src = Hex.decode("12345678"); Buffer buffer = factory.createBuffer(src.length); buffer.put(src); Assert.assertArrayEquals(Hex.decode("3456"), buffer.subBuffer(1, 2).get()); } }