Search in sources :

Example 1 with Operator

use of de.janrufmonitor.repository.search.Operator in project janrufmonitor by tbrandt77.

the class JournalController method getSearchTerms.

private ISearchTerm[] getSearchTerms() {
    String st = this.m_configuration.getProperty(CFG_SEARCHTERMS, "");
    if (st != null && st.trim().length() > 0) {
        List terms = new ArrayList();
        StringTokenizer and_t = new StringTokenizer(st, Operator.AND.toString());
        final String[] ands = new String[and_t.countTokens()];
        int i = 0;
        while (and_t.hasMoreTokens()) {
            ands[i] = and_t.nextToken().trim();
            i++;
        }
        for (i = 0; i < ands.length; i++) {
            final String term = ands[i];
            final StringTokenizer or_t = new StringTokenizer(ands[i], Operator.OR.toString());
            if (or_t.countTokens() == 1) {
                terms.add(new ISearchTerm() {

                    public String getSearchTerm() {
                        return term.trim();
                    }

                    public Operator getOperator() {
                        return Operator.AND;
                    }

                    public String toString() {
                        return term + "->" + Operator.AND.toString();
                    }
                });
                or_t.nextToken();
            }
            while (or_t.hasMoreTokens()) {
                final String termo = or_t.nextToken().trim();
                terms.add(new ISearchTerm() {

                    public String toString() {
                        return termo + "->" + Operator.OR.toString();
                    }

                    public String getSearchTerm() {
                        return termo;
                    }

                    public Operator getOperator() {
                        return Operator.OR;
                    }
                });
            }
        }
        ISearchTerm[] s = new ISearchTerm[terms.size()];
        for (int j = terms.size(), k = 0; k < j; k++) {
            s[k] = (ISearchTerm) terms.get(k);
        }
        return s;
    }
    return null;
}
Also used : Operator(de.janrufmonitor.repository.search.Operator) StringTokenizer(java.util.StringTokenizer) ISearchTerm(de.janrufmonitor.repository.search.ISearchTerm) ArrayList(java.util.ArrayList) ICallList(de.janrufmonitor.framework.ICallList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ICallList (de.janrufmonitor.framework.ICallList)1 ISearchTerm (de.janrufmonitor.repository.search.ISearchTerm)1 Operator (de.janrufmonitor.repository.search.Operator)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 StringTokenizer (java.util.StringTokenizer)1