diff options
Diffstat (limited to 'src/org/gnunet/construct/parsers/IntegerFillParser.java')
-rw-r--r-- | src/org/gnunet/construct/parsers/IntegerFillParser.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/org/gnunet/construct/parsers/IntegerFillParser.java b/src/org/gnunet/construct/parsers/IntegerFillParser.java index 1d485da..8c08627 100644 --- a/src/org/gnunet/construct/parsers/IntegerFillParser.java +++ b/src/org/gnunet/construct/parsers/IntegerFillParser.java | |||
@@ -58,9 +58,25 @@ public class IntegerFillParser implements Parser { | |||
58 | final int frameSize = ReflectUtil.justGetInt(frameObj, frameSizePath); | 58 | final int frameSize = ReflectUtil.justGetInt(frameObj, frameSizePath); |
59 | int remaining = frameStart + frameSize - srcBuf.position(); | 59 | int remaining = frameStart + frameSize - srcBuf.position(); |
60 | 60 | ||
61 | throw new UnsupportedOperationException("not yet implemented"); | 61 | int elemNumber = remaining / byteSize; |
62 | 62 | ||
63 | // return getSize(dstObj); | 63 | @SuppressWarnings("unchecked") |
64 | final Class<Message> arrayElementType = (Class<Message>) targetField.getType().getComponentType(); | ||
65 | |||
66 | if (!arrayElementType.isPrimitive()) { | ||
67 | throw new AssertionError("IntegerFillParser is expected to be of primitive type, not " + arrayElementType); | ||
68 | } | ||
69 | |||
70 | final Object arr = Array.newInstance(arrayElementType, elemNumber); | ||
71 | ReflectUtil.justSet(dstObj, targetField, arr); | ||
72 | |||
73 | |||
74 | for (int i = 0; i < elemNumber; ++i) { | ||
75 | long v = IntegerUtil.readLong(srcBuf, signed, byteSize); | ||
76 | ReflectUtil.justSetArray(arr, i, v); | ||
77 | } | ||
78 | |||
79 | return remaining; | ||
64 | } | 80 | } |
65 | 81 | ||
66 | @Override | 82 | @Override |