public Metadata readMetadata ( Reader reader ) { LineCounter lineCounter = new LineCounter ( "fromString" , StandardCharsets . UTF_16 ) ; FileHashComputer fileHashComputer = new FileHashComputer ( "fromString" ) ; LineOffsetCounter lineOffsetCounter = new LineOffsetCounter ( ) ; CharHandler [ ] handlers = { lineCounter , fileHashComputer , lineOffsetCounter } ; try { read ( reader , handlers ) ; } catch ( IOException e ) { throw new IllegalStateException ( "Should never occur" , e ) ; } return new Metadata ( lineCounter . lines ( ) , lineCounter . nonBlankLines ( ) , fileHashComputer . getHash ( ) , lineOffsetCounter . getOriginalLineStartOffsets ( ) , lineOffsetCounter . getOriginalLineEndOffsets ( ) , lineOffsetCounter . getLastValidOffset ( ) ) ; }
For testing purpose