public class BinaryExporter extends java.lang.Object implements JmeExporter
1. "number of classes" - four bytes - int value representing the number of entries in the class lookup table.
CLASS TABLE: There will be X blocks each consisting of numbers 2 thru 9, where X = the number read in 1.
2. "class alias" - 1...X bytes, where X = ((int) FastMath.log(aliasCount, 256) + 1) - an alias used when writing object data to match an object to its appropriate object class type.
3. "full class name size" - four bytes - int value representing number of bytes to read in for next field.
4. "full class name" - 1...X bytes representing a String value, where X = the
number read in 3. The String is the fully qualified class name of the Savable
class, eg "com.jme.math.Vector3f
"
5. "number of fields" - four bytes - int value representing number of blocks to read in next (numbers 6 - 9), where each block represents a field in this class.
6. "field alias" - 1 byte - the alias used when writing out fields in a class. Because it is a single byte, a single class can not save out more than a total of 256 fields.
7. "field type" - 1 byte - a value representing the type of data a field
contains. This value is taken from the static fields of
com.jme.util.export.binary.BinaryClassField
.
8. "field name size" - 4 bytes - int value representing the size of the next field.
9. "field name" - 1...X bytes representing a String value, where X = the number read in 8. The String is the full String value used when writing the current field.
10. "number of unique objects" - four bytes - int value representing the number of data entries in this file.
DATA LOOKUP TABLE: There will be X blocks each consisting of numbers 11 and 12, where X = the number read in 10.
11. "data id" - four bytes - int value identifying a single unique object that was saved in this data file.
12. "data location" - four bytes - int value representing the offset in the object data portion of this file where the object identified in 11 is located.
13. "future use" - four bytes - hardcoded int value 1.
14. "root id" - four bytes - int value identifying the top level object.
OBJECT DATA SECTION: There will be X blocks each consisting of numbers 15 thru 19, where X = the number of unique location values named in 12.
15. "class alias" - see 2.
16. "data length" - four bytes - int value representing the length in bytes of data stored in fields 17 and 18 for this object.
FIELD ENTRY: There will be X blocks each consisting of numbers 18 and 19
17. "field alias" - see 6.
18. "field data" - 1...X bytes representing the field data. The data length is dependent on the field type and contents.
Modifier and Type | Field and Description |
---|---|
protected int |
aliasCount |
static boolean |
debug |
protected int |
idCount |
protected java.util.HashMap<java.lang.Integer,java.lang.Integer> |
locationTable |
static boolean |
useFastBufs |
Constructor and Description |
---|
BinaryExporter() |
Modifier and Type | Method and Description |
---|---|
protected byte[] |
fixClassAlias(byte[] bytes,
int width) |
protected byte[] |
generateTag() |
OutputCapsule |
getCapsule(Savable object)
Returns the
OutputCapsule for the given savable object. |
static BinaryExporter |
getInstance() |
int |
processBinarySavable(Savable object) |
void |
save(Savable object,
java.io.File f)
Export the
Savable to a file. |
void |
save(Savable object,
java.io.OutputStream os)
Export the
Savable to an OutputStream. |
static <T extends Savable> |
saveAndLoad(AssetManager assetManager,
T object)
Saves the object into memory then loads it from memory.
|
protected int aliasCount
protected int idCount
protected java.util.HashMap<java.lang.Integer,java.lang.Integer> locationTable
public static boolean debug
public static boolean useFastBufs
public static BinaryExporter getInstance()
public static <T extends Savable> T saveAndLoad(AssetManager assetManager, T object)
T
- The type of savable.assetManager
- AssetManager to load assets from.object
- The object to save and then load.public void save(Savable object, java.io.OutputStream os) throws java.io.IOException
JmeExporter
Savable
to an OutputStream.save
in interface JmeExporter
object
- The savable to exportos
- The output streamjava.io.IOException
- If an io exception occurs during exportprotected byte[] fixClassAlias(byte[] bytes, int width)
public void save(Savable object, java.io.File f) throws java.io.IOException
JmeExporter
Savable
to a file.save
in interface JmeExporter
object
- The savable to exportf
- The file to export tojava.io.IOException
- If an io exception occurs during exportpublic OutputCapsule getCapsule(Savable object)
JmeExporter
OutputCapsule
for the given savable object.getCapsule
in interface JmeExporter
object
- The object to retrieve an output capsule for.OutputCapsule
for the given savable object.public int processBinarySavable(Savable object) throws java.io.IOException
java.io.IOException
protected byte[] generateTag()