|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.joanju.DataXferStream
public class DataXferStream
Serialize objects to a blob optimized for random access. Objects of this class must only be used within a single thread.
Several hours of searching the internet turned up many different tools for serialization, but none of them (that I could find) were designed with direct, fast random access as the primary consideration.
This and Xferable are designed such that it is self-describing, and if the output class 'schemas' are used correctly, there should never be a reason for the addition of new data fields added to the output to break any code using 'old' versions of the schema. Each byte offset is written with a field-reference-name, and the schema is written to every blob.
Constructor Summary | |
---|---|
DataXferStream()
|
Method Summary | |
---|---|
void |
addSchemaFor(Xferable x)
May be used for building an xfer blob just for schema purposes. |
void |
buildIndexes()
Must be called after all objects have been stored. |
java.io.ByteArrayOutputStream |
getBytes()
Once buildIndex() has been called, then use this to get the blob. |
int |
getIndexOffset()
|
int |
getOffsetOf(java.lang.Object o)
Get the offset of an object that's already been stored. |
int |
getSchemaMapOffset()
|
void |
schemaBool(java.lang.String fieldName)
|
void |
schemaInt(java.lang.String fieldName)
|
void |
schemaRef(java.lang.String fieldName)
|
int |
size()
Get the size in bytes. |
int |
store(java.lang.Object o)
Store an object and any object hierarchy that comes with it. |
void |
writeBool(boolean b)
Called by Xferable.writeXferBytes() for boolean fields. |
void |
writeInt(int i)
Called by Xferable.writeXferBytes() for int fields. |
void |
writeRef(java.lang.Object o)
Called by Xferable.writeXferBytes(). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DataXferStream()
Method Detail |
---|
public void addSchemaFor(Xferable x)
public void buildIndexes() throws java.io.IOException
java.io.IOException
public java.io.ByteArrayOutputStream getBytes()
public int getIndexOffset()
public int getSchemaMapOffset()
public int getOffsetOf(java.lang.Object o) throws java.io.IOException
java.io.IOException
public void schemaBool(java.lang.String fieldName) throws java.io.IOException
java.io.IOException
public void schemaInt(java.lang.String fieldName) throws java.io.IOException
java.io.IOException
public void schemaRef(java.lang.String fieldName) throws java.io.IOException
java.io.IOException
public int size()
public int store(java.lang.Object o) throws java.io.IOException
java.io.IOException
public void writeBool(boolean b) throws java.io.IOException
java.io.IOException
public void writeInt(int i) throws java.io.IOException
java.io.IOException
public void writeRef(java.lang.Object o) throws java.io.IOException
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |