this.appendDelimiterIndex = currentText.lastIndexOf( this.appendChoiceDelimiter ); if (this.appendDelimiterIndex != -1) { currentText = currentText.substring( this.appendDelimiterIndex + 1 );
if (this.appendChoiceDelimiter != null) { this.appendDelimiterIndex = TextUtil.lastIndexOf( currentText, this.appendChoiceDelimiter ); if (this.appendDelimiterIndex != -1) { currentText = currentText.substring( this.appendDelimiterIndex + 1 ); } } else if (this.appendDelimiterIndex != -1 && this.appendDelimiterIndex < currentText.length()) { currentText = currentText.substring( this.appendDelimiterIndex );
	public void notifyStateChanged() {		//#if polish.usePolishGui			//# Screen scr = getScreen();		//#else			Screen scr = null;		//#endif		if (scr != null && scr instanceof Form && ((Form)scr).itemStateListener != null ) {			// let the external item state listener do the work			super.notifyStateChanged();		} else {			// find out possible matches yourself:			if ( this.lowerCaseChoices == null ) {				return; // no choices are known			}			String currentText = getString();			if (currentText != null) {				if (this.isAppendMode) {					this.appendDelimiterIndex = currentText.lastIndexOf( this.appendChoiceDelimiter );					if (this.appendDelimiterIndex != -1) {						currentText = currentText.substring( this.appendDelimiterIndex + 1 );					}				}				currentText = currentText.toLowerCase();				// cycle through available choices and add the ones resulting in matches.				// There is one special case, though: when only one of the available choices				// can be used (=no free text entry alllowed), we need to ensure that there is at least one match, before updating				// the choicesContainer:				if (this.isAllowFreeTextEntry) {					this.choicesContainer.clear();				}				int foundMatches = 0;				for (int i = 0; i < this.lowerCaseChoices.length; i++) {					String choice = this.lowerCaseChoices[i];					if ( matches( currentText, choice ) ) {						// found a match!						foundMatches++;						Item item = this.choiceItems[i];						if (item == null) {							// create new ChoiceItem (lazy initialisation)							item = new ChoiceItem( this.choices[i], null, Choice.IMPLICIT, this.choiceItemStyle );						}						//#debug						System.out.println("found match: " + choice);						this.choicesContainer.add( item );					}				}				// handle case when there are no matches, but only matches are allowed as the input:				if ( this.isAllowFreeTextEntry ) {					this.numberOfMatches = foundMatches;				} else {					if ( foundMatches == 0 ) {						// re-set the text to the last match:						setString( this.lastMatchingText );					} else {						// remove all previous matches and remember this text:						this.lastMatchingText = getString();						for ( int i = this.numberOfMatches; --i >= 0; ) {							this.choicesContainer.remove( 0 );						}						this.numberOfMatches = foundMatches;					}									}			}			openChoices( this.numberOfMatches > 0 );		}	}