}
public Document getDocument( InputStream rawContent, Reference2ObjectMap<Enum<?>,Object> metadata ) throws IOException {
final FastBufferedInputStream fbis = new FastBufferedInputStream( rawContent );
int startedHeader = 0; // 0 == false, 1 == true, 2 === header started and uri collected
boolean foundDocNo = false;
int l = fbis.readLine( buffer );
if ( l < 0 ) throw new EOFException();
if ( ! TRECDocumentCollection.equals( buffer, l, DOC_OPEN ) ) throw new IllegalStateException ( "Document does not start with <DOC>: " + new String( buffer, 0, l ) );
while ( ( l = fbis.readLine( buffer ) ) != -1 ) {
if ( !foundDocNo && startsWith( buffer, l, DOCNO_OPEN ) ) {
foundDocNo = true;
metadata.put( MetadataKeys.TITLE, new String( buffer, DOCNO_OPEN.length, l - ( DOCNO_OPEN.length + DOCNO_CLOSE.length ) ) );
}