|
27 | 27 | import com.igormaznitsa.jbbp.model.JBBPFieldLong;
|
28 | 28 | import com.igormaznitsa.jbbp.model.JBBPFieldShort;
|
29 | 29 | import com.igormaznitsa.mvn.test.jbbp.VarCustom;
|
30 |
| - |
31 | 30 | import java.io.IOException;
|
32 | 31 |
|
33 | 32 | public class VarCustomImpl extends VarCustom {
|
34 | 33 |
|
35 | 34 | @Override
|
36 |
| - public JBBPAbstractField readCustomFieldType(Object sourceStruct, JBBPBitInputStream inStream, JBBPFieldTypeParameterContainer typeParameterContainer, JBBPNamedFieldInfo nullableNamedFieldInfo, int extraValue, boolean readWholeStream, int arraySize) throws IOException { |
37 |
| - return new JBBPFieldShort(nullableNamedFieldInfo, (short) inStream.readUnsignedShort(typeParameterContainer.getByteOrder())); |
| 35 | + public JBBPAbstractField readCustomFieldType(Object sourceStruct, JBBPBitInputStream inStream, |
| 36 | + JBBPFieldTypeParameterContainer typeParameterContainer, |
| 37 | + JBBPNamedFieldInfo nullableNamedFieldInfo, |
| 38 | + int extraValue, boolean readWholeStream, |
| 39 | + int arraySize) throws IOException { |
| 40 | + return new JBBPFieldShort(nullableNamedFieldInfo, |
| 41 | + (short) inStream.readUnsignedShort(typeParameterContainer.getByteOrder())); |
38 | 42 | }
|
39 | 43 |
|
40 | 44 | @Override
|
41 |
| - public void writeCustomFieldType(Object sourceStruct, JBBPBitOutputStream outStream, JBBPAbstractField fieldValue, JBBPFieldTypeParameterContainer typeParameterContainer, JBBPNamedFieldInfo nullableNamedFieldInfo, int extraValue, boolean wholeArray, int arraySize) throws IOException { |
42 |
| - outStream.writeShort(((JBBPFieldShort) fieldValue).getAsInt(), typeParameterContainer.getByteOrder()); |
| 45 | + public void writeCustomFieldType(Object sourceStruct, JBBPBitOutputStream outStream, |
| 46 | + JBBPAbstractField fieldValue, |
| 47 | + JBBPFieldTypeParameterContainer typeParameterContainer, |
| 48 | + JBBPNamedFieldInfo nullableNamedFieldInfo, int extraValue, |
| 49 | + boolean wholeArray, int arraySize) throws IOException { |
| 50 | + outStream.writeShort(((JBBPFieldShort) fieldValue).getAsInt(), |
| 51 | + typeParameterContainer.getByteOrder()); |
43 | 52 | }
|
44 | 53 |
|
45 | 54 | @Override
|
46 |
| - public JBBPAbstractField readVarField(Object sourceStruct, JBBPBitInputStream inStream, JBBPByteOrder byteOrder, JBBPNamedFieldInfo nullableNamedFieldInfo, int extraValue) throws IOException { |
| 55 | + public JBBPAbstractField readVarField(Object sourceStruct, JBBPBitInputStream inStream, |
| 56 | + JBBPByteOrder byteOrder, |
| 57 | + JBBPNamedFieldInfo nullableNamedFieldInfo, int extraValue) |
| 58 | + throws IOException { |
47 | 59 | return new JBBPFieldLong(nullableNamedFieldInfo, inStream.readLong(byteOrder));
|
48 | 60 | }
|
49 | 61 |
|
50 | 62 | @Override
|
51 |
| - public JBBPAbstractArrayField<? extends JBBPAbstractField> readVarArray(Object sourceStruct, JBBPBitInputStream inStream, JBBPByteOrder byteOrder, JBBPNamedFieldInfo nullableNamedFieldInfo, int extraValue, boolean readWholeStream, int arraySize) throws IOException { |
| 63 | + public JBBPAbstractArrayField<? extends JBBPAbstractField> readVarArray(Object sourceStruct, |
| 64 | + JBBPBitInputStream inStream, |
| 65 | + JBBPByteOrder byteOrder, |
| 66 | + JBBPNamedFieldInfo nullableNamedFieldInfo, |
| 67 | + int extraValue, |
| 68 | + boolean readWholeStream, |
| 69 | + int arraySize) |
| 70 | + throws IOException { |
52 | 71 | if (readWholeStream) {
|
53 | 72 | return new JBBPFieldArrayLong(nullableNamedFieldInfo, inStream.readLongArray(-1, byteOrder));
|
54 | 73 | } else {
|
55 |
| - return new JBBPFieldArrayLong(nullableNamedFieldInfo, inStream.readLongArray(arraySize, byteOrder)); |
| 74 | + return new JBBPFieldArrayLong(nullableNamedFieldInfo, |
| 75 | + inStream.readLongArray(arraySize, byteOrder)); |
56 | 76 | }
|
57 | 77 | }
|
58 | 78 |
|
59 | 79 | @Override
|
60 |
| - public void writeVarField(Object sourceStruct, JBBPAbstractField value, JBBPBitOutputStream outStream, JBBPByteOrder byteOrder, JBBPNamedFieldInfo nullableNamedFieldInfo, int extraValue) throws IOException { |
| 80 | + public void writeVarField(Object sourceStruct, JBBPAbstractField value, |
| 81 | + JBBPBitOutputStream outStream, JBBPByteOrder byteOrder, |
| 82 | + JBBPNamedFieldInfo nullableNamedFieldInfo, int extraValue) |
| 83 | + throws IOException { |
61 | 84 | outStream.writeLong(((JBBPFieldLong) value).getAsLong(), byteOrder);
|
62 | 85 | }
|
63 | 86 |
|
64 | 87 | @Override
|
65 |
| - public void writeVarArray(Object sourceStruct, JBBPAbstractArrayField<? extends JBBPAbstractField> array, JBBPBitOutputStream outStream, JBBPByteOrder byteOrder, JBBPNamedFieldInfo nullableNamedFieldInfo, int extraValue, int arraySizeToWrite) throws IOException { |
| 88 | + public void writeVarArray(Object sourceStruct, |
| 89 | + JBBPAbstractArrayField<? extends JBBPAbstractField> array, |
| 90 | + JBBPBitOutputStream outStream, JBBPByteOrder byteOrder, |
| 91 | + JBBPNamedFieldInfo nullableNamedFieldInfo, int extraValue, |
| 92 | + int arraySizeToWrite) throws IOException { |
66 | 93 | final JBBPFieldArrayLong a = (JBBPFieldArrayLong) array;
|
67 | 94 | if (arraySizeToWrite < 0) {
|
68 | 95 | for (final long l : a.getArray()) {
|
|
0 commit comments