You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32-31Lines changed: 32 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,23 +18,24 @@ For instance I have been very actively using the framework in [the ZX-Poly emula
18
18
Change log
19
19
===========
20
20
-**1.3.0-SNAPSHOT**
21
-
-__Fixed issue [#16 NullPointerException when referencing a JBBPCustomFieldTypeProcessor parsed field"](https://github.com/raydac/java-binary-block-parser/issues/16), many thanks to @use-sparingly for the bug report__
22
-
- created [Maven plugin](https://github.com/raydac/jbbp-maven-plugin) to generate Java class sources (1.6+) from JBBP scripts
21
+
-__Fixed issue [#16 NullPointerException when referencing a JBBPCustomFieldTypeProcessor parsed field"](https://github.com/raydac/java-binary-block-parser/issues/16), many thanks to @use-sparingly for the bug report__
22
+
- added Maven plugin to auto-generate Java classes (1.6+) from JBBP scripts
23
+
- added Gradle plugin to auto-generate Java classes (1.6+) from JBBP scripts
23
24
- added extra byte array reading writing methods with byte order support into JBBPBitInputStream and JBBPBitOutputStream
24
25
- added converter of compiled parser data into Java class sources (1.6+)
25
26
- added method to read unsigned short values as char [] into JBBPBitInputStream
26
27
- Class version target has been changed to Java 1.6
27
28
- fixed compatibiity of tests with Java 1.6
28
29
- Minor refactoring
29
-
30
+
30
31
-**1.2.1 (28-JUL-2016)**
31
32
-__Fixed issue [#10 "assertArrayLength throws exception in multi-thread"](https://github.com/raydac/java-binary-block-parser/issues/10), many thanks to @sky4star for the bug report.__
32
33
- minor refactoring
33
34
34
35
-**1.2.0 (10-JUN-2015)**
35
36
- Refactoring
36
37
- Improved tree of JBBP exceptions
37
-
- Fixed NPE in JBBPTextWriter for String field mapped to byte array
38
+
- Fixed NPE in JBBPTextWriter for String field mapped to byte array
38
39
- Added support of custom field types through JBBPCustomFieldTypeProcessor
39
40
- Added JBBPCustomFieldTypeProcessorAggregator, auxiliary class to join several JBBPCustomFieldTypeProcessors
40
41
- Fixed JBBPTextWriter, added support of logging for JBBPAbstractField objects
@@ -50,11 +51,11 @@ Change log
50
51
- Fixed static fields including in mapping processes if class has marked by default Bin annotation
51
52
- Added flag JBBPParser#FLAG_SKIP_REMAINING_FIELDS_IF_EOF to ignore remaining fields during parsing if EOF without exception
52
53
- Added flag JBBPMapper#FLAG_IGNORE_MISSING_VALUES to ignore mapping for values which are not found in parsed source
53
-
- Added new auxiliary methods in JBBPUtils
54
+
- Added new auxiliary methods in JBBPUtils
54
55
55
56
-**1.0 (08-AUG-2014)**
56
-
- The Initial version
57
-
57
+
- The Initial version
58
+
58
59
# Maven dependency
59
60
The Framework has been published in the Maven Central and can be easily added as a dependency
60
61
```
@@ -64,7 +65,7 @@ The Framework has been published in the Maven Central and can be easily added as
64
65
<version>1.2.1</version>
65
66
</dependency>
66
67
```
67
-
the precompiled library jar, javadoc and sources also can be downloaded directly from [the Maven central.](http://search.maven.org/#browse|808871750)
68
+
the precompiled library jar, javadoc and sources also can be downloaded directly from [the Maven central.](http://search.maven.org/#browse|808871750)
68
69
69
70
# Hello world
70
71
The Framework is very easy in use because it has only two main classes for its functionality com.igormaznitsa.jbbp.JBBPParser (for data parsing) and com.igormaznitsa.jbbp.io.JBBPOut (for binary block writing), both of them work over low-level IO classes com.igormaznitsa.jbbp.io.JBBPBitInputStream and com.igormaznitsa.jbbp.io.JBBPBitOutputStream which are the core for the framework.
# More compex example with features added as of 1.1.0
84
-
The Example shows how to parse a byte written in non-standard MSB0 order (Java has LSB0 bit order) to bit fields, print its values and pack fields back
85
+
The Example shows how to parse a byte written in non-standard MSB0 order (Java has LSB0 bit order) to bit fields, print its values and pack fields back
85
86
```Java
86
87
classFlags {
87
88
@Bin(outOrder=1, name="f1", type=BinType.BIT, outBitNumber=JBBPBitNumber.BITS_1, comment="It's flag one") byte flag1;
88
89
@Bin(outOrder=2, name="f2", type=BinType.BIT, outBitNumber=JBBPBitNumber.BITS_2, comment="It's second flag") byte flag2;
@@ -136,7 +137,7 @@ The Framework provides support for arrays and structures. Just keep in mind that
136
137
it is possible to define processors for own custom data types, for instance you can take a look at [case processing three byte unsigned integer types](https://github.com/raydac/java-binary-block-parser/blob/master/src/test/java/com/igormaznitsa/jbbp/it/CustomThreeByteIntegerTypeTest.java).
137
138
138
139
### Float and Double types
139
-
The Parser doesn't support Java float and double types out of the box. But it can be implemented through custom type processor. [there is written example and test and the code can be copy pasted](https://github.com/raydac/java-binary-block-parser/blob/master/src/test/java/com/igormaznitsa/jbbp/it/FloatAndDoubleTypesTest.java).
140
+
The Parser doesn't support Java float and double types out of the box. But it can be implemented through custom type processor. [there is written example and test and the code can be copy pasted](https://github.com/raydac/java-binary-block-parser/blob/master/src/test/java/com/igormaznitsa/jbbp/it/FloatAndDoubleTypesTest.java).
140
141
141
142
## Variable fields
142
143
If you have some data which structure is variable then you can use the `var` type for defined field and process reading of the data manually with custom [JBBPVarFieldProcessor](https://github.com/raydac/java-binary-block-parser/blob/master/src/main/java/com/igormaznitsa/jbbp/JBBPVarFieldProcessor.java) instance.
@@ -170,7 +171,7 @@ Expressions are used for calculation of length of arrays and allow brackets and
170
171
- Arithmetic operators: +,-,%,*,/,%
171
172
- Bit operators: &,|,^,~
172
173
- Shift operators: <<,>>,>>>
173
-
- Brackets: (, )
174
+
- Brackets: (, )
174
175
175
176
Inside expression you can use integer numbers and named field values through their names (if you use fields from the same structure) or paths. Keep in your mind that you can't use array fields or fields placed inside structure arrays.
176
177
```
@@ -182,7 +183,7 @@ int field1;
182
183
```
183
184
184
185
# Commentaries
185
-
You can use commentaries inside a parser script, the parser supports the only comment format and recognizes as commentaries all text after '//' till the end of line.
186
+
You can use commentaries inside a parser script, the parser supports the only comment format and recognizes as commentaries all text after '//' till the end of line.
186
187
```
187
188
int;
188
189
// hello commentaries
@@ -193,7 +194,7 @@ You can use commentaries inside a parser script, the parser supports the only co
193
194
Inside expression you can use field names and field paths, also you can use the special macros '$$' which represents the current input stream byte counter, all fields started with '$' will be recognized by the parser as special user defined variables and it will be requesting them from special user defined provider. If the array size contains the only '_' symbol then the field or structure will not have defined size and whole stream will be read.
194
195
195
196
# How to get result of parsing
196
-
The Result of parsing is an instance of com.igormaznitsa.jbbp.model.JBBPFieldStruct class which represents the root invisible structure for the parsed data and you can use its inside methods to find desired fields for their names, paths or classes. All Fields are successors of com.igormaznitsa.jbbp.model.JBBPAbstractField class. To increase comfort, it is easier to use mapping to classes when the mapper automaticaly places values to fields of a Java class.
197
+
The Result of parsing is an instance of com.igormaznitsa.jbbp.model.JBBPFieldStruct class which represents the root invisible structure for the parsed data and you can use its inside methods to find desired fields for their names, paths or classes. All Fields are successors of com.igormaznitsa.jbbp.model.JBBPAbstractField class. To increase comfort, it is easier to use mapping to classes when the mapper automaticaly places values to fields of a Java class.
197
198
198
199
# Example
199
200
The Example below shows how to parse a PNG file with the JBBP parser (the example taken from tests)
@@ -213,17 +214,17 @@ final InputStream pngStream = getResourceAsInputStream("picture.png");
213
214
);
214
215
215
216
finalJBBPFieldStruct result = pngParser.parse(pngStream);
The Example from tests shows how to parse a tcp frame wrapped in a network frame
263
+
The Example from tests shows how to parse a tcp frame wrapped in a network frame
263
264
```Java
264
265
finalJBBPParser tcpParser =JBBPParser.prepare(
265
266
"skip:34; // skip bytes till the frame\n"
266
267
+"ushort SourcePort;"
267
268
+"ushort DestinationPort;"
268
269
+"int SequenceNumber;"
269
270
+"int AcknowledgementNumber;"
270
-
271
+
271
272
+"bit:1 NONCE;"
272
273
+"bit:3 RESERVED;"
273
274
+"bit:4 HLEN;"
274
-
275
+
275
276
+"bit:1 FIN;"
276
277
+"bit:1 SYN;"
277
278
+"bit:1 RST;"
@@ -280,7 +281,7 @@ final JBBPParser tcpParser = JBBPParser.prepare(
280
281
+"bit:1 URG;"
281
282
+"bit:1 ECNECHO;"
282
283
+"bit:1 CWR;"
283
-
284
+
284
285
+"ushort WindowSize;"
285
286
+"ushort TCPCheckSum;"
286
287
+"ushort UrgentPointer;"
@@ -298,11 +299,11 @@ No, `@Bin` annotations in classes are used only for mapping and data writing, bu
298
299
No problems! The Parser works over com.igormaznitsa.jbbp.io.BitInputStream class which can be used directly and allows read bits, bytes, count bytes and align data from a stream.
299
300
300
301
## I want to make a bin block instead of parsing!
301
-
The Framework contains a special helper as the class com.igormaznitsa.jbbp.io.JBBPOut which allows to build bin blocks with some kind of DSL
302
+
The Framework contains a special helper as the class com.igormaznitsa.jbbp.io.JBBPOut which allows to build bin blocks with some kind of DSL
Copy file name to clipboardExpand all lines: changelog.txt
+5-4Lines changed: 5 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,8 @@ Change log
3
3
4
4
1.3.0
5
5
- fixed NPE when referencing a JBBPCustomFieldTypeProcessor parsed field
6
-
- created [Maven plugin](https://github.com/raydac/jbbp-maven-plugin) to generate Java class sources (1.6+) from JBBP scripts
6
+
- added Maven plugin to auto-generate Java classes (1.6+) from JBBP scripts
7
+
- added Gradle plugin to auto-generate Java classes (1.6+) from JBBP scripts
7
8
- added extra byte array reading writing methods with byte order support into JBBPBitInputStream and JBBPBitOutputStream
8
9
- added converter of compiled parser data into Java class sources (1.6+)
9
10
- added method to read unsigned short values as char [] into JBBPBitInputStream
@@ -14,7 +15,7 @@ Change log
14
15
1.2.0
15
16
- Refactoring
16
17
- Improved tree of JBBP exceptions
17
-
- Fixed NPE in JBBPTextWriter for String field mapped to byte array
18
+
- Fixed NPE in JBBPTextWriter for String field mapped to byte array
18
19
- Added support of custom field types through JBBPCustomFieldTypeProcessor
19
20
- Added JBBPCustomFieldTypeProcessorAggregator, auxiliary class to join several JBBPCustomFieldTypeProcessors
20
21
- Fixed JBBPTextWriter, added support of logging for JBBPAbstractField objects
@@ -29,8 +30,8 @@ Change log
29
30
- Fixed read byte counter, now it counts only fully processed bytes, if only several bits have been read from byte then the byte will not be counted until whole read
30
31
- Fixed static fields including in mapping processes if class has marked by default Bin annotation
31
32
- Added flag JBBPParser#FLAG_SKIP_REMAINING_FIELDS_IF_EOF to ignore remaining fields during parsing if EOF without exception
32
-
- Added flag JBBPMapper#FLAG_IGNORE_MISSING_VALUES to ignore mapping for values which are not found in parsed source
33
+
- Added flag JBBPMapper#FLAG_IGNORE_MISSING_VALUES to ignore mapping for values which are not found in parsed source
0 commit comments