com.revusky.niggle.data
Class DefaultRecordInputStream
java.lang.Object
|
+--java.io.InputStream
|
+--java.io.FilterInputStream
|
+--java.io.DataInputStream
|
+--com.revusky.niggle.data.DefaultRecordInputStream
- All Implemented Interfaces:
- java.io.DataInput, java.io.ObjectInput, ValidatingRecordInput
- public class DefaultRecordInputStream
- extends java.io.DataInputStream
- implements java.io.ObjectInput, ValidatingRecordInput
An implementation of the ObjectInput interface
for slurping Records off a stream in their
default flat-file format, which is not
the standard Java serialised object format.
Objects are ASCII serialised in a format like this:
_meta=reminder.1
unique_id=1
creation_date=Nov 17, 1999 8:03:15 AM
name=vitamin
...
The stream will be a complete clean rewrite of all live persistent objects followed
by some appended delete and add records of changes since the last complete rewrite.
The append section could contain obsolete records, deleted and added repeatedly.
- Author:
- Jonathan Revusky jon@revusky.com
Fields inherited from class java.io.FilterInputStream |
in |
Method Summary |
protected java.lang.String |
getTypeInfo()
Read the first line of the record data,
which tells us what type of record this is. |
java.lang.Object |
readObject()
Read the next record off the stream. |
Methods inherited from class java.io.DataInputStream |
read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, readUTF, skipBytes |
Methods inherited from class java.io.FilterInputStream |
available, close, mark, markSupported, read, reset, skip |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.io.ObjectInput |
available, close, read, read, read, skip |
Methods inherited from interface java.io.DataInput |
readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, skipBytes |
DELETION_MARKER
public static final java.lang.String DELETION_MARKER
INSERTION_MARKER
public static final java.lang.String INSERTION_MARKER
UPDATE_MARKER
public static final java.lang.String UPDATE_MARKER
DefaultRecordInputStream
public DefaultRecordInputStream(java.io.InputStream is)
- Constructor, given stream
- Parameters:
is
- the underlying stream to read persistent data from.
DefaultRecordInputStream
public DefaultRecordInputStream(java.io.File file)
throws java.io.IOException
- a convenience constructor that takes a File argument.
- Parameters:
file
- File from which to read the persistent data.- Throws:
java.io.IOException
-
readObject
public java.lang.Object readObject()
throws java.io.IOException,
java.lang.ClassNotFoundException
- Read the next record off the stream.
- Specified by:
readObject
in interface java.io.ObjectInput
- Returns:
- null if this is the end of the stream.
getTypeInfo
protected java.lang.String getTypeInfo()
throws java.io.IOException
- Read the first line of the record data,
which tells us what type of record this is.
- Returns:
- record type e.g. "reminder.1