Examples of Criterion


Examples of com.tll.criteria.Criterion

      final CriterionGroup pg = criteria.getPrimaryGroup();
      if(pg != null && pg.isSet()) {
        for(final ICriterion ic : pg) {
          if(ic.isGroup()) throw new InvalidCriteriaException("Nested criterion groups are not supported");
          if(!ic.isSet()) throw new InvalidCriteriaException("criterion not set");
          final Criterion ctn = (Criterion) ic;
          final Object checkValue = ctn.getValue();
          final String pname = ctn.getPropertyName();

          Query pquery;
          if(pname.indexOf('.') > 0) {
            pquery = query;
            // descend one time for each node in the pname (which may be a dot
            // notated property path)
            final PropertyPath path = new PropertyPath(pname);
            for(final String node : path.nodes()) {
              pquery = pquery.descend(node);
            }
          }
          else {
            pquery = query.descend(pname);
          }

          switch(ctn.getComparator()) {
            case BETWEEN: {
              Object min, max;
              if(checkValue instanceof NumberRange) {
                final NumberRange range = (NumberRange) checkValue;
                min = range.getMinimumNumber();
                max = range.getMaximumNumber();
              }
              else if(checkValue instanceof DateRange) {
                final DateRange range = (DateRange) checkValue;
                min = range.getStartDate();
                max = range.getEndDate();
              }
              else {
                // presume an object array
                final Object[] oarr = (Object[]) checkValue;
                min = oarr[0];
                max = oarr[1];
              }
              pquery.constrain(min).greater().equal().or(pquery.constrain(max).smaller().equal());
              break;
            }
            case CONTAINS:
              pquery.constrain(checkValue).contains();
              break;
            case ENDS_WITH:
              pquery.constrain(checkValue).endsWith(ctn.isCaseSensitive());
              break;
            case EQUALS:
              if(!ctn.isCaseSensitive())
                throw new InvalidCriteriaException("Case insensitive equals checking is currently not supported");
              pquery.constrain(checkValue);
              break;
            case GREATER_THAN:
              pquery.constrain(checkValue).greater();
              break;
            case GREATER_THAN_EQUALS:
              pquery.constrain(checkValue).greater().equal();
              break;
            case IN: {
              Object[] arr;
              if(checkValue.getClass().isArray()) {
                arr = (Object[]) checkValue;
              }
              else if(checkValue instanceof Collection<?>) {
                arr = ((Collection) checkValue).toArray();
              }
              else if(checkValue instanceof String) {
                // assume comma-delimited string
                arr =
                    org.springframework.util.ObjectUtils.toObjectArray(org.springframework.util.StringUtils
                        .commaDelimitedListToStringArray((String) checkValue));
              }
              else {
                throw new InvalidCriteriaException(
                    "Unsupported or null type for IN comparator: " + checkValue == null ? "<null>" : checkValue
                        .getClass().toString());
              }
              Constraint c = null;
              for(final Object o : arr) {
                if(c == null) {
                  c = pquery.constrain(o);
                }
                else {
                  c.or(pquery.constrain(o));
                }
              }
              break;
            }
            case IS:
              if(checkValue instanceof DBType == false) {
                throw new InvalidCriteriaException("IS clauses support only check values of type: "
                    + DBType.class.getSimpleName());
              }
              final DBType dbType = (DBType) checkValue;
              if(dbType == DBType.NULL) {
                // null
                pquery.constrain(null);
              }
              else {
                // not null
                pquery.constrain(null).not();
              }
            case LESS_THAN:
              pquery.constrain(checkValue).smaller();
              break;
            case LESS_THAN_EQUALS:
              pquery.constrain(checkValue).smaller().equal();
              break;
            case LIKE:
              pquery.constrain(checkValue).like();
              break;
            case NOT_EQUALS:
              pquery.constrain(checkValue).not();
              break;
            case STARTS_WITH:
              pquery.constrain(checkValue).startsWith(ctn.isCaseSensitive());
              break;
          } // comparator switch
        }
      }
    }
View Full Code Here

Examples of edu.cmu.cs.stage3.util.Criterion

        }
        java.util.Enumeration enum1 = referencesToBeResolved.elements();
        while( enum1.hasMoreElements() ) {
          PropertyReference propertyReference = ((PropertyReference)enum1.nextElement());
          try {
            Criterion criterion = propertyReference.getCriterion();
            if( criterion instanceof VariableCriterion ) {
              VariableCriterion variableCriterion = (VariableCriterion)criterion;
              Element variable = lookup( propertyReference.getProperty().getOwner(), variableCriterion );
              if( variable != null ) {
                propertyReference.getProperty().set( variable );
View Full Code Here

Examples of oracle.adf.view.rich.model.Criterion

            throw new UnsupportedOperationException("ConjunctionCriterionImpl.addCriterion can only add an AttributeCriterion.");
        }
        final AttributeCriterion attrCrit = (AttributeCriterion) criterion;
        boolean found = false;
        for (int i = 0; i < criteria.size(); i++) {
            final Criterion iterCrit = criteria.get(i);
            if (!(iterCrit instanceof AttributeCriterion)) {
                continue;
            }
            final AttributeCriterion iterAttrCrit = (AttributeCriterion) iterCrit;
            if (found && !iterAttrCrit.getAttribute().equals(attrCrit.getAttribute())) {
View Full Code Here

Examples of org.apache.james.mailbox.SearchQuery.Criterion

            return SearchQuery.headerDateBefore(ImapConstants.RFC822_DATE, date.toDate(), DateResolution.Day);
        case SearchKey.TYPE_SENTON:
            return SearchQuery.headerDateOn(ImapConstants.RFC822_DATE, date.toDate(), DateResolution.Day);
        case SearchKey.TYPE_SENTSINCE:
            // Include the date which is used as search param. See IMAP-293
            Criterion onCrit = SearchQuery.headerDateOn(ImapConstants.RFC822_DATE, date.toDate(), DateResolution.Day);
            Criterion afterCrit = SearchQuery.headerDateAfter(ImapConstants.RFC822_DATE, date.toDate(), DateResolution.Day);
            return SearchQuery.or(onCrit, afterCrit);
        case SearchKey.TYPE_SEQUENCE_SET:
            return sequence(key.getSequenceNumbers(), session, true);
        case SearchKey.TYPE_SINCE:
            // Include the date which is used as search param. See IMAP-293
View Full Code Here

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

            return SearchQuery.headerDateBefore(ImapConstants.RFC822_DATE, date.toDate(), DateResolution.Day);
        case SearchKey.TYPE_SENTON:
            return SearchQuery.headerDateOn(ImapConstants.RFC822_DATE, date.toDate(), DateResolution.Day);
        case SearchKey.TYPE_SENTSINCE:
            // Include the date which is used as search param. See IMAP-293
            Criterion onCrit = SearchQuery.headerDateOn(ImapConstants.RFC822_DATE, date.toDate(), DateResolution.Day);
            Criterion afterCrit = SearchQuery.headerDateAfter(ImapConstants.RFC822_DATE, date.toDate(), DateResolution.Day);
            return SearchQuery.or(onCrit, afterCrit);
        case SearchKey.TYPE_SEQUENCE_SET:
            return sequence(key.getSequenceNumbers(), session, true);
        case SearchKey.TYPE_SINCE:
            // Include the date which is used as search param. See IMAP-293
View Full Code Here

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

                    }
                }
            }
        }

        Criterion crit = SearchQuery.uid(ranges.toArray(new SearchQuery.NumericRange[0]));
        return crit;
    }
View Full Code Here

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

    }

    private Criterion or(List<SearchKey> keys, final ImapSession session) throws MessageRangeException {
        final SearchKey keyOne = keys.get(0);
        final SearchKey keyTwo = keys.get(1);
        final Criterion criterionOne = toCriterion(keyOne, session);
        final Criterion criterionTwo = toCriterion(keyTwo, session);
        final Criterion result = SearchQuery.or(criterionOne, criterionTwo);
        return result;
    }
View Full Code Here

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

        return result;
    }

    private Criterion not(List<SearchKey> keys, final ImapSession session) throws MessageRangeException {
        final SearchKey key = keys.get(0);
        final Criterion criterion = toCriterion(key, session);
        final Criterion result = SearchQuery.not(criterion);
        return result;
    }
View Full Code Here

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

    private Criterion and(List<SearchKey> keys, final ImapSession session) throws MessageRangeException {
        final int size = keys.size();
        final List<Criterion> criteria = new ArrayList<Criterion>(size);
        for (final SearchKey key : keys) {
            final Criterion criterion = toCriterion(key, session);
            criteria.add(criterion);
        }
        final Criterion result = SearchQuery.and(criteria);
        return result;
    }
View Full Code Here

Examples of org.apache.torque.criteria.Criterion

        {
            titleSet.add(validTitles[j]);
        }

        Criteria crit = new Criteria();
        Criterion c = new Criterion(BookPeer.TITLE,
                "Book 6 - Author 1", Criteria.GREATER_EQUAL);
        c.and(new Criterion(BookPeer.TITLE,
                "Book 8 - Author 3", Criteria.LESS_EQUAL));
        crit.where(c);
        crit.addDescendingOrderByColumn(BookPeer.BOOK_ID);
        crit.setLimit(10);
        crit.setOffset(5);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.