/**
  * This function inserts or replaces the user's input in a string buffer, to create the text
  * which would be on screen if we allowed it. We declare to throw bad location due to
  * doc.getText, but since the paramters are coming from the farmework, that should never
  * happen.... in theory. If insert is true we insert, if false we replace. Length parameter only
  * used when replacing.
  */
 private StringBuffer getTextPrototype(
     boolean insert, FilterBypass fb, int offs, String str, int length)
     throws BadLocationException {
   Document doc = fb.getDocument();
   String text = doc.getText(0, doc.getLength());
   StringBuffer sb = new StringBuffer(text);
   if (insert) {
     sb.insert(offs, str);
   } else {
     sb.replace(offs, offs + length, str);
   }
   return sb;
 } // end of getTextPrototype
Beispiel #2
0
 /**
  * Transforme la chaine de caractère avec accent sans accent Utilise la liste de caractères
  * spéciaux
  */
 private String sansAccent(String chaine) {
   java.lang.StringBuffer Result = new StringBuffer(chaine);
   int MIN = 192;
   int MAX = 255;
   Vector<String> map = initMap();
   for (int bcl = 0; bcl < Result.length(); bcl++) {
     int carVal = chaine.charAt(bcl);
     if (carVal >= MIN && carVal <= MAX) { // Remplacement
       java.lang.String newVal = (java.lang.String) map.get(carVal - MIN);
       Result.replace(bcl, bcl + 1, newVal);
     }
   }
   return Result.toString();
 }