public final < T extends MapLayer > T read ( Class < T > type ) throws IOException { // Read the header if ( ! this . isHeaderRead ) { this . isHeaderRead = true ; readHeader ( ) ; if ( this . progression != null ) { this . progression . setProperties ( 0 , 0 , this . restToRead , false ) ; } } T selectedObject = null ; if ( this . restToRead > 0 ) { final ObjectInputStream oos = new ObjectInputStream ( this . input ) ; do { try { final Object readObject = oos . readObject ( ) ; -- this . restToRead ; if ( type . isInstance ( readObject ) ) { selectedObject = type . cast ( readObject ) ; } } catch ( ClassNotFoundException e ) { // } } while ( this . restToRead > 0 && selectedObject == null ) ; } if ( this . progression != null ) { if ( this . restToRead <= 0 ) { this . progression . end ( ) ; } else { this . progression . increment ( ) ; } } return selectedObject ; }
Read the next layer of the given type from the input .