Merge pull request #51 from ckayser/master
fix #49 : start decoding binary composite field from the offset position
This commit is contained in:
@@ -79,7 +79,7 @@ public class CompositeField implements CustomBinaryField<CompositeField> {
|
||||
public CompositeField decodeBinaryField(byte[] buf, int offset, int length) {
|
||||
@SuppressWarnings("rawtypes")
|
||||
List<IsoValue> vals = new ArrayList<>(parsers.size());
|
||||
int pos = 0;
|
||||
int pos = offset;
|
||||
try {
|
||||
for (FieldParseInfo fpi : parsers) {
|
||||
IsoValue<?> v = fpi.parseBinary(0, buf, pos, fpi.getDecoder());
|
||||
|
||||
@@ -79,4 +79,19 @@ public class TestComposites {
|
||||
Assert.assertEquals("X", f.getValues().get(3).getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecodeBinaryWithOffset() {
|
||||
final CompositeField dec = new CompositeField()
|
||||
.addParser(new LlvarParseInfo())
|
||||
.addParser(new NumericParseInfo(5))
|
||||
.addParser(new AlphaParseInfo(1));
|
||||
int offset = 5;
|
||||
final CompositeField f = dec.decodeBinaryField(binaryData, offset, this.binaryData.length - offset);
|
||||
Assert.assertNotNull(f);
|
||||
Assert.assertEquals(3, f.getValues().size());
|
||||
Assert.assertEquals("Two", f.getValues().get(0).getValue());
|
||||
Assert.assertEquals(999l, f.getValues().get(1).getValue());
|
||||
Assert.assertEquals("X", f.getValues().get(2).getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user