Exemple #1
0
 @Override
 public void setSearch(String input) {
   this.matches.clear();
   final List<TermHit> startsWith = new ArrayList<TermHit>();
   final List<TermHit> containedIn = new ArrayList<TermHit>();
   final String lowerInput = input.toLowerCase();
   for (OBOObject term : this.terms.getTerms()) {
     if ((term.getName() != null)) {
       final int position = term.getName().toLowerCase().indexOf(lowerInput);
       if (position == 0) {
         startsWith.add(new TermHit(term, term.getName(), NAME_MATCH));
       } else if (position > -1) {
         containedIn.add(new TermHit(term, term.getName(), NAME_MATCH));
       }
     }
     for (Synonym synonym : term.getSynonyms()) {
       if (synonym.getText() != null) {
         final int position = synonym.getText().toLowerCase().indexOf(lowerInput);
         if (position == 0) {
           startsWith.add(new TermHit(term, synonym.getText(), SYNONYM_MATCH));
         } else if (position > -1) {
           containedIn.add(new TermHit(term, synonym.getText(), SYNONYM_MATCH));
         }
       }
     }
   }
   Collections.sort(startsWith, COMPARATOR);
   Collections.sort(containedIn, COMPARATOR);
   this.matches.addAll(startsWith);
   this.matches.addAll(containedIn);
 }
Exemple #2
0
 @Override
 public String toString(OBOObject valueObject) {
   return valueObject == null ? null : valueObject.getName();
 }
Exemple #3
0
 @Override
 public boolean isSame(String text, OBOObject item) {
   return item != null ? text.equals(item.getName()) : false;
 }
Exemple #4
0
 @Override
 public String getPrimaryText() {
   return term.getName();
 }