public PersistedValueData read ( ObjectReader in , int type ) throws UnknownClassIdException , IOException { File tempDirectory = new File ( SerializationConstants . TEMP_DIR ) ; PrivilegedFileHelper . mkdirs ( tempDirectory ) ; // read id int key ; if ( ( key = in . readInt ( ) ) != SerializationConstants . PERSISTED_VALUE_DATA ) { throw new UnknownClassIdException ( "There is unexpected class [" + key + "]" ) ; } int orderNumber = in . readInt ( ) ; boolean isByteArray = in . readBoolean ( ) ; if ( isByteArray ) { byte [ ] data = new byte [ in . readInt ( ) ] ; in . readFully ( data ) ; return ValueDataUtil . createValueData ( type , orderNumber , data ) ; } else { // read file id - used for reread data optimization String id = in . readString ( ) ; // read file length long length = in . readLong ( ) ; SerializationSpoolFile sf = holder . get ( id ) ; if ( sf == null ) { // Deleted ItemState usecase if ( length == SerializationConstants . NULL_FILE ) { return new StreamPersistedValueData ( orderNumber , ( SerializationSpoolFile ) null , spoolConfig ) ; } sf = new SerializationSpoolFile ( tempDirectory , id , holder ) ; writeToFile ( in , sf , length ) ; holder . put ( id , sf ) ; return new StreamPersistedValueData ( orderNumber , sf , spoolConfig ) ; } else { sf . acquire ( this ) ; // workaround for AsyncReplication test try { PersistedValueData vd = new StreamPersistedValueData ( orderNumber , sf , spoolConfig ) ; // skip data in input stream if ( in . skip ( length ) != length ) { throw new IOException ( "Content isn't skipped correctly." ) ; } return vd ; } finally { sf . release ( this ) ; } } } }
Read and set PersistedValueData object data .