src/tokenclustering/model/AvailableTokens.java
/**
     * Makes a search of availables tokens.
     * @param entry The entry of the search.
     * @return The tokens that are match of the search.
     */
Makes a search of availables tokens.
@param entry The entry of the search.
@return The tokens that are match of the search.
Makes a search of availables tokens . @param entry The entry of the search . @return The tokens that are match of the search .
public ArrayList<Token> search(String entry) {
        ArrayList<Token> result = new ArrayList<Token>();
        try {
            String[] parts = entry.split("-");
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < parts.length; i++) {
                builder.append(".*");
                builder.append(parts[i].toLowerCase());
            }
            builder.append(".*");
            Pattern pattern = Pattern.compile(builder.toString());
            this.refreshList();
            Iterator<Token> it = tokens.iterator();
            while (it.hasNext()) {
                Token actualToken = it.next();
                String actualName = actualToken.getName();
                String actualNameLower = actualName.toLowerCase();
                Matcher matcher = pattern.matcher(actualNameLower);
                if (matcher.find()
                        && matcher.start() == 0
                        && matcher.end() == actualNameLower.length()) {
                    result.add(actualToken);
                }
            }
        } catch (java.util.regex.PatternSyntaxException e) {
        }
        return result;
    }
public ArrayList < Token > search ( String entry ) { ArrayList < Token > result = new ArrayList < Token > ( ) ; try { String [ ] parts = entry . split ( "-" ) ; StringBuilder builder = new StringBuilder ( ) ; for ( int i = 0 ; i < parts . length ; i ++ ) { builder . append ( ".*" ) ; builder . append ( parts [ i ] . toLowerCase ( ) ) ; } builder . append ( ".*" ) ; Pattern pattern = Pattern . compile ( builder . toString ( ) ) ; this . refreshList ( ) ; Iterator < Token > it = tokens . iterator ( ) ; while ( it . hasNext ( ) ) { Token actualToken = it . next ( ) ; String actualName = actualToken . getName ( ) ; String actualNameLower = actualName . toLowerCase ( ) ; Matcher matcher = pattern . matcher ( actualNameLower ) ; if ( matcher . find ( ) && matcher . start ( ) == 0 && matcher . end ( ) == actualNameLower . length ( ) ) { result . add ( actualToken ) ; } } } catch ( java . util . regex . PatternSyntaxException e ) { } return result ; }
Makes a search of availables tokens.
Makes a search of availables tokens .