fr.jussieu.ufr_info_p7.T9
Interface Completion


public interface Completion

A class implement the Completion interface to provide completion services to T9 class instances. A completion is a two-part word: a prefix read from user inputs, and a completion suffix provided by the completion service itself. Any user input fires events to a T9 object which invoke methods to the completion service. In a T9 object, a completion can be viewed as a word (the prefix) and a possible completion word (the suffix). A basic navigation service in provided through completionPrecedente() and completionSuivante() methods. When the user effectively choose to complete the word, the T9 object fires the complete() method.

A minimal completion service could be:

 class BasicCompletion implements Completion {
   private StringBuffer prefix = new StringBuffer();
   public void termine() { }
   public void complete() { }
   public void setMotCourant(String mot) {
     if (mot==null) throw new NullPointerException();
     prefix = new StringBuffer(mot);
   }
   public String getMotCourant() { return prefix.toString(); }
   public String getCompletionCourante() { return ""; }
   public void completionPrecedente() { }
   public void completionSuivante() { }
   public void ajouteCaractere(char c) { prefixe.append(c); }
   public void enleveDernierCaractere() {
     if (prefix.length()>0) { prefix.setLength(prefix.length()-1); }
   }
 }

Version:
1.01, 2004-11-30
Author:
Jean-Baptiste Yunès
See Also:
T9

Method Summary
 void ajouteCaractere(char caractere)
          Add a character to the prefix.
 void complete()
          Complete the prefix with the curreent suffix.
 void completionPrecedente()
          Compute the previous possible completion of the current prefix.
 void completionSuivante()
          Compute the next possible completion of the current prefix.
 void enleveDernierCaractere()
          Remove the last character of the prefix.
 String getCompletionCourante()
          Get the value of the suffix.
 String getMotCourant()
          Get the value of the prefix.
 void setMotCourant(String motCourant)
          Set the value of the completion prefix.
 void termine()
          This method is called before the T9 object terminates.
 

Method Detail

termine

void termine()
This method is called before the T9 object terminates. This slot is primarily provided to clean internal data structures.

The general contract is that it is invoked when T9 object has decided to terminate with your current completion object.

Important note: this method is not devised to terminate the JVM, you are not supposed to call any termination function.


setMotCourant

void setMotCourant(String motCourant)
Set the value of the completion prefix. This method is called when the T9 object needs to reset the current completion. A completion protocol conform method must update the completion suffix according to the new value.

Parameters:
motCourant - the new value to use as the prefix.
Throws:
NullPointerException - if a null value is used

getMotCourant

String getMotCourant()
Get the value of the prefix. This method is called whenever the UI needs to show the value.

Returns:
the value of the prefix.

getCompletionCourante

String getCompletionCourante()
Get the value of the suffix. This method is called whenever the UI needs to show the value.

Returns:
the value of the suffix.

complete

void complete()
Complete the prefix with the curreent suffix. This method is called when the user wants to complete the prefix with the current suffix.


ajouteCaractere

void ajouteCaractere(char caractere)
Add a character to the prefix. This method is called when the user input a character through the UI. This basically adds the character to the prefix.

Parameters:
caractere - the input character.

enleveDernierCaractere

void enleveDernierCaractere()
Remove the last character of the prefix. This method is called when the user wants to delete the last character of the prefix. This method will never be called if the length of the String returned by getMotCourant() is 0.


completionPrecedente

void completionPrecedente()
Compute the previous possible completion of the current prefix. This method is called whenever the T9 want to navigate back through the list of possible completion words. The preceding word must be provided through getCompletionCourante() method.


completionSuivante

void completionSuivante()
Compute the next possible completion of the current prefix. This method is called whenever the T9 want to navigate forward through the list of possible completion words. The next word must be available through getCompletionCourante() method.