Package jsonij.json

Examples of jsonij.json.Value


                                expressionStringBuilder.append(c);
                                predicateComponentBuilder.append(c);
                            }
                            value = predicateComponentBuilder.toString().trim();
                            JSONParser jsonParser = new JSONParser();
                            Value jsonValue = jsonParser.parseValue(value);
                            target.skipWhitepace(expressionStringBuilder);
                            OperatorExpressionPredicateCondition predicateCondition = new OperatorExpressionPredicateCondition(attribute, expressionPredicateOperator, jsonValue);
                            if(op != null) {
                                predicateCondition.setCombine(op);
                                op = null;
View Full Code Here


    public List<Value> evaluate(List<Value> values, List<Value> results) {

        for (Value value : values) {
            if (value.getValueType() == Value.TYPE.ARRAY) {
                for (int j = 0; j < value.size(); j++) {
                    Value checkElement = value.get(j);
                    if (checkElement.getValueType() == Value.TYPE.OBJECT) {
                        boolean expressionValid = true;
                        for (ExpressionPredicateCondition condition : conditions) {
                            if (condition instanceof OperatorExpressionPredicateCondition) {
                                OperatorExpressionPredicateCondition operatorCondition = (OperatorExpressionPredicateCondition) condition;
                                Value checkValue = checkElement.get(operatorCondition.getAttribute());
                                if (checkValue == null) {
                                    expressionValid = false;
                                    break;
                                }
                                ExpressionPredicateOperator expressionConditionOperator = operatorCondition.getOperator();
                                if (expressionConditionOperator.equals(ExpressionPredicateOperator.NOT_NULL)) {
                                    if (checkValue.isNull()) {
                                        expressionValid = false;
                                        break;
                                    }
                                } else if (expressionConditionOperator.equals(ExpressionPredicateOperator.EQUAL)) {
                                    if (!checkValue.equals(operatorCondition.value)) {
                                        expressionValid = false;
                                        break;
                                    }
                                } else if (expressionConditionOperator.equals(ExpressionPredicateOperator.LESS)) {
                                } else if (expressionConditionOperator.equals(ExpressionPredicateOperator.GREATER)) {
                                } else if (expressionConditionOperator.equals(ExpressionPredicateOperator.LESS_EQUAL)) {
                                } else if (expressionConditionOperator.equals(ExpressionPredicateOperator.GREATER_EQUAL)) {
                                }
                            } else if (condition instanceof FunctionExpressionPredicateCondition) {
                                FunctionExpressionPredicateCondition functionCondition = (FunctionExpressionPredicateCondition) condition;
                                String functionName = functionCondition.getFunctionName();
                                FunctionArgument[] funtionArguments = functionCondition.getArguments();

                                if(functionName.equals("regex")) {
                                    RegexFunction regexFunction = new RegexFunction();
                                    Value result = regexFunction.evaluate(funtionArguments, checkElement);
                                    if(result == null) {
                                        expressionValid = false;
                                        break;
                                    }
                                }
                            }
                        }

                        if (expressionValid) {
                            results.add(checkElement);
                        }
                    }
                }
            } else {
                if(value.getValueType() == Value.TYPE.OBJECT) {

                    boolean expressionValid = true;
                    for (ExpressionPredicateCondition condition : conditions) {
                        if (condition instanceof OperatorExpressionPredicateCondition) {
                            OperatorExpressionPredicateCondition operatorCondition = (OperatorExpressionPredicateCondition) condition;
                            Value checkValue = value.get(operatorCondition.getAttribute());
                            if (checkValue == null) {
                                expressionValid = false;
                                break;
                            }
                            ExpressionPredicateOperator expressionConditionOperator = operatorCondition.getOperator();
                            if (expressionConditionOperator.equals(ExpressionPredicateOperator.NOT_NULL)) {
                                if (checkValue.isNull()) {
                                    expressionValid = false;
                                    break;
                                }
                            } else if (expressionConditionOperator.equals(ExpressionPredicateOperator.EQUAL)) {
                                if (!checkValue.equals(operatorCondition.value)) {
                                    expressionValid = false;
                                    break;
                                }
                            } else if (expressionConditionOperator.equals(ExpressionPredicateOperator.LESS)) {
                            } else if (expressionConditionOperator.equals(ExpressionPredicateOperator.GREATER)) {
                            } else if (expressionConditionOperator.equals(ExpressionPredicateOperator.LESS_EQUAL)) {
                            } else if (expressionConditionOperator.equals(ExpressionPredicateOperator.GREATER_EQUAL)) {
                            }
                        } else if (condition instanceof FunctionExpressionPredicateCondition) {
                            FunctionExpressionPredicateCondition functionCondition = (FunctionExpressionPredicateCondition) condition;
                            String functionName = functionCondition.getFunctionName();
                            FunctionArgument[] funtionArguments = functionCondition.getArguments();

                            if(functionName.equals("regex")) {
                                RegexFunction regexFunction = new RegexFunction();
                                Value result = regexFunction.evaluate(funtionArguments, value);
                                if(result != null) {
                                    results.add(value);
                                }
                            }
                        }
View Full Code Here

            return new JSON.Array<JSON.Numeric>();
        }
        CycleDetector cycleDetector = new CycleDetector();
        JSON.Array<Value> marshaledArray = new JSON.Array<Value>();
        for (int i = 0; i < size; i++) {
            Value marshaledObject = marshalJavaObject(a[i], cycleDetector);
            if(marshaledObject != null) {
                marshaledArray.add(marshaledObject);
            } else {
                marshaledArray.add(JSON.NULL);
            }
View Full Code Here

    protected Value marshalAnyObject(Object o, CycleDetector cycleDetector) {
        if(o == null) {
            return JSON.NULL;
        }
        Value marshaledObject = null;
        Class<?> objectClass = o.getClass();
        TYPE objectType = inspectObjectType(objectClass);
        switch (objectType) {
            case BOOLEAN:
                marshaledObject = marshalJavaBoolean(o);
View Full Code Here

        }
        return marshaledObject;
    }

    protected Value marshalJavaBoolean(Object o) {
        Value value = null;
        boolean marshaledBoolean = (Boolean) o;
        if (marshaledBoolean) {
            value = JSON.TRUE;
        } else {
            value = JSON.FALSE;
View Full Code Here

        }
        return value;
    }

    protected Value marshalJavaNumeric(Object o) {
        Value value = null;
        Number marshaledNumber = null;
        marshaledNumber = (Number) o;
        if (marshaledNumber != null) {
            value = new JSON.Numeric(marshaledNumber);
        } else {
View Full Code Here

        }
        return value;
    }

    protected Value marshalJavaEnum(Object o) {
        Value value = null;
        if (o != null) {
            String marshaledEnumeration = o.toString();
            value = new JSON.String(marshaledEnumeration);
        } else {
            value = JSON.NULL;
View Full Code Here

        }
        return value;
    }

    protected Value marshalJavaString(Object o) {
        Value value = null;
        String marshaledString = (String) o;
        if (marshaledString != null) {
            value = new JSON.String(marshaledString);
        } else {
            value = JSON.NULL;
View Full Code Here

        }
        return value;
    }

    protected Value marshalJavaArray(Object o, CycleDetector cycleDetector) {
        Value value = null;
        if (o != null) {
            JSON.Array<Value> marshaledArray = new JSON.Array<Value>();
            int size = Array.getLength(o);
            Class<?> type = o.getClass();
            Class<?> componentType = type.getComponentType();
View Full Code Here

        }
        return value;
    }

    protected Value marshalJavaList(Object o, CycleDetector cycleDetector) {
        Value value = null;
        List<?> marshaledList = (List<?>) o;
        if (marshaledList != null) {
            JSON.Array<Value> marshaledArray = new JSON.Array<Value>();
            Iterator<?> marshaledListIterator = marshaledList.listIterator();
            Object listItem = null;
View Full Code Here

TOP

Related Classes of jsonij.json.Value

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.