question: public void printEntryDetails ( Writer w ) { int linesadded = - 1 ; String title ; try { HardcopyWriter ww = ( HardcopyWriter ) w ; int textSpace = ww . getCharactersPerLine ( ) - indentWidth - 1 ; title = "   ID:                " ; if ( ( textSpaceWithIcon != 0 ) && ( linesadded < blanks ) ) { linesadded = writeWrappedComment ( w , _id , title , textSpaceWithIcon ) + linesadded ; } else { linesadded = writeWrappedComment ( w , _id , title , textSpace ) + linesadded ; } title = "   Filename:          " ; if ( ( textSpaceWithIcon != 0 ) && ( linesadded < blanks ) ) { linesadded = writeWrappedComment ( w , _fileName != null ? _fileName : "<null>" , title , textSpaceWithIcon ) + linesadded ; } else { linesadded = writeWrappedComment ( w , _fileName != null ? _fileName : "<null>" , title , textSpace ) + linesadded ; } if ( ! ( _roadName . isEmpty ( ) ) ) { title = "   Road name:         " ; if ( ( textSpaceWithIcon != 0 ) && ( linesadded < blanks ) ) { linesadded = writeWrappedComment ( w , _roadName , title , textSpaceWithIcon ) + linesadded ; } else { linesadded = writeWrappedComment ( w , _roadName , title , textSpace ) + linesadded ; } } if ( ! ( _roadNumber . isEmpty ( ) ) ) { title = "   Road number:       " ; if ( ( textSpaceWithIcon != 0 ) && ( linesadded < blanks ) ) { linesadded = writeWrappedComment ( w , _roadNumber , title , textSpaceWithIcon ) + linesadded ; } else { linesadded = writeWrappedComment ( w , _roadNumber , title , textSpace ) + linesadded ; } } if ( ! ( _mfg . isEmpty ( ) ) ) { title = "   Manufacturer:      " ; if ( ( textSpaceWithIcon != 0 ) && ( linesadded < blanks ) ) { linesadded = writeWrappedComment ( w , _mfg , title , textSpaceWithIcon ) + linesadded ; } else { linesadded = writeWrappedComment ( w , _mfg , title , textSpace ) + linesadded ; } } if ( ! ( _owner . isEmpty ( ) ) ) { title = "   Owner:             " ; if ( ( textSpaceWithIcon != 0 ) && ( linesadded < blanks ) ) { linesadded = writeWrappedComment ( w , _owner , title , textSpaceWithIcon ) + linesadded ; } else { linesadded = writeWrappedComment ( w , _owner , title , textSpace ) + linesadded ; } } if ( ! ( _model . isEmpty ( ) ) ) { title = "   Model:             " ; if ( ( textSpaceWithIcon != 0 ) && ( linesadded < blanks ) ) { linesadded = writeWrappedComment ( w , _model , title , textSpaceWithIcon ) + linesadded ; } else { linesadded = writeWrappedComment ( w , _model , title , textSpace ) + linesadded ; } } if ( ! ( _dccAddress . isEmpty ( ) ) ) { w . write ( newLine , 0 , 1 ) ; String s = "   DCC Address:       " + _dccAddress ; w . write ( s , 0 , s . length ( ) ) ; linesadded ++ ; } if ( ! ( _comment . isEmpty ( ) ) ) { for ( int i = 0 ; i < ( blanks - linesadded ) ; i ++ ) { w . write ( newLine , 0 , 1 ) ; } if ( blanks != 0 ) { blanks = 0 ; } title = "   Comment:           " ; linesadded = writeWrappedComment ( w , _comment , title , textSpace ) + linesadded ; } if ( ! ( _decoderModel . isEmpty ( ) ) ) { title = "   Decoder Model:     " ; if ( ( textSpaceWithIcon != 0 ) && ( linesadded < blanks ) ) { linesadded = writeWrappedComment ( w , _decoderModel , title , textSpaceWithIcon ) + linesadded ; } else { linesadded = writeWrappedComment ( w , _decoderModel , title , textSpace ) + linesadded ; } } if ( ! ( _decoderFamily . isEmpty ( ) ) ) { title = "   Decoder Family:    " ; if ( ( textSpaceWithIcon != 0 ) && ( linesadded < blanks ) ) { linesadded = writeWrappedComment ( w , _decoderFamily , title , textSpaceWithIcon ) + linesadded ; } else { linesadded = writeWrappedComment ( w , _decoderFamily , title , textSpace ) + linesadded ; } } if ( ! ( _decoderComment . isEmpty ( ) ) ) { for ( int i = 0 ; i < ( blanks - linesadded ) ; i ++ ) { w . write ( newLine , 0 , 1 ) ; } if ( blanks != 0 ) { blanks = 0 ; } title = "   Decoder Comment:   " ; linesadded = writeWrappedComment ( w , _decoderComment , title , textSpace ) + linesadded ; } w . write ( newLine , 0 , 1 ) ; for ( int i = - 1 ; i < ( blanks - linesadded ) ; i ++ ) { w . write ( newLine , 0 , 1 ) ; } } catch ( IOException e ) { log . error ( "Error printing RosterEntry: " + e ) ; } }
target:  Prints the roster information. Updated to allow for multiline comment and decoder comment fields. Created separate write statements for text and line feeds to work around the HardcopyWriter bug that misplaces borders