public void readFrom ( IIMReader reader , int recover ) throws IOException , InvalidDataSetException { final boolean doLog = log != null ; for ( ; ; ) { try { DataSet ds = reader . read ( ) ; if ( ds == null ) { break ; } if ( doLog ) { log . debug ( "Read data set " + ds ) ; } DataSetInfo info = ds . getInfo ( ) ; Serializer s = info . getSerializer ( ) ; if ( s != null ) { if ( info . getDataSetNumber ( ) == IIM . DS ( 1 , 90 ) ) { setCharacterSet ( ( String ) s . deserialize ( ds . getData ( ) , activeSerializationContext ) ) ; } } dataSets . add ( ds ) ; if ( stopAfter9_10 && info . getDataSetNumber ( ) == IIM . DS ( 9 , 10 ) ) break ; } catch ( IIMFormatException e ) { if ( recoverFromIIMFormat && recover -- > 0 ) { boolean r = reader . recover ( ) ; if ( doLog ) { log . debug ( r ? "Recoved from " + e : "Failed to recover from " + e ) ; } if ( ! r ) break ; } else { throw e ; } } catch ( UnsupportedDataSetException e ) { if ( recoverFromUnsupportedDataSet && recover -- > 0 ) { boolean r = reader . recover ( ) ; if ( doLog ) { log . debug ( r ? "Recoved from " + e : "Failed to recover from " + e ) ; } if ( ! r ) break ; } else { throw e ; } } catch ( InvalidDataSetException e ) { if ( recoverFromInvalidDataSet && recover -- > 0 ) { boolean r = reader . recover ( ) ; if ( doLog ) { log . debug ( r ? "Recoved from " + e : "Failed to recover from " + e ) ; } if ( ! r ) break ; } else { throw e ; } } catch ( IOException e ) { if ( recover -- > 0 && ! dataSets . isEmpty ( ) ) { if ( doLog ) { log . error ( "IOException while reading, however some data sets where recovered, " + e ) ; } return ; } else { throw e ; } } } }
Reads data sets from a passed reader .