public void reserve ( @ Nonnegative final int nExpectedLength ) { ValueEnforcer . isGE0 ( nExpectedLength , "ExpectedLength" ) ; if ( m_aBuffer . position ( ) != 0 ) throw new IllegalStateException ( "cannot be called except after finish()" ) ; if ( nExpectedLength > m_aBuffer . capacity ( ) ) { // Allocate a temporary buffer large enough for this string rounded up int nDesiredLength = nExpectedLength ; if ( ( nDesiredLength & SIZE_ALIGNMENT_MASK ) != 0 ) { // round up nDesiredLength = ( nExpectedLength + SIZE_ALIGNMENT ) & ~ SIZE_ALIGNMENT_MASK ; } assert nDesiredLength % SIZE_ALIGNMENT == 0 ; m_aBuffer = CharBuffer . allocate ( nDesiredLength ) ; } if ( m_aBuffer . position ( ) != 0 ) throw new IllegalStateException ( "Buffer position weird!" ) ; if ( nExpectedLength > m_aBuffer . capacity ( ) ) throw new IllegalStateException ( ) ; }
Reserve space for the next string that will be &le ; expectedLength characters long . Must only be called when the buffer is empty .