protected void rebuildIndentationBuf ( ) { if ( doIndent == false ) return ; final int maxIndent = 65 ; // hardcoded maximum indentation size in // characters int bufSize = 0 ; offsetNewLine = 0 ; if ( writeLineSepartor ) { offsetNewLine = lineSeparator . length ( ) ; bufSize += offsetNewLine ; } maxIndentLevel = 0 ; if ( writeIndentation ) { indentationJump = indentationString . length ( ) ; maxIndentLevel = maxIndent / indentationJump ; bufSize += maxIndentLevel * indentationJump ; } if ( indentationBuf == null || indentationBuf . length < bufSize ) { indentationBuf = new char [ bufSize + 8 ] ; } int bufPos = 0 ; if ( writeLineSepartor ) { for ( int i = 0 ; i < lineSeparator . length ( ) ; i ++ ) { indentationBuf [ bufPos ++ ] = lineSeparator . charAt ( i ) ; } } if ( writeIndentation ) { for ( int i = 0 ; i < maxIndentLevel ; i ++ ) { for ( int j = 0 ; j < indentationString . length ( ) ; j ++ ) { indentationBuf [ bufPos ++ ] = indentationString . charAt ( j ) ; } } } }
For maximum efficiency when writing indents the required output is pre - computed This is internal function that recomputes buffer after user requested chnages .