#### Maven plugin
> fillColor=`#D1FF9C`
diff --git a/README.md b/README.md
index d31b0f1c..47e3b5ac 100644
--- a/README.md
+++ b/README.md
@@ -15,14 +15,14 @@ For instance I have been very actively using the framework in [the ZX-Poly emula
![Use cases](https://github.com/raydac/java-binary-block-parser/blob/master/docs/jbbp_mm.png)
# Change log
-- **2.0.0-SNAPSHOT**
+- **2.0.0 (20-nov-2019)**
- __removed DslBinCustom annotation, use @Bin annotation instead__
- __renamed attributes of @Bin annotation to their correct form__
- __reworked object mapping system, removed hacks to instantiate classes, now only mapping to objects allowed, support of private fields mapping is removed__
- __minimal JDK version now 1.8+__
- __minimal Android API now 3.0+__
- added support of getters and setters into mapping
- - added `Object newInstance(Class)` method support of mapped classes to generate instances for local classes
+ - added `Object newInstance(Class)` method support of mapped classes to generate local class member instances
- added generating of `makeFIELD()` method for structure types in Java class converter
- refactoring
@@ -67,7 +67,7 @@ The Framework has been published in the Maven Central and can be easily added as
com.igormaznitsajbbp
- 1.4.1
+ 2.0.0
```
the precompiled library jar, javadoc and sources also can be downloaded directly from [the Maven central.](http://search.maven.org/#browse|808871750)
@@ -83,7 +83,7 @@ The Easiest case below shows how to parse byte array to bits.
Of course sometime it is not a comfortable way to look for parsed fields in the result, so you can use mapping of parsed data to class fields.
```Java
class Parsed {@Bin(type = BinType.BIT_ARRAY)byte[] parsed;}
-Parsed parsedBits = JBBPParser.prepare("bit:1 [_] parsed;").parse(new byte[]{1,2,3,4,5}).mapTo(Parsed.class);
+Parsed parsedBits = JBBPParser.prepare("bit:1 [_] parsed;").parse(new byte[]{1,2,3,4,5}).mapTo(new Parsed());
```
# Relative speed of different approaches in parsing
@@ -100,7 +100,7 @@ Since 1.3.0 version, the framework can convert JBBP scripts into sources __(the
For instance you can use such simple snippet to generate Java classes from JBBP script, potentially it can generate many classes but usually only one class
```Java
JBBPParser parser = JBBPParser.prepare("byte a; byte b; byte c;");
- List generated = parser.convertToSrc(TargetSources.JAVA_1_6,"com.test.jbbp.gen.SomeClazz");
+ List generated = parser.convertToSrc(TargetSources.JAVA,"com.test.jbbp.gen.SomeClazz");
for(ResultSrcItem i : generated) {
for(Map.Entry j :i.getResult().entrySet()) {
System.out.println("Class file name "+j.getKey());
@@ -114,7 +114,7 @@ in Maven you should just add such plugin execution
com.igormaznitsajbbp-maven-plugin
- 1.4.1
+ 2.0.0gen-jbbp-src
@@ -138,7 +138,7 @@ class Flags {
}
final int data = 0b10101010;
- Flags parsed = JBBPParser.prepare("bit:1 f1; bit:2 f2; bit:1 f3; bit:4 f4;", JBBPBitOrder.MSB0).parse(new byte[]{(byte)data}).mapTo(Flags.class);
+ Flags parsed = JBBPParser.prepare("bit:1 f1; bit:2 f2; bit:1 f3; bit:4 f4;", JBBPBitOrder.MSB0).parse(new byte[]{(byte)data}).mapTo(new Flags());
assertEquals(1,parsed.flag1);
assertEquals(2,parsed.flag2);
assertEquals(0,parsed.flag3);
@@ -302,9 +302,12 @@ final JBBPParser pngParser = JBBPParser.prepare(
class Png {
long header;
Chunk [] chunk;
+ public Object newInstance(Class> klazz){
+ return klazz == Chunk.class ? new Chunk() : null;
+ }
}
- final Png png = pngParser.parse(pngStream).mapTo(Png.class);
+ final Png png = pngParser.parse(pngStream).mapTo(new Png());
```
The Example from tests shows how to parse a tcp frame wrapped in a network frame
```Java
diff --git a/changelog.txt b/changelog.txt
index 7597e6e3..fa932e56 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,11 +1,11 @@
-2.0.0-SNAPSHOT
+2.0.0
- __removed DslBinCustom annotation, use @Bin annotation instead__
- __renamed attributes of @Bin annotation to their correct form__
- __reworked object mapping system, removed hacks to instantiate classes, now only mapping to objects allowed, support of private fields mapping is removed__
- __minimal JDK version now 1.8+__
- __minimal Android API now 3.0+__
- added support of getters and setters into mapping
- - added `Object newInstance(Class)` method support of mapped classes to generate instances for local classes
+ - added `Object newInstance(Class)` method support of mapped classes to generate local class member instances
- added generating of `makeFIELD()` method for structure types in Java class converter
- refactoring
diff --git a/docs/jbbp_mm.png b/docs/jbbp_mm.png
index 30bd9df5..b0e3c9ab 100644
Binary files a/docs/jbbp_mm.png and b/docs/jbbp_mm.png differ
diff --git a/jbbp-plugins/jbbp-gradle/build.gradle b/jbbp-plugins/jbbp-gradle/build.gradle
index 411cfefb..4439a35f 100644
--- a/jbbp-plugins/jbbp-gradle/build.gradle
+++ b/jbbp-plugins/jbbp-gradle/build.gradle
@@ -7,7 +7,7 @@ def getProp(name, dflt) {
}
}
-def jbbpVersion = getProp('jbbp_plugin_version', '2.0.0-SNAPSHOT')
+def jbbpVersion = getProp('jbbp_plugin_version', '2.0.0')
def metaLibVersion = getProp('meta_lib_version', '1.1.2')
group = 'com.igormaznitsa'
diff --git a/jbbp-plugins/jbbp-gradle/pom.xml b/jbbp-plugins/jbbp-gradle/pom.xml
index d321fe92..1869d78e 100644
--- a/jbbp-plugins/jbbp-gradle/pom.xml
+++ b/jbbp-plugins/jbbp-gradle/pom.xml
@@ -6,7 +6,7 @@
com.igormaznitsajbbp-main-plugin-pom
- 2.0.0-SNAPSHOT
+ 2.0.0jbbp-gradle-plugin
@@ -22,6 +22,8 @@
+ 1.8
+ 1.8install
diff --git a/jbbp-plugins/jbbp-maven/jbbp-maven-plugin-tests/pom.xml b/jbbp-plugins/jbbp-maven/jbbp-maven-plugin-tests/pom.xml
index 57b32103..35a7372c 100644
--- a/jbbp-plugins/jbbp-maven/jbbp-maven-plugin-tests/pom.xml
+++ b/jbbp-plugins/jbbp-maven/jbbp-maven-plugin-tests/pom.xml
@@ -5,7 +5,7 @@
com.igormaznitsajbbp-maven-plugin-pom
- 2.0.0-SNAPSHOT
+ 2.0.0jbbp-maven-plugin-tests
diff --git a/jbbp-plugins/jbbp-maven/jbbp-maven-plugin/pom.xml b/jbbp-plugins/jbbp-maven/jbbp-maven-plugin/pom.xml
index f973a1bc..da14e4fd 100644
--- a/jbbp-plugins/jbbp-maven/jbbp-maven-plugin/pom.xml
+++ b/jbbp-plugins/jbbp-maven/jbbp-maven-plugin/pom.xml
@@ -5,7 +5,7 @@
com.igormaznitsajbbp-maven-plugin-pom
- 2.0.0-SNAPSHOT
+ 2.0.0jbbp-maven-plugin
@@ -14,6 +14,11 @@
JBBP Maven pluginGenerator of sources from JBBP scripts
+
+ 1.8
+ 1.8
+
+
publish
@@ -61,6 +66,9 @@
jar
+
+
+
diff --git a/jbbp-plugins/jbbp-maven/jbbp-maven-plugin/src/test/resources/com/igormaznitsa/jbbp/plugin/mvn/mojoConfig.xml b/jbbp-plugins/jbbp-maven/jbbp-maven-plugin/src/test/resources/com/igormaznitsa/jbbp/plugin/mvn/mojoConfig.xml
index afa14b5d..fe885ba0 100644
--- a/jbbp-plugins/jbbp-maven/jbbp-maven-plugin/src/test/resources/com/igormaznitsa/jbbp/plugin/mvn/mojoConfig.xml
+++ b/jbbp-plugins/jbbp-maven/jbbp-maven-plugin/src/test/resources/com/igormaznitsa/jbbp/plugin/mvn/mojoConfig.xml
@@ -14,7 +14,7 @@
com.igormaznitsajbbp-maven-plugin
- 2.0.0-SNAPSHOT
+ 2.0.0generate
diff --git a/jbbp-plugins/jbbp-maven/pom.xml b/jbbp-plugins/jbbp-maven/pom.xml
index 8fcf8f4b..565a123f 100644
--- a/jbbp-plugins/jbbp-maven/pom.xml
+++ b/jbbp-plugins/jbbp-maven/pom.xml
@@ -5,7 +5,7 @@
com.igormaznitsajbbp-main-plugin-pom
- 2.0.0-SNAPSHOT
+ 2.0.0jbbp-maven-plugin-pom
diff --git a/jbbp-plugins/jbbp-plugin-common/pom.xml b/jbbp-plugins/jbbp-plugin-common/pom.xml
index f8e53fa1..5f1e9580 100644
--- a/jbbp-plugins/jbbp-plugin-common/pom.xml
+++ b/jbbp-plugins/jbbp-plugin-common/pom.xml
@@ -6,7 +6,7 @@
com.igormaznitsajbbp-main-plugin-pom
- 2.0.0-SNAPSHOT
+ 2.0.0jbbp-plugin-common
diff --git a/jbbp-plugins/pom.xml b/jbbp-plugins/pom.xml
index 57e3cf32..e78dcf7c 100644
--- a/jbbp-plugins/pom.xml
+++ b/jbbp-plugins/pom.xml
@@ -5,7 +5,7 @@
com.igormaznitsajbbp-main-pom
- 2.0.0-SNAPSHOT
+ 2.0.0jbbp-main-plugin-pom
diff --git a/jbbp/pom.xml b/jbbp/pom.xml
index 1821ec93..28773a8d 100644
--- a/jbbp/pom.xml
+++ b/jbbp/pom.xml
@@ -5,7 +5,7 @@
com.igormaznitsajbbp-main-pom
- 2.0.0-SNAPSHOT
+ 2.0.0jbbp
@@ -16,6 +16,11 @@
own DSL to describe parsing data format
+
+ 1.8
+ 1.8
+
+
org.openjdk.jmh
@@ -164,6 +169,9 @@
jar
+
+
+
diff --git a/jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitOutputStream.java b/jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitOutputStream.java
index 4f4f6d1e..932564b8 100644
--- a/jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitOutputStream.java
+++ b/jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitOutputStream.java
@@ -17,7 +17,6 @@
package com.igormaznitsa.jbbp.io;
import com.igormaznitsa.jbbp.utils.JBBPUtils;
-
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -418,6 +417,7 @@ public void writeString(final String value, final JBBPByteOrder order) throws IO
* the byte order in saved char data will be BIG_ENDIAN
*
* @param value array to be written, must not be null but can contain null values
+ * @param order byte order to write char data, must not be null
* @throws IOException it will be thrown for transport errors
* @see #writeString(String, JBBPByteOrder)
* @since 1.4.0
diff --git a/jbbp/src/main/java/com/igormaznitsa/jbbp/mapper/Bin.java b/jbbp/src/main/java/com/igormaznitsa/jbbp/mapper/Bin.java
index 644915eb..2988d34a 100644
--- a/jbbp/src/main/java/com/igormaznitsa/jbbp/mapper/Bin.java
+++ b/jbbp/src/main/java/com/igormaznitsa/jbbp/mapper/Bin.java
@@ -33,7 +33,7 @@
* from parsed a JBBP structure. Also it can be used for whole class but in the
* case be careful and use default name and path values. The Class is not thread safe.
*
- * >Since 2.0.0 was removed prefix 'out' for fields which contained it.
+ * Since 2.0.0 was removed prefix 'out' for fields which contained it.
*
* @since 1.0
*/
diff --git a/jbbp/src/main/java/com/igormaznitsa/jbbp/model/JBBPFieldStruct.java b/jbbp/src/main/java/com/igormaznitsa/jbbp/model/JBBPFieldStruct.java
index 5df7a55c..891fe13a 100644
--- a/jbbp/src/main/java/com/igormaznitsa/jbbp/model/JBBPFieldStruct.java
+++ b/jbbp/src/main/java/com/igormaznitsa/jbbp/model/JBBPFieldStruct.java
@@ -16,6 +16,9 @@
package com.igormaznitsa.jbbp.model;
+import static com.igormaznitsa.jbbp.utils.JBBPUtils.ARRAY_FIELD_EMPTY;
+
+
import com.igormaznitsa.jbbp.compiler.JBBPNamedFieldInfo;
import com.igormaznitsa.jbbp.exceptions.JBBPFinderException;
import com.igormaznitsa.jbbp.exceptions.JBBPTooManyFieldsFoundException;
@@ -24,11 +27,8 @@
import com.igormaznitsa.jbbp.model.finder.JBBPFieldFinder;
import com.igormaznitsa.jbbp.utils.Function;
import com.igormaznitsa.jbbp.utils.JBBPUtils;
-
import java.util.List;
-import static com.igormaznitsa.jbbp.utils.JBBPUtils.ARRAY_FIELD_EMPTY;
-
/**
* Describes a structure.
*
@@ -224,9 +224,10 @@ public T findFieldForPathAndType(final String fiel
* Find a structure by its path and map the structure fields to a class
* fields.
*
- * @param a class type
- * @param path the path to the structure to be mapped, must not be null
- * @param instance object instance to be filled by values, must not be null
+ * @param a class type
+ * @param path the path to the structure to be mapped, must not be null
+ * @param instance object instance to be filled by values, must not be null
+ * @param instantiators array of functions which can instantiate object of required class, must not be null
* @return a mapped instance of the class, must not be null
* @since 2.0.0
*/
@@ -239,10 +240,11 @@ public final T mapTo(final String path, final T instance, final Function a class type
- * @param path the path to the structure to be mapped, must not be null
- * @param instance object instance to be filled by values, must not be null
- * @param flags special flags to tune mapping process
+ * @param a class type
+ * @param path the path to the structure to be mapped, must not be null
+ * @param instance object instance to be filled by values, must not be null
+ * @param flags special flags to tune mapping process
+ * @param instantiators array of functions which can instantiate object of required class, must not be null
* @return a mapped instance of the class, must not be null
* @see JBBPMapper#FLAG_IGNORE_MISSING_VALUES
* @since 2.0.0
@@ -260,6 +262,7 @@ public final T mapTo(final String path, final T instance, final int flags, f
* @param path the path to the structure to be mapped, must not be null
* @param instance object instance to be filled by values, must not be null
* @param customFieldProcessor a custom field processor to provide values for custom mapping fields, it can be null if there is not any custom field
+ * @param instantiators array of functions which can instantiate object of required class, must not be null
* @return a mapped instance of the class, must not be null
* @since 2.0.0
*/
@@ -277,6 +280,7 @@ public final T mapTo(final String path, final T instance, final JBBPMapperCu
* @param instance object instance to be filled by values, must not be null
* @param customFieldProcessor a custom field processor to provide values for custom mapping fields, it can be null if there is not any custom field
* @param flags special flags to tune mapping process
+ * @param instantiators array of functions which can instantiate object of required class, must not be null
* @return a mapped instance of the class, must not be null
* @see JBBPMapper#FLAG_IGNORE_MISSING_VALUES
* @since 2.0.0
@@ -289,8 +293,10 @@ public final T mapTo(final String path, final T instance, final JBBPMapperCu
/**
* Map the structure fields to object fields.
*
- * @param objectToMap an object to map fields of the structure, must not be
- * null
+ * @param expected result type
+ * @param objectToMap an object to map fields of the structure, must not be
+ * null
+ * @param instantiators array of functions which can instantiate object of required class, must not be null
* @return the same object from the arguments but with filled fields by values
* of the structure
*/
@@ -302,8 +308,10 @@ public final T mapTo(final T objectToMap, final Function, Object>..
/**
* Map the structure fields to object fields.
*
- * @param instance object instance to be filled by values, must not be null
- * @param flags special flags to tune mapping process
+ * @param expected result type
+ * @param instance object instance to be filled by values, must not be null
+ * @param flags special flags to tune mapping process
+ * @param instantiators array of functions which can instantiate object of required class, must not be null
* @return the same object from the arguments but with filled fields by values
* of the structure
* @see JBBPMapper#FLAG_IGNORE_MISSING_VALUES
@@ -317,12 +325,12 @@ public final T mapTo(final T instance, final int flags, final Function the type of the input and the output to the function
+ * @param expected result type
* @param instance an object to map fields of the structure, must not be
* null
* @param customFieldProcessor a custom field processor to provide values for
* custom mapping fields, it can be null if there is not any custom field
- * @param instantiators auxiliary functions to generate instances of classes by request
+ * @param instantiators array of functions which can instantiate object of required class, must not be null
* @return the same object from the arguments but with filled fields by values
* of the structure
*/
@@ -334,14 +342,13 @@ public final T mapTo(final T instance, final JBBPMapperCustomFieldProcessor
/**
* Map the structure fields to object fields.
*
- * @param the type of the input and the output to the function
+ * @param expected result type
* @param objectToMap an object to map fields of the structure, must not be
* null
* @param customFieldProcessor a custom field processor to provide values for
* custom mapping fields, it can be null if there is not any custom field
* @param flags special flags to tune mapping process
- * @param instantiators auxiliary functions to generate instances of
- * classes by request
+ * @param instantiators array of functions which can instantiate object of required class, must not be null
* @return the same object from the arguments but with filled fields by values
* of the structure
* @see JBBPMapper#FLAG_IGNORE_MISSING_VALUES
diff --git a/jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java b/jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java
index 13d9a69c..c4add02b 100644
--- a/jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java
+++ b/jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPDslBuilder.java
@@ -432,6 +432,7 @@ public JBBPDslBuilder VarArray(final String sizeExpression) {
/**
* Create named var array with fixed size.
*
+ * @param name name of the array, can be null for anonymous one
* @param size size of the array, if negative then read till end of stream.
* @return the builder instance, must not be null
*/
@@ -1371,6 +1372,7 @@ public JBBPDslBuilder String() {
/**
* Add named string field.
*
+ * @param name name of field, can be null for anonymous one
* @return the builder instance, must not be null
*/
public JBBPDslBuilder String(final String name) {
diff --git a/jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPTextWriter.java b/jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPTextWriter.java
index da5e3afa..a6f712da 100644
--- a/jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPTextWriter.java
+++ b/jbbp/src/main/java/com/igormaznitsa/jbbp/utils/JBBPTextWriter.java
@@ -325,6 +325,7 @@ public JBBPTextWriter(
* Auxiliary method allows to build writer over StringWriter with system-depended next line and hex radix.
* The Method allows fast instance create.
*
+ * @return the text writer instance, must not be null
* @since 1.4.0
*/
public static JBBPTextWriter makeStrWriter() {
diff --git a/pom.xml b/pom.xml
index ad81dee6..bfe94a25 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
com.igormaznitsajbbp-main-pom
- 2.0.0-SNAPSHOT
+ 2.0.0pom
@@ -21,7 +21,7 @@
yyyyMMddHHmm3.01.1.2
- 2.0.0-SNAPSHOT
+ 2.0.0${jbbp.version}1.81.8