Package org.apache.cxf.jaxrs.ext.search

Examples of org.apache.cxf.jaxrs.ext.search.SearchParseException


                    SearchBean bean = (SearchBean)conditionClass.newInstance();
                    bean.set(setter, tvalue.getObject().toString());
                    return (T)bean;
                }
            } catch (Throwable e) {
                throw new SearchParseException(e);
            }
        }
View Full Code Here


            final T condition = conditionClass.newInstance();
            final FilterExpression expression = parser.parseFilterString(searchExpression);
            final FilterExpressionVisitor visitor = new FilterExpressionVisitor(condition);           
            return (SearchCondition< T >)expression.accept(visitor);           
        } catch (ODataMessageException ex) {
            throw new SearchParseException(ex);
        } catch (ODataApplicationException ex) {
            throw new SearchParseException(ex);
        } catch (InstantiationException ex) {
            throw new SearchParseException(ex);
        } catch (IllegalAccessException ex) {
            throw new SearchParseException(ex);
        }
    }
View Full Code Here

                        return new AndSearchCondition< T >(conditions);
                    } else if (operator == BinaryOperator.OR) {
                        return new OrSearchCondition< T >(conditions);
                    }
                } else {
                    throw new SearchParseException(
                        "Unsupported binary operation arguments (SearchCondition expected): "
                            + leftSide + ", " + rightSide);
                }
            }

            // Property could be either on left side (Name eq 'Tom') or
            // right side ('Tom' eq Name)
            TypedValue value = null;
            TypedProperty property = null;
           
            if (leftSide instanceof TypedProperty && rightSide instanceof TypedValue) {
                property = (TypedProperty)leftSide;
                value = (TypedValue)rightSide;
            } else if (rightSide instanceof TypedProperty && leftSide instanceof TypedValue) {
                property = (TypedProperty)rightSide;
                value = (TypedValue)leftSide;
            } else {
                throw new SearchParseException(
                    "Unsupported binary operation arguments (TypedValue or TypedProperty expected): "
                        + leftSide + ", " + rightSide);
            }
                      
            ConditionType conditionType = null;
            switch (operator) {
            case EQ:   
                conditionType = ConditionType.EQUALS;
                break;
            case NE:
                conditionType = ConditionType.NOT_EQUALS;
                break;
            case LT:
                conditionType = ConditionType.LESS_THAN;
                break;
            case LE:
                conditionType = ConditionType.LESS_OR_EQUALS;
                break;
            case GT:
                conditionType = ConditionType.GREATER_THAN;
                break;               
            case GE:
                conditionType = ConditionType.GREATER_OR_EQUALS;
                break;               
            default:
                throw new SearchParseException("Unsupported binary operation: " + operator);
            }
           
            Object typedValue = null;
            // If property type and value type are compatible, just use them
            if (property.typeInfo.getTypeClass().isAssignableFrom(value.typeClass)) {
View Full Code Here

                final Object value = type.valueOfString(edmLiteral.getLiteral(),
                    EdmLiteralKind.DEFAULT, null, type.getDefaultType());
               
                return new TypedValue(type.getDefaultType(), edmLiteral.getLiteral(), value);
            } catch (EdmSimpleTypeException ex) {
                throw new SearchParseException("Failed to convert literal to a typed form: " + literal, ex);
            }
        }
View Full Code Here

            return new TypedProperty(typeInfo, setter);
        }

        @Override
        public Object visitMethod(MethodExpression methodExpression, MethodOperator method, List<Object> parameters) {
            throw new SearchParseException("Unsupported operation visitMethod: " + methodExpression
                + "," + method + "," + parameters);
        }
View Full Code Here

                + "," + method + "," + parameters);
        }

        @Override
        public Object visitMember(MemberExpression memberExpression, Object path, Object property) {
            throw new SearchParseException("Unsupported operation visitMember: "
                + memberExpression + "," + path + "," + property);           
        }
View Full Code Here

                + memberExpression + "," + path + "," + property);           
        }

        @Override
        public Object visitUnary(UnaryExpression unaryExpression, UnaryOperator operator, Object operand) {
            throw new SearchParseException("Unsupported operation visitUnary: " + unaryExpression
                + "," + operator + "," + operand);
        }
View Full Code Here

        }
       
        @Override
        public Object visitOrderByExpression(OrderByExpression orderByExpression, String expressionString,
                List<Object> orders) {
            throw new SearchParseException("Unsupported operation visitOrderByExpression: "
                + orderByExpression + "," + expressionString + "," + orders);
        }
View Full Code Here

                + orderByExpression + "," + expressionString + "," + orders);
        }

        @Override
        public Object visitOrder(OrderExpression orderExpression, Object filterResult, SortOrder sortOrder) {
            throw new SearchParseException("Unsupported operation visitOrder: " + orderExpression
                + "," + filterResult + "," + sortOrder);
        }       
View Full Code Here

            if (c == '(') {
                level++;
            } else if (c == ')') {
                level--;
                if (level < 0) {
                    throw new SearchParseException(String.format("Unexpected closing bracket at position %d",
                                                               idx));
                }
            }
            String cs = Character.toString(c);
            boolean isOperator = AND.equals(cs) || OR.equals(cs);
            if (level == 0 && isOperator) {
                String s1 = expr.substring(lastIdx, idx);
                String s2 = expr.substring(idx, idx + 1);
                subexpressions.add(s1);
                operators.add(s2);
                lastIdx = idx + 1;
            }
            boolean isEnd = idx == expr.length() - 1;
            if (isEnd) {
                String s1 = expr.substring(lastIdx, idx + 1);
                subexpressions.add(s1);
                operators.add(null);
                lastIdx = idx + 1;
            }
        }
        if (level != 0) {
            throw new SearchParseException(String
                .format("Unmatched opening and closing brackets in expression: %s", expr));
        }
        if (operators.get(operators.size() - 1) != null) {
            String op = operators.get(operators.size() - 1);
            String ex = subexpressions.get(subexpressions.size() - 1);
            throw new SearchParseException("Dangling operator at the end of expression: ..." + ex + op);
        }
        // looking for adjacent ANDs then group them into ORs
        // Note: in case not ANDs is found (e.g only ORs) every single subexpression is
        // treated as "single item group of ANDs"
        int from = 0;
View Full Code Here

TOP

Related Classes of org.apache.cxf.jaxrs.ext.search.SearchParseException

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.