java.lang.Object
com.aoapps.lang.io.FastObjectInput
- All Implemented Interfaces:
DataInput,ObjectInput,AutoCloseable
Utilities to read
FastExternalizable, Externalizable, and Serializable objects.
When multiple objects are being written, this avoids the repetitive writing of classnames and serialVersionUIDs.
Any object that is ObjectInputValidation is validated immediately - there is no need
and no mechanism to register the validation since this is for simple value objects
that don't participate in more complex object graphs.
- Author:
- AO Industries, Inc.
-
Method Summary
Modifier and TypeMethodDescriptionintvoidclose()intread()intread(byte[] b) intread(byte[] b, int off, int len) booleanbytereadByte()charreadChar()doubleprotected FastExternalizableReads aFastExternalizableobject from the stream.Reads a fast serializedStringfrom the stream.floatvoidreadFully(byte[] b) voidreadFully(byte[] b, int off, int len) intreadInt()readLine()longreadLong()Reads a possibly-FastExternalizableobject from the stream.shortintintreadUTF()longskip(long n) intskipBytes(int n) voidunwrap()Unwraps the object input.static FastObjectInputwrap(ObjectInput in) Gets the wrapper for the providedObjectInput, creating if needed.
-
Method Details
-
wrap
Gets the wrapper for the providedObjectInput, creating if needed. To avoid memory leaks, it must also beunwrappedin a finally block.TODO: Can
FastObjectInputitself implementAutoCloseableforunwrap()? Maybe this means it no longer implementsObjectInputdirectly?- Throws:
IOException
-
unwrap
Unwraps the object input.- Throws:
IllegalStateException- if not wrapped
-
readObject
Reads a possibly-FastExternalizableobject from the stream.- Specified by:
readObjectin interfaceObjectInput- Throws:
IOExceptionClassNotFoundException- See Also:
-
readFastObject
Reads aFastExternalizableobject from the stream.- Throws:
IOExceptionClassNotFoundException- See Also:
-
readFastUTF
Reads a fast serializedStringfrom the stream.- Throws:
IOException- See Also:
-
read
- Specified by:
readin interfaceObjectInput- Throws:
IOException
-
read
- Specified by:
readin interfaceObjectInput- Throws:
IOException
-
read
- Specified by:
readin interfaceObjectInput- Throws:
IOException
-
skip
- Specified by:
skipin interfaceObjectInput- Throws:
IOException
-
available
- Specified by:
availablein interfaceObjectInput- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceObjectInput- Throws:
IOException
-
readFully
- Specified by:
readFullyin interfaceDataInput- Throws:
IOException
-
readFully
- Specified by:
readFullyin interfaceDataInput- Throws:
IOException
-
skipBytes
- Specified by:
skipBytesin interfaceDataInput- Throws:
IOException
-
readBoolean
- Specified by:
readBooleanin interfaceDataInput- Throws:
IOException
-
readByte
- Specified by:
readBytein interfaceDataInput- Throws:
IOException
-
readUnsignedByte
- Specified by:
readUnsignedBytein interfaceDataInput- Throws:
IOException
-
readShort
- Specified by:
readShortin interfaceDataInput- Throws:
IOException
-
readUnsignedShort
- Specified by:
readUnsignedShortin interfaceDataInput- Throws:
IOException
-
readChar
- Specified by:
readCharin interfaceDataInput- Throws:
IOException
-
readInt
- Specified by:
readIntin interfaceDataInput- Throws:
IOException
-
readLong
- Specified by:
readLongin interfaceDataInput- Throws:
IOException
-
readFloat
- Specified by:
readFloatin interfaceDataInput- Throws:
IOException
-
readDouble
- Specified by:
readDoublein interfaceDataInput- Throws:
IOException
-
readLine
- Specified by:
readLinein interfaceDataInput- Throws:
IOException
-
readUTF
- Specified by:
readUTFin interfaceDataInput- Throws:
IOException
-
