Package org.apache.james.mailbox.model.SearchQuery

Examples of org.apache.james.mailbox.model.SearchQuery.NumericRange


            SearchQuery searchQuery = new SearchQuery();
            NumericRange[] nRanges = new NumericRange[ranges.size()];
            Set<Long> vanishedUids = new HashSet<Long>();
            for (int i = 0; i < ranges.size(); i++) {
                MessageRange r = ranges.get(i);
                NumericRange nr;
                if (r.getType() == Type.ONE) {
                    nr = new NumericRange(r.getUidFrom());
                } else {
                    nr = new NumericRange(r.getUidFrom(), r.getUidTo());
                }
                long from = nr.getLowValue();
                long to = nr.getHighValue();
                while(from <= to) {
                    vanishedUids.add(from++);
                }
                nRanges[i] = nr;
               
View Full Code Here


        final NumericRange[] ranges = operator.getRange();
        final long uid = message.getUid();
        final int length = ranges.length;
        boolean result = false;
        for (int i = 0; i < length; i++) {
            final NumericRange numericRange = ranges[i];
            if (numericRange.isIn(uid)) {
                result = true;
                break;
            }
        }
        return result;
View Full Code Here

        if (crits.size() == && crits.get(0) instanceof UidCriterion) {
            final List<Long> uids = new ArrayList<Long>();
            UidCriterion uidCrit = (UidCriterion) crits.get(0);
            NumericRange[] ranges = uidCrit.getOperator().getRange();
            for (int i = 0; i < ranges.length; i++) {
                NumericRange r = ranges[i];
                Iterator<Message<Id>> messages = mapper.findInMailbox(mailbox, MessageRange.range(r.getLowValue(), r.getHighValue()), FetchType.Metadata, -1);
               
                while(messages.hasNext()) {
                    long uid = messages.next().getUid();
                    if (uids.contains(uid) == false) {
                        uids.add(uid);
View Full Code Here

     * @throws UnsupportedSearchException
     */
    private Query createUidQuery(SearchQuery.UidCriterion crit) throws UnsupportedSearchException {
        NumericRange[] ranges = crit.getOperator().getRange();
        if (ranges.length == 1) {
            NumericRange range = ranges[0];
            return NumericRangeQuery.newLongRange(UID_FIELD, range.getLowValue(), range.getHighValue(), true, true);
        } else {
            BooleanQuery rangesQuery = new BooleanQuery();
            for (int i = 0; i < ranges.length; i++) {
                NumericRange range = ranges[i];
                rangesQuery.add(NumericRangeQuery.newLongRange(UID_FIELD, range.getLowValue(), range.getHighValue(), true, true), BooleanClause.Occur.SHOULD);
            }       
            return rangesQuery;
        }
    }
View Full Code Here

           
            List<MessageRange> ranges = MessageRange.toRanges(new ArrayList<Long>(uids));
            NumericRange[] nRanges = new NumericRange[ranges.size()];
            for (int i = 0; i < ranges.size(); i++) {
                MessageRange range = ranges.get(i);
                nRanges[i] = new NumericRange(range.getUidFrom(), range.getUidTo());
            }
            return createUidQuery((UidCriterion) SearchQuery.uid(nRanges));
        } catch (IOException e) {
            throw new MailboxException("Unable to search mailbox " + mailbox, e);
        } finally {
View Full Code Here

TOP

Related Classes of org.apache.james.mailbox.model.SearchQuery.NumericRange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.