protected long writeOutput ( OutputStream out , ValueData value ) throws IOException { if ( value . isByteArray ( ) ) { byte [ ] buff = value . getAsByteArray ( ) ; out . write ( buff ) ; return buff . length ; } else { InputStream in ; if ( value instanceof StreamPersistedValueData ) { StreamPersistedValueData streamed = ( StreamPersistedValueData ) value ; if ( streamed . isPersisted ( ) ) { // already persisted in another Value, copy it to this Value in = streamed . getAsStream ( ) ; } else { in = streamed . getStream ( ) ; if ( in == null ) { in = new FileInputStream ( streamed . getTempFile ( ) ) ; } } } else { in = value . getAsStream ( ) ; } try { return copy ( in , out ) ; } finally { in . close ( ) ; } } }
Stream value data to the output .