Object Data Structure is a file format inspired by NBT. Everything in this file format is made of tags.
ODS is not human-readable, data is stored in bytes.
Requires Java 8+
Access release builds of Object Data Structure by using the following methods:
Maven:
<repositories>
<repository>
<id>ObjectDataStructure</id>
<url>https://repo.ryandw11.com/repository/maven-releases/</url>
</repository>
</repositories>
<dependency>
<groupId>me.ryandw11</groupId>
<artifactId>ods</artifactId>
<version>1.0.5</version>
</dependency>
Gradle:
repositories {
maven { url 'https://repo.ryandw11.com/repository/maven-releases/' }
}
dependencies {
implementation 'me.ryandw11:ods:1.0.5'
}
Fat Jar:
You can get the fat jar from releases or get automatic builds from ci.ryandw11.com.
As stated above ODS uses tags. There are many primative tags: StringTag, IntTag, ShortTag, LongTag, ByteTag, DoubleTag, FloatTag.
There are also the ListTag and MapTag. They both store primative tags in a list and map format respectivly.
Finally there are ObjectTags. ObjectTags store other tags. For more information about the possibilites be sure to check out the wiki and javadoc!
The ODS class is full of useful methods that allow the easy serialization of primative objects.
The ODS class also allows the serialization of custom objects.
ObjectDataStructure ods = new ObjectDataStructure(new File("test.ods"));
List<Tag<?>> tags = new ArrayList<>();
tags.add(new StringTag("ExampleKey", "This is an example string!"));
tags.add(new IntTag("ExampleInt", 754));
ObjectTag car = new ObjectTag("Car");
car.addTag(new StringTag("type", "Jeep"));
car.addTag(new IntTag("gas", 30));
car.addTag(new ListTag<>("coords", ODS.wrap(Arrays.asList(10, 5, 10))));
ObjectTag owner = new ObjectTag("Owner");
owner.addTag(new StringTag("firstName", "Jeff"));
owner.addTag(new StringTag("lastName", "Bob"));
owner.addTag(new IntTag("Age", 30));
car.addTag(owner);
tags.add(car);
ods.save(tags);
System.out.println("The value of ExampleKey is: " + ods.<StringTag>get("ExampleKey").getValue());
ObjectTag myCar = ods.get("Car");
System.out.println("The car is a " + myCar.getTag("type").getValue());
StringTag ownerFirstName = ods.get("Car.Owner.firstName");
StringTag ownerLastName = ods.get("Car.Owner.lastName");
System.out.println("The owner of the car is " + ODS.unwrap(ownerFirstName) + " " + ODS.unwrap(ownerLastName));
This tool allows you inspect ods files.
Click here to go to the visualizer repository.
- C++ (Coming Soon)
- ODSSharp (C#)
- object-data-structure (Rust)
To port this to another language you just need to follow the file format specifications. The specifications for the ODS file type can be found below. Test ODS files can be found below. The Visualizer tool might be helpful.
- There are none! To add your port to this list open an issue or create a PR!
ODSCompressionPlus provides additional compression formats, such as: Zstd.
Each tag has a header consisting of 7 bytes.
1 Byte | 4 Bytes | 2 Bytes |
---|---|---|
The Data Type | The size of the tag (in bytes) starting from the next byte. | The number of bytes the key has. |
Byte | Type |
---|---|
0 | Reserved |
1 | String |
2 | int |
3 | Float |
4 | Double |
5 | Short |
6 | Long |
7 | Char |
8 | Byte |
9 | List |
10 | Map |
11 | Object |
12 | Compressed Object |
- None
- GZIP
- ZLIB