Skip to main content

Getting Started

Object Data Structure has two different modes. Learn about them here.

Welcome to Object Data Structure! Most implementations of ODS are very similar to each other with minor differences.

All implementations of ODS have an ObjectDataStructure class. This class allows you to define what you want to do with ODS. ODS allows you to save/load from file or memory.

File vs Memory Mode

ODS has two modes that you can pick from that determines how ODS handles data. Those two modes are File and Memory modes.

File Mode

When ODS is in file mode, all data is written to and read from a file. You have the option to compress that file to make the space used up on the hard drive lower. Note: When compression is used, the entire file must be read due to the nature of compression algorithms.
When in File Mode no memory is cached at all and all operations read/write the file directly. If this is an issue, than it is recommended to use Memory Mode as it has options to export the data to a file (also with compression).

Memory Mode

Memory Mode is considered to be more efficient than File Mode since all operations are done on an internal buffer instead of on a hard drive. This is probably the best general purpose mode to use when working with ODS.

Both Modes

Both modes support exporting bytes to memory and a file. These export methods also allows you to define a compression algorithm to use.

The ObjectDataStructure Class

In order to use the basic functionality of ODS you need to import (or use) the classes/structs required by ODS.

import me.ryandw11.ods;

As stated above, in all implementation you must construct an ObjectDataStructure object in order to use ODS. You can have multiple ObjectDataStructures going at once.

info

The ObjectDataStructure class should only be used on a single thread to prevent IO conflicts. It is recommended to use a thread separate from the main one if in File Mode.

In Java you can pick between the different constructors to determine file vs memory.

You can see the different constructor in the JavaDocs.

For File Mode:

ObjectDataStructure ods = new ObjectDataStructure(new File("test.ods"));

For Memory Mode:

ObjectDataStructure ods = new ObjectDataStructure();

Now you are ready to save or load data from a file. We will be covering Creating and Saving tags next.