Class SafeObjectOutputStream
java.lang.Object
org.apache.axis2.context.externalize.SafeObjectOutputStream
- All Implemented Interfaces:
DataOutput,ObjectOutput,ObjectStreamConstants,AutoCloseable,ExternalizeConstants
public class SafeObjectOutputStream
extends Object
implements ObjectOutput, ObjectStreamConstants, ExternalizeConstants
A SafeObjectOutputStream provides extra mechanisms to ensure that
objects can be safely serialized to the ObjectOutput.
If an Object is written to a normal ObjectOutput, the ObjectOutput is left in
an unknown state if a NotSerializableException occurs.
The SafeObjectOutputStream does some additonal checking to ensure that the Object can
be safely written. If the Object is suspicious, it is first written to a buffer to ensure
that the underlying ObjectOutput is not corrupted.
In addition, SafeObjectOutputStream provides extra methods to write containers of Objects.
For example the writeMap object will write the key and value pairs that are can be serialized.
- See Also:
-
Field Summary
FieldsFields inherited from interface org.apache.axis2.context.externalize.ExternalizeConstants
ACTIVE_OBJECT, EMPTY_MARKER, EMPTY_OBJECT, LAST_ENTRY, OBJ_RESTORE_PROBLEM, OBJ_SAVE_PROBLEM, UNSUPPORTED_REVID, UNSUPPORTED_SUIDFields inherited from interface java.io.ObjectStreamConstants
baseWireHandle, PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, SC_BLOCK_DATA, SC_ENUM, SC_EXTERNALIZABLE, SC_SERIALIZABLE, SC_WRITE_METHOD, SERIAL_FILTER_PERMISSION, STREAM_MAGIC, STREAM_VERSION, SUBCLASS_IMPLEMENTATION_PERMISSION, SUBSTITUTION_PERMISSION, TC_ARRAY, TC_BASE, TC_BLOCKDATA, TC_BLOCKDATALONG, TC_CLASS, TC_CLASSDESC, TC_ENDBLOCKDATA, TC_ENUM, TC_EXCEPTION, TC_LONGSTRING, TC_MAX, TC_NULL, TC_OBJECT, TC_PROXYCLASSDESC, TC_REFERENCE, TC_RESET, TC_STRING -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidbooleanvoidflush()inthashCode()static SafeObjectOutputStreaminstall(ObjectOutput out) Add the SafeOutputStream if necessary.voidreset()toString()voiduseProtocolVersion(int version) voidwrite(byte[] buf) voidwrite(byte[] buf, int off, int len) voidwrite(int val) voidwriteBoolean(boolean val) voidwriteByte(int val) voidwriteBytes(String str) voidwriteChar(int val) voidwriteChars(String str) voidwriteDouble(double val) voidvoidwriteFloat(float val) voidwriteInt(int val) booleanWrites pair of objects to the stream.booleanWrite a list.voidwriteLong(long val) booleanWrite a map FORMAT for null map EMPTY_OBJECT FORMAT for non-empty map ACTIVE_OBJECT for each contained key value pair writePair EMPTY_OBJECT (indicates end of the listvoidwriteObject(Object obj) booleanWrites pair of objects to the stream.voidwriteShort(int val) void
-
Field Details
-
notSerializableList
-
-
Method Details
-
install
Add the SafeOutputStream if necessary.- Parameters:
out- Current ObjectOutput- Returns:
- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceObjectOutput- Throws:
IOException
-
defaultWriteObject
- Throws:
IOException
-
equals
-
flush
- Specified by:
flushin interfaceObjectOutput- Throws:
IOException
-
hashCode
public int hashCode() -
putFields
- Throws:
IOException
-
reset
- Throws:
IOException
-
toString
-
useProtocolVersion
- Throws:
IOException
-
write
- Specified by:
writein interfaceDataOutput- Specified by:
writein interfaceObjectOutput- Throws:
IOException
-
write
- Specified by:
writein interfaceDataOutput- Specified by:
writein interfaceObjectOutput- Throws:
IOException
-
write
- Specified by:
writein interfaceDataOutput- Specified by:
writein interfaceObjectOutput- Throws:
IOException
-
writeBoolean
- Specified by:
writeBooleanin interfaceDataOutput- Throws:
IOException
-
writeByte
- Specified by:
writeBytein interfaceDataOutput- Throws:
IOException
-
writeBytes
- Specified by:
writeBytesin interfaceDataOutput- Throws:
IOException
-
writeChar
- Specified by:
writeCharin interfaceDataOutput- Throws:
IOException
-
writeChars
- Specified by:
writeCharsin interfaceDataOutput- Throws:
IOException
-
writeDouble
- Specified by:
writeDoublein interfaceDataOutput- Throws:
IOException
-
writeFields
- Throws:
IOException
-
writeFloat
- Specified by:
writeFloatin interfaceDataOutput- Throws:
IOException
-
writeInt
- Specified by:
writeIntin interfaceDataOutput- Throws:
IOException
-
writeLong
- Specified by:
writeLongin interfaceDataOutput- Throws:
IOException
-
writeObject
- Specified by:
writeObjectin interfaceObjectOutput- Throws:
IOException
-
writeShort
- Specified by:
writeShortin interfaceDataOutput- Throws:
IOException
-
writeUTF
- Specified by:
writeUTFin interfaceDataOutput- Throws:
IOException
-
writeMap
Write a map FORMAT for null map EMPTY_OBJECT FORMAT for non-empty map ACTIVE_OBJECT for each contained key value pair writePair EMPTY_OBJECT (indicates end of the list- Parameters:
ll-- Returns:
- Throws:
IOException
-
writeList
Write a list. FORMAT for null list EMPTY_OBJECT FORMAT for non-empty list ACTIVE_OBJECT for each contained object ACTOVE_OBJECT writeObject EMPTY_OBJECT (indicates end of the list- Parameters:
ll-- Returns:
- Throws:
IOException
-
writePair
public boolean writePair(Object obj1, boolean isSafe1, Object obj2, boolean isSafe2) throws IOException Writes pair of objects to the stream. If the objects are known (apriori) to be completely serializable they are "safe". Safe objects are written directly to the stream. Objects that are not known are to be safe are tested for safety and only written if they are deemed safe. Unsafe objects are not written. Note: The java.io.ObjectOutputStream is left in an unrecoverable state if any object written to it causes a serialization error. So please use the isSafe parameter wisely FORMAT for non-serializable key/value pair nothing is written FORMAT for safe serializable key/value pair ACTIVE_OBJECT FORM_OBJECT Object FORMAT for other serializable key/value pair ACTIVE_OBJECT FORM_BYTE length of bytes bytes representing the object- Parameters:
obj1-isSafe1- true if you know that object can be safely serialized. false if the object needs to be tested for serialization.obj2-isSafe2- true if you know that object can be safely serialized. false if the object needs to be tested for serialization.- Throws:
IOException
-
writeItem
Writes pair of objects to the stream. If the objects are known (apriori) to be completely serializable they are "safe". Safe objects are written directly to the stream. Objects that are not known are to be safe are tested for safety and only written if they are deemed safe. Unsafe objects are not written. Note: The java.io.ObjectOutputStream is left in an unrecoverable state if any object written to it causes a serialization error. So please use the isSafe parameter wisely FORMAT for non-serializable key/value pair nothing is written FORMAT for safe serializable key/value pair ACTIVE_OBJECT FORM_OBJECT Object FORMAT for other serializable key/value pair ACTIVE_OBJECT FORM_BYTE length of bytes bytes representing the object- Parameters:
obj1-isSafe1- true if you know that object can be safely serialized. false if the object needs to be tested for serialization.obj2-isSafe2- true if you know that object can be safely serialized. false if the object needs to be tested for serialization.- Throws:
IOException
-