public DictionaryBuilder add ( CharSequence seq ) throws DictionaryBuilderException { if ( d_finalized ) throw new DictionaryBuilderException ( "Cannot add a sequence to a finalized DictionaryBuilder." ) ; if ( d_prevSeq != null && compareCharacterSequences ( d_prevSeq , seq ) >= 0 ) throw new DictionaryBuilderException ( String . format ( "Sequences are not added in lexicographic order: %s %s" , d_prevSeq , seq ) ) ; d_prevSeq = seq ; // Traverse across the shared prefix. int i = 0 ; State curState = d_startState ; for ( int len = seq . length ( ) ; i < len ; i ++ ) { State nextState = curState . move ( seq . charAt ( i ) ) ; if ( nextState != null ) curState = nextState ; else break ; } if ( curState . hasOutgoing ( ) ) replaceOrRegisterIterative ( curState ) ; addSuffix ( curState , seq . subSequence ( i , seq . length ( ) ) ) ; ++ d_nSeqs ; return this ; }
Add a character sequence .