Package org.teiid.api.exception.query

Examples of org.teiid.api.exception.query.ExpressionEvaluationException


                  } else {
                      newPattern.append(newSingleMatch);
                  }
              } else {
                  if (escaped) {
                      throw new ExpressionEvaluationException(QueryPlugin.Util.getString("MatchCriteria.invalid_escape", new Object[] {pattern, new Character(escape)})); //$NON-NLS-1$
                  }
                  appendCharacter(newPattern, character);
              }
          }
         
          if (escaped) {
              throw new ExpressionEvaluationException(QueryPlugin.Util.getString("MatchCriteria.invalid_escape", new Object[] {pattern, new Character(escape)})); //$NON-NLS-1$ 
          }
         
          return newPattern;
      }
View Full Code Here


        } else if(criteria instanceof ExistsCriteria) {
            return Boolean.valueOf(evaluate((ExistsCriteria)criteria, tuple));
        } else if (criteria instanceof ExpressionCriteria) {
          return (Boolean)evaluate(((ExpressionCriteria)criteria).getExpression(), tuple);
    } else {
            throw new ExpressionEvaluationException("ERR.015.006.0010", QueryPlugin.Util.getString("ERR.015.006.0010", criteria)); //$NON-NLS-1$ //$NON-NLS-2$
    }
  }
View Full Code Here

    // Evaluate left expression
    Object leftValue = null;
    try {
      leftValue = evaluate(criteria.getLeftExpression(), tuple);
    } catch(ExpressionEvaluationException e) {
            throw new ExpressionEvaluationException(e, "ERR.015.006.0011", QueryPlugin.Util.getString("ERR.015.006.0011", new Object[] {"left", criteria})); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }

    // Shortcut if null
    if(leftValue == null) {
      return null;
    }

    // Evaluate right expression
    Object rightValue = null;
    try {
      rightValue = evaluate(criteria.getRightExpression(), tuple);
    } catch(ExpressionEvaluationException e) {
            throw new ExpressionEvaluationException(e, "ERR.015.006.0011", QueryPlugin.Util.getString("ERR.015.006.0011", new Object[]{"right", criteria})); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }

    // Shortcut if null
    if(rightValue == null) {
      return null;
View Full Code Here

      case CompareCriteria.GT:
        return Boolean.valueOf((compareValues(leftValue, rightValue) > 0));
      case CompareCriteria.GE:
        return Boolean.valueOf((compareValues(leftValue, rightValue) >= 0));
      default:
                throw new ExpressionEvaluationException("ERR.015.006.0012", QueryPlugin.Util.getString("ERR.015.006.0012", criteria.getOperator())); //$NON-NLS-1$ //$NON-NLS-2$
    }
  }
View Full Code Here

    // Evaluate left expression
        Object value = null;
    try {
      value = evaluate(criteria.getLeftExpression(), tuple);
    } catch(ExpressionEvaluationException e) {
            throw new ExpressionEvaluationException(e, "ERR.015.006.0011", QueryPlugin.Util.getString("ERR.015.006.0011", new Object[]{"left", criteria})); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }

    // Shortcut if null
    if(value == null) {
            return null;
        }
       
        CharSequence leftValue = null;
       
        if (value instanceof CharSequence) {
            leftValue = (CharSequence)value;
        } else {
            try {
                leftValue = ((Sequencable)value).getCharSequence();
            } catch (SQLException err) {
                throw new ExpressionEvaluationException(err, err.getMessage());
            }
        }

    // Evaluate right expression
    String rightValue = null;
    try {
      rightValue = (String) evaluate(criteria.getRightExpression(), tuple);
    } catch(ExpressionEvaluationException e) {
            throw new ExpressionEvaluationException(e, "ERR.015.006.0011", QueryPlugin.Util.getString("ERR.015.006.0011", new Object[]{"right", criteria})); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }

    // Shortcut if null
    if(rightValue == null) {
            return null;
View Full Code Here

    try {
            Pattern patternRegex = Pattern.compile(rePattern.toString(), Pattern.DOTALL);
            Matcher matcher = patternRegex.matcher(search);
            return matcher.matches();
    } catch(PatternSyntaxException e) {
            throw new ExpressionEvaluationException(e, "ERR.015.006.0014", QueryPlugin.Util.getString("ERR.015.006.0014", new Object[]{pattern, e.getMessage()})); //$NON-NLS-1$ //$NON-NLS-2$
    }
  }
View Full Code Here

    // Evaluate expression
    Object leftValue = null;
    try {
      leftValue = evaluate(criteria.getExpression(), tuple);
    } catch(ExpressionEvaluationException e) {
            throw new ExpressionEvaluationException(e, "ERR.015.006.0015", QueryPlugin.Util.getString("ERR.015.006.0015", criteria)); //$NON-NLS-1$ //$NON-NLS-2$
    }

    // Shortcut if null
    if(leftValue == null) {
            return null;
        }
        Boolean result = Boolean.FALSE;

        ValueIterator valueIter = null;
        if (criteria instanceof SetCriteria) {
          SetCriteria set = (SetCriteria)criteria;
          if (set.isAllConstants()) {
            boolean exists = set.getValues().contains(new Constant(leftValue, criteria.getExpression().getType()));
            if (!exists) {
              if (set.getValues().contains(Constant.NULL_CONSTANT)) {
                return null;
              }
              return criteria.isNegated();
            }
            return !criteria.isNegated();
          }
          valueIter = new CollectionValueIterator(((SetCriteria)criteria).getValues());
        } else if (criteria instanceof DependentSetCriteria){
          ContextReference ref = (ContextReference)criteria;
        ValueIteratorSource vis = (ValueIteratorSource)getContext(criteria).getVariableContext().getGlobalValue(ref.getContextSymbol());
        Set<Object> values;
        try {
          values = vis.getCachedSet(ref.getValueExpression());
        } catch (TeiidProcessingException e) {
          throw new ExpressionEvaluationException(e, e.getMessage());
        }
          if (values != null) {
            return values.contains(leftValue);
          }
          //there are too many values to justify a linear search or holding
          //them in memory
          return true;
        } else if (criteria instanceof SubquerySetCriteria) {
          try {
        valueIter = evaluateSubquery((SubquerySetCriteria)criteria, tuple);
      } catch (TeiidProcessingException e) {
        throw new ExpressionEvaluationException(e, e.getMessage());
      }
        } else {
          throw new AssertionError("unknown set criteria type"); //$NON-NLS-1$
        }
        while(valueIter.hasNext()) {
            Object possibleValue = valueIter.next();
            Object value = null;
            if(possibleValue instanceof Expression) {
          try {
            value = evaluate((Expression) possibleValue, tuple);
          } catch(ExpressionEvaluationException e) {
                    throw new ExpressionEvaluationException(e, "ERR.015.006.0015", QueryPlugin.Util.getString("ERR.015.006.0015", possibleValue)); //$NON-NLS-1$ //$NON-NLS-2$
          }
            } else {
                value = possibleValue;
            }
View Full Code Here

    // Evaluate expression
    Object value = null;
    try {
      value = evaluate(criteria.getExpression(), tuple);
    } catch(ExpressionEvaluationException e) {
            throw new ExpressionEvaluationException(e, "ERR.015.006.0015", QueryPlugin.Util.getString("ERR.015.006.0015", criteria)); //$NON-NLS-1$ //$NON-NLS-2$
    }

    return (value == null ^ criteria.isNegated());
  }
View Full Code Here

        // Evaluate expression
        Object leftValue = null;
        try {
            leftValue = evaluate(criteria.getLeftExpression(), tuple);
        } catch(ExpressionEvaluationException e) {
            throw new ExpressionEvaluationException(e, "ERR.015.006.0015", QueryPlugin.Util.getString("ERR.015.006.0015", criteria)); //$NON-NLS-1$ //$NON-NLS-2$
        }

        // Shortcut if null
        if(leftValue == null) {
            return null;
        }

        // Need to be careful to initialize this variable carefully for the case
        // where valueIterator has no values, and the block below is not entered.
        // If there are no rows, and ALL is the predicate quantifier, the result
        // should be true.  If SOME is the predicate quantifier, or no quantifier
        // is used, the result should be false.
        Boolean result = Boolean.FALSE;
        if (criteria.getPredicateQuantifier() == SubqueryCompareCriteria.ALL){
            result = Boolean.TRUE;
        }

        ValueIterator valueIter;
    try {
      valueIter = evaluateSubquery(criteria, tuple);
    } catch (TeiidProcessingException e) {
      throw new ExpressionEvaluationException(e, e.getMessage());
    }
        while(valueIter.hasNext()) {
            Object value = valueIter.next();

            if(value != null) {
              int compare = compareValues(leftValue, value);
                // Compare two non-null values using specified operator
                switch(criteria.getOperator()) {
                    case SubqueryCompareCriteria.EQ:
                        result = Boolean.valueOf(compare == 0);
                        break;
                    case SubqueryCompareCriteria.NE:
                        result = Boolean.valueOf(compare != 0);
                        break;
                    case SubqueryCompareCriteria.LT:
                        result = Boolean.valueOf(compare < 0);
                        break;
                    case SubqueryCompareCriteria.LE:
                        result = Boolean.valueOf(compare <= 0);
                        break;
                    case SubqueryCompareCriteria.GT:
                        result = Boolean.valueOf(compare > 0);
                        break;
                    case SubqueryCompareCriteria.GE:
                        result = Boolean.valueOf(compare >= 0);
                        break;
                    default:
                        throw new ExpressionEvaluationException("ERR.015.006.0012", QueryPlugin.Util.getString("ERR.015.006.0012", criteria.getOperator())); //$NON-NLS-1$ //$NON-NLS-2$
                }

                switch(criteria.getPredicateQuantifier()) {
                    case SubqueryCompareCriteria.ALL:
                        if (Boolean.FALSE.equals(result)){
                            return Boolean.FALSE;
                        }
                        break;
                    case SubqueryCompareCriteria.SOME:
                        if (Boolean.TRUE.equals(result)){
                            return Boolean.TRUE;
                        }
                        break;
                    default:
                        throw new ExpressionEvaluationException("ERR.015.006.0057", QueryPlugin.Util.getString("ERR.015.006.0057", criteria.getPredicateQuantifier())); //$NON-NLS-1$ //$NON-NLS-2$
                }

            } else { // value is null
                result = null;
            }
View Full Code Here

        ValueIterator valueIter;
    try {
      valueIter = evaluateSubquery(criteria, tuple);
    } catch (TeiidProcessingException e) {
      throw new ExpressionEvaluationException(e, e.getMessage());
    }
        if(valueIter.hasNext()) {
            return !criteria.isNegated();
        }
        return criteria.isNegated();
View Full Code Here

TOP

Related Classes of org.teiid.api.exception.query.ExpressionEvaluationException

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.