The great leap forward, leaving the old behind, striving for the new!
<dependencies>
<dependency>
<groupId>org.ugp.serialx</groupId>
<artifactId>serialx-json</artifactId>
<version>1.3.8</version> <!-- Specify newer version if needed -->
</dependency>
</dependencies>
<repositories>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/SimplyProgrammer/Java-SerialX</url>
</repository>
</repositories>
What was added:
Maven:
- The whole library was modularized using Maven into the following modules:
- SerialX-core - Contains core features and utilities shared across the library. It also contains basic protocols and parsers that resemble the functionalities of pre-1.2.X SerialX.
- SerialX-juss - Now contains everything JUSS related, features that were added roughly in 1.2 and later... This includes things like JussSerializer, ArrayConverter, OperationGroups etc...
- SerialX-json - A relatively small extension of the JUSS module that is more narrowly focused on JSON. This is now where SerialX support for JSON is located.
- SerialX-operators - An extensional module, this is now where all operator parsers are located.
- SerialX-devtools - Small module containing tools for debugging the library, mainly Parser/Converter API. It is intended for DSL developers and people who want to add their own data formats.
- From now on Maven will be used for dependency management and building of this library.
- Distribution of this library will be conducted using Maven from now on.
- This greatly simplifies a lot of lengthy, complex IDE-specific processes.
Unit tests and benchmarks:
- Some examples are now used as unit tests, this should greatly simplify the testing process and reduce the chance of bug introduction in the future.
- These are now located on the new "tests-and-experimental-features" branch. This branch will be used for demonstrations, benchmarking, testing and experimenting. Note that this branch is not part of the main API.
Specific changes:
- Library is now compatible with JDK versions up to 21 (probably even newer but it was not tested)!
- ImportsProvider now implements caching for Imports.
- ParserRegistry now implements DataParser allowing for easier creation of more complex (context-free) languages.
- NumberConverter was refactored, now providing all in one parsing numberOf function that is on average 12x faster than the old implementation.
- New numberOf function supports octadecimal number and has improved handling of E-notation.
- Java integer caching is now in place.
- DecimalFormater was dumped in favor of the more customizable overridable format method.
- BooleanConverter and NullConverter were slightly refactored allowing for near O(1) complexity of parsing.
- ObjectConverter got a significant refactor!
- It was separated into 2 separate classes across 2 modules. Now it is ProtocolConverter that is extended by ObjectConverter.
- Static member invocation is now only allowed on a small carefully selected group of classes, fixing the major security exploit that would an attacker to call any static function in a hypothetical REST implementation.
- Both ObjectConverter and ProtocolConverter were slightly optimized.
- StringConverter was slightly optimized by introducing caching. It is disabled by default, by enabling it the same String instance will be returned for the same strings during parsing.
- Static variables were made instance-specific allowing for more flexibility.
- GenericScope and Scope received various API improvements, the most notable ones being:
- GenericScope now implements Collection instead of just Iterable making it part of Java collection API.
- From/Into API now partially supports recognition for generic types of declared Object variables, making it more useful for non-JUSS formats such as JSON. This enhances also AutoProtocol and UniversalObjectInstantiationProtocol together with SelfSerializableProtocol.
- Mode of SerializationProtocol is now implemented with 64 int (long) bit-packing which allows for chaining of multiple modes which can now be understood as protocol types. This trades an overall number of unique modes for greater utility.
- Serializer (and core high-level changes):
- The concept of scope parent variable inheritance was abandoned due to being unacceptable and inefficient (both time and space-wise...), quite error-prone and tedious to work with as well as and potentially dangerous. Not mentioning the fact that the only reason for its existence was to allow you to access variables declared in the parent scope, for which it suboptimal solution to say at least...
- In a similar fashion, the notion of each parser having to return the new instance of respective object for every parsed string was abandoned as well and is no longer required, allowing for more flexibility and concepts such as already mentioned caching!
- OOP NULL was abandoned as well as it was a biproduct of sub-optimal decisions mentioned above and therefore conceptually flawed. It is deprecated and should not be used!
- All static utility functions (for instance string analyses and processing functions) were separated into new Utils class, in order to achieve better separation of concerns...
- All string analyses and processing utility functions (for example indexOfNotInObj or splitValues) were rewritten into more "finite state machine"-like form which slightly increases their performance...
- Some new utility functions were added and existing ones were improved!
- Operation group mark of OperationGroups (parentheses operator) is no longer static and always the same, now it is shorter and pseudo-randomly generated which slightly increases the performance and highly mitigates the hypothetical "Group mark injection" attack which would result in unauthorized access to group mark at runtime.
- UniversalObjectInstantiationProtocol is no longer registered by default and now requires manual registration for a specific class, this enhances security since instantiation of any object (dangerous or not) is prevented.
- The same goes for SelfSerializableProtocol.
- JsonSerializer received many improvements and bug fixes in order to match JSON more accurately.
- Dedicated JsonCharacterConverter and JsonNumberConverter were added for this. Also, JsonObjectConverter was separated into its own class.
- Operators class was added, which is used for injecting all operator parsers into the specific registry.
- Almost every operator parser was refactored, resulting in simpler, shorter and therefore more optimized code. The most notable ones are:
- ArithmeticOperators which now also allows you to declare your own arithmetic operators and/or specify their precedence.
- Due to refactoring, ResultWrapper is no longer needed and will be removed, this extends to LogicalOperators as well.
- NegationOperator now supports separate handling of logical negation (! operator) and mathematical negation (- operator), however by default their behavior is the same.
- The ability to specify custom output PrintWriter was added for SerializationDebugger.
- Besides the changes mentioned above, countless smaller improvements including numerous bug fixes, performance improvements, API enhancements or Javadoc specifications were added across the whole library.
- Some functions were slightly renamed but it is usually documented but deprecated functions were removed!