https://github.com/phax/phive-binary
A validation library for binary formats inspired by phive
https://github.com/phax/phive-binary
Last synced: about 1 year ago
JSON representation
A validation library for binary formats inspired by phive
- Host: GitHub
- URL: https://github.com/phax/phive-binary
- Owner: phax
- License: apache-2.0
- Created: 2024-01-30T11:53:41.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-15T10:14:11.000Z (about 2 years ago)
- Last Synced: 2024-04-16T07:44:20.870Z (about 2 years ago)
- Language: Java
- Size: 94.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# phive-binary
[](https://javadoc.io/doc/com.helger.phive/phive-binary)
[](https://maven-badges.herokuapp.com/maven-central/com.helger.phive/phive-binary)
A validation library for binary formats inspired by phive.
The goal of the library is to make sure, that certain binary file types can be checked for validity based on either file extension or MIME Type.
This project is part of my Peppol solution stack. See https://github.com/phax/peppol for other components and libraries in that area.
# Basic usage
Each file format is implemented as an instance of `IFileFormatDescriptor`.
Each file format is registered into the singleton instance `FileFormatRegistry.getInstance ()`.
Based on a file extension (e.g. `pdf`) or based on a MIME type (e.g. `application/pdf`) you need to get the `IFileFormatDescriptor` you need.
And for each file format descriptor several content validators may be available.
Via `getContentValidatorFavourSpeed ()` or `getContentValidatorFavourAccuracy ()` the matching `IPhiveContentValidator` can be retrieved.
And finally the content validator does the actual matching.
So to summarize:
1. Get `IFileFormatDescriptor` from `FileFormatRegistry.getInstance ()`
1. Choose the `IPhiveContentValidator` from the file format descriptor (this object can be cached by the way)
1. Let the content validator check if the provided value matches
# Extensibility
All known file formats are loaded via [SPI](https://docs.oracle.com/javase/tutorial/ext/basics/spi.html).
By implementing the `com.helger.phive.binary.IFileFormatRegistrarSPI` in your application, custom file formats can be added.
# Maven usage
Add the following to your pom.xml to use this artifact, replacing `x.y.z` with the real version number:
```xml
com.helger.phive
phive-binary
x.y.z
```
# News and Noteworthy
* v0.1.0 - 2024-01-31
* Initial version
* Supported formats are: CSV (no content validator), GIF, JPG, PDF, PNG, PSD, TIFF, XLS, XSLX and XML