Package com.alibaba.citrus.service.form.support

Examples of com.alibaba.citrus.service.form.support.NumberSupport


                    fail();
            }

            if (result != null) {
                v.afterPropertiesSet();
                NumberSupport num = null;
                String numStr = null;

                switch (i) {
                    case 0:
                        num = v.getOperand(equalTo);
                        numStr = v.getEqualTo();
                        break;

                    case 1:
                        num = v.getOperand(notEqualTo);
                        numStr = v.getNotEqualTo();
                        break;

                    case 2:
                        num = v.getOperand(lessThan);
                        numStr = v.getLessThan();
                        break;

                    case 3:
                        num = v.getOperand(greaterThan);
                        numStr = v.getGreaterThan();
                        break;

                    case 4:
                        num = v.getOperand(lessThanOrEqualTo);
                        numStr = v.getLessThanOrEqualTo();
                        break;

                    case 5:
                        num = v.getOperand(greaterThanOrEqualTo);
                        numStr = v.getGreaterThanOrEqualTo();
                        break;

                    default:
                        fail();
                }

                assertEquals(result, num.getValue());
                assertEquals(result.toString(), numStr);
            } else {
                assertInitError(v, exception(NumberFormatException.class, value)); // For input string: value
            }
        }
View Full Code Here


    /** 验证一个字段。 */
    @Override
    protected boolean validate(Context context, String value) {
        Field fieldToCompare = assertNotNull(context.getField(fieldName), "field not found");
        NumberSupport thisValue = new NumberSupport(getNumberType(), value);
        NumberSupport otherValue = new NumberSupport(getNumberType(), fieldToCompare.getStringValue());

        try {
            return getOp().accept(thisValue.compareTo(otherValue));
        } catch (IllegalArgumentException e) {
            return false; // 包括NumberFormatException。如果getValue失败,验证失败。
View Full Code Here

    public void setGreaterThanOrEqualTo(String value) {
        setOperand(greaterThanOrEqualTo, value);
    }

    private String getOperandString(CompareOperator op) {
        NumberSupport n = getOperand(op);
        return n == null ? null : n.getStringValue();
    }
View Full Code Here

    public final NumberSupport getOperand(CompareOperator op) {
        return operands[op.ordinal()];
    }

    protected final void setOperand(CompareOperator op, String value) {
        operands[op.ordinal()] = new NumberSupport(null, trimToNull(value));
    }
View Full Code Here

    }

    /** 验证一个字段。 */
    @Override
    protected boolean validate(Context context, String value) {
        NumberSupport numberValue = new NumberSupport(getNumberType(), value);
        boolean valid = true;

        try {
            numberValue.getValue();
        } catch (NumberFormatException e) {
            valid = false;
        }

        if (valid) {
            for (int i = 0; i < operands.length; i++) {
                if (operands[i] != null) {
                    valid &= CompareOperator.values()[i].accept(numberValue.compareTo(operands[i]));
                }
            }
        }

        return valid;
View Full Code Here

     * ��֤һ���ֶΡ�
     */
    @Override
    protected boolean validate(Context context, String value) {
        Field fieldToCompare = assertNotNull(context.getField(fieldName), "field not found");
        NumberSupport thisValue = new NumberSupport(getNumberType(), value);
        NumberSupport otherValue = new NumberSupport(getNumberType(), fieldToCompare.getStringValue());

        try {
            return getOp().accept(thisValue.compareTo(otherValue));
        } catch (IllegalArgumentException e) {
            return false; // ����NumberFormatException�����getValueʧ�ܣ���֤ʧ�ܡ�
View Full Code Here

    public void setGreaterThanOrEqualTo(String value) {
        setOperand(greaterThanOrEqualTo, value);
    }

    private String getOperandString(CompareOperator op) {
        NumberSupport n = getOperand(op);
        return n == null ? null : n.getStringValue();
    }
View Full Code Here

    public final NumberSupport getOperand(CompareOperator op) {
        return operands[op.ordinal()];
    }

    protected final void setOperand(CompareOperator op, String value) {
        operands[op.ordinal()] = new NumberSupport(null, trimToNull(value));
    }
View Full Code Here

    /**
     * ��֤һ���ֶΡ�
     */
    @Override
    protected boolean validate(Context context, String value) {
        NumberSupport numberValue = new NumberSupport(getNumberType(), value);
        boolean valid = true;

        try {
            numberValue.getValue();
        } catch (NumberFormatException e) {
            valid = false;
        }

        for (int i = 0; i < operands.length; i++) {
            if (operands[i] != null) {
                valid &= CompareOperator.values()[i].accept(numberValue.compareTo(operands[i]));
            }
        }

        return valid;
    }
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.service.form.support.NumberSupport

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.