public void writeGeneric ( Object value ) { if ( value == null ) write ( NULL_VALUE ) ; else { if ( value instanceof String ) { writeByte ( TYPE_STRING ) ; writeUTF ( ( String ) value ) ; } else if ( value instanceof Boolean ) { writeByte ( TYPE_BOOLEAN ) ; writeBoolean ( ( ( Boolean ) value ) . booleanValue ( ) ) ; } else if ( value instanceof Byte ) { writeByte ( TYPE_BYTE ) ; writeByte ( ( ( Byte ) value ) . byteValue ( ) ) ; } else if ( value instanceof Short ) { writeByte ( TYPE_SHORT ) ; writeShort ( ( ( Short ) value ) . shortValue ( ) ) ; } else if ( value instanceof Integer ) { writeByte ( TYPE_INT ) ; writeInt ( ( ( Integer ) value ) . intValue ( ) ) ; } else if ( value instanceof Long ) { writeByte ( TYPE_LONG ) ; writeLong ( ( ( Long ) value ) . longValue ( ) ) ; } else if ( value instanceof Float ) { writeByte ( TYPE_FLOAT ) ; writeFloat ( ( ( Float ) value ) . floatValue ( ) ) ; } else if ( value instanceof Double ) { writeByte ( TYPE_DOUBLE ) ; writeDouble ( ( ( Double ) value ) . doubleValue ( ) ) ; } else if ( value instanceof byte [ ] ) { writeByte ( TYPE_BYTEARRAY ) ; writeByteArray ( ( byte [ ] ) value ) ; } else if ( value instanceof Character ) { writeByte ( TYPE_CHARACTER ) ; writeChar ( ( ( Character ) value ) . charValue ( ) ) ; } else throw new IllegalArgumentException ( "Unsupported type : " + value . getClass ( ) . getName ( ) ) ; }
Write a generic type to the stream