protected String createRecordHeader ( WARCRecordInfo metaRecord ) throws IllegalArgumentException { final StringBuilder sb = new StringBuilder ( 2048 /*A SWAG: TODO: Do analysis.*/ ) ; sb . append ( WARC_ID ) . append ( CRLF ) ; sb . append ( HEADER_KEY_TYPE ) . append ( COLON_SPACE ) . append ( metaRecord . getType ( ) ) . append ( CRLF ) ; // Do not write a subject-uri if not one present. if ( ! StringUtils . isEmpty ( metaRecord . getUrl ( ) ) ) { sb . append ( HEADER_KEY_URI ) . append ( COLON_SPACE ) . append ( checkHeaderValue ( metaRecord . getUrl ( ) ) ) . append ( CRLF ) ; } sb . append ( HEADER_KEY_DATE ) . append ( COLON_SPACE ) . append ( metaRecord . getCreate14DigitDate ( ) ) . append ( CRLF ) ; if ( metaRecord . getExtraHeaders ( ) != null ) { for ( final Iterator < Element > i = metaRecord . getExtraHeaders ( ) . iterator ( ) ; i . hasNext ( ) ; ) { sb . append ( i . next ( ) ) . append ( CRLF ) ; } } sb . append ( HEADER_KEY_ID ) . append ( COLON_SPACE ) . append ( ' ' ) . append ( metaRecord . getRecordId ( ) . toString ( ) ) . append ( ' ' ) . append ( CRLF ) ; if ( metaRecord . getContentLength ( ) > 0 ) { sb . append ( CONTENT_TYPE ) . append ( COLON_SPACE ) . append ( checkHeaderLineMimetypeParameter ( metaRecord . getMimetype ( ) ) ) . append ( CRLF ) ; } sb . append ( CONTENT_LENGTH ) . append ( COLON_SPACE ) . append ( Long . toString ( metaRecord . getContentLength ( ) ) ) . append ( CRLF ) ; return sb . toString ( ) ; }
final ANVLRecord xtraHeaders final long contentLength )