public class ODSMem extends java.lang.Object implements ODSInternal
Constructor and Description |
---|
ODSMem()
Does not pre-populate.
|
ODSMem(byte[] data,
Compressor compressor)
Import in pre-existing data.
|
ODSMem(java.nio.ByteBuffer buffer,
Compressor compressor)
Import in pre-existing data.
|
Modifier and Type | Method and Description |
---|---|
void |
append(Tag<?> tag)
Append tags to the end of the buffer.
|
void |
appendAll(java.util.List<Tag<?>> tags)
Append a list of tags to the end of the buffer.
|
void |
clear()
Clear the buffer.
|
boolean |
delete(java.lang.String key)
Remove a tag from the list.
|
byte[] |
export(Compressor compressor)
Get the array of bytes from the buffer.
|
boolean |
find(java.lang.String key)
Find if a key exists within the buffer.
|
<T extends Tag<?>> |
get(java.lang.String key)
Grab a tag based upon an object key.
|
java.util.List<Tag<?>> |
getAll()
Get all of the tags in the buffer.
|
void |
importFile(java.io.File file,
Compressor compressor)
Import a data from an ODS file into the buffer.
|
boolean |
replaceData(java.lang.String key,
Tag<?> replacement)
Replace a key with another tag.
|
void |
save(java.util.List<? extends Tag<?>> tags)
Save tags to the buffer.
|
void |
saveToFile(java.io.File file,
Compressor compressor)
Save data from the buffer into a file.
|
void |
set(java.lang.String key,
Tag<?> value)
This method can append, delete, and set tags.
|
public ODSMem(byte[] data, Compressor compressor)
data
- The array of data.compressor
- The compression used.public ODSMem(java.nio.ByteBuffer buffer, Compressor compressor)
buffer
- The buffer containing the data.compressor
- The compression used.public ODSMem()
public <T extends Tag<?>> T get(java.lang.String key)
This method allows you to directly get sub-objects with little overhead.
get("Object1.Object2.valuetag");
get
in interface ODSInternal
T
- The tag type.key
- The key to use.This will return null if the requested sub-object does not exist.
public java.util.List<Tag<?>> getAll()
getAll
in interface ODSInternal
This will return null if there are no tags.
public void save(java.util.List<? extends Tag<?>> tags)
This will overwrite the existing buffer. To append tags see append(Tag)
and appendAll(List)
save
in interface ODSInternal
tags
- The list of tags to save.public void append(Tag<?> tag)
append
in interface ODSInternal
tag
- The tag to be appended.public void appendAll(java.util.List<Tag<?>> tags)
appendAll
in interface ODSInternal
tags
- The list of tags.public boolean find(java.lang.String key)
find
in interface ODSInternal
key
- They key to findpublic boolean delete(java.lang.String key)
delete
in interface ODSInternal
key
- The key to remove.public boolean replaceData(java.lang.String key, Tag<?> replacement)
replaceData
in interface ODSInternal
key
- The keyreplacement
- The data to replacepublic void set(java.lang.String key, Tag<?> value)
A note on keys when appending: ObjectOne.ObjectTwo.tagName
When appending data tagName will not be the actual tag name.
The tag name written to the file is the name of the specified tag in the value parameter. Any parent objects that do not exist will be created. For example:
ObjectOne.ObjectTwo.NewObject.tagName
If in the example above NewObject does not exist, than the object will be created with the value tag inside
of it. Please see the wiki for a more detailed explanation on this.
When value is null, the specified key is deleted. The key MUST exist or an ODSException
will be thrown.
set
in interface ODSInternal
key
- The key of the tag to append, delete, or set.
When appending the key does not need to exist. ObjectTags that don't exist will be created automatically.
When the key is set to "" (An empty string) than it is assumed you want to append to the parent buffer.
Valid Tags:
ObjectOne.tagToDelete
ObjectOne.NewObject.tagToAppend
ObjectOne.tagToSet
value
- The tag to append or replace the key with. If this parameter is null than the key is deleted.
public byte[] export(Compressor compressor)
export
in interface ODSInternal
compressor
- The compression you want to use for the bytes.public void importFile(java.io.File file, Compressor compressor)
importFile
in interface ODSInternal
file
- The file to import from.compressor
- The compression of that file.public void saveToFile(java.io.File file, Compressor compressor)
saveToFile
in interface ODSInternal
file
- The file to save to.compressor
- The compression to use for that file.public void clear()
clear
in interface ODSInternal