CPD Results

The following document contains the results of PMD's CPD 4.2.2.

Duplications

File Line
org/springmodules/validation/util/date/DefaultDateParser.java 321
org/springmodules/validation/util/date/DefaultDateParser.java 337
        register("^T<y$", new DateModifier() {
            public void modify(Calendar calendar, String value) {
                int thisYear = calendar.get(Calendar.YEAR);
                calendar.add(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) * -1);
                calendar.add(Calendar.MINUTE, calendar.get(Calendar.MINUTE) * -1);
                calendar.add(Calendar.SECOND, calendar.get(Calendar.SECOND) * -1);
                calendar.add(Calendar.MILLISECOND, calendar.get(Calendar.MILLISECOND) * -1);

                while (thisYear == calendar.get(Calendar.YEAR)) {
                    calendar.add(Calendar.DAY_OF_YEAR, -1);

File Line
org/springmodules/validation/util/date/DefaultDateParser.java 278
org/springmodules/validation/util/date/DefaultDateParser.java 294
        register("^T<M$", new DateModifier() {
            public void modify(Calendar calendar, String value) {
                int thisMonth = calendar.get(Calendar.MONTH);
                calendar.add(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) * -1);
                calendar.add(Calendar.MINUTE, calendar.get(Calendar.MINUTE) * -1);
                calendar.add(Calendar.SECOND, calendar.get(Calendar.SECOND) * -1);
                calendar.add(Calendar.MILLISECOND, calendar.get(Calendar.MILLISECOND) * -1);

                while (thisMonth == calendar.get(Calendar.MONTH)) {
                    calendar.add(Calendar.DAY_OF_YEAR, -1);

File Line
org/springmodules/validation/util/date/DefaultDateParser.java 235
org/springmodules/validation/util/date/DefaultDateParser.java 251
        register("^T<w$", new DateModifier() {
            public void modify(Calendar calendar, String value) {
                int thisWeek = calendar.get(Calendar.WEEK_OF_YEAR);
                calendar.add(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) * -1);
                calendar.add(Calendar.MINUTE, calendar.get(Calendar.MINUTE) * -1);
                calendar.add(Calendar.SECOND, calendar.get(Calendar.SECOND) * -1);
                calendar.add(Calendar.MILLISECOND, calendar.get(Calendar.MILLISECOND) * -1);

                while (thisWeek == calendar.get(Calendar.WEEK_OF_YEAR)) {
                    calendar.add(Calendar.DAY_OF_YEAR, -1);

File Line
org/springmodules/validation/bean/conf/loader/xml/handler/AbstractClassValidationElementHandler.java 118
org/springmodules/validation/bean/conf/loader/xml/handler/AbstractPropertyValidationElementHandler.java 137
    public void handle(Element element, String propertyName, MutableBeanValidationConfiguration configuration) {

        AbstractValidationRule rule = createValidationRule(element);

        String errorCode = extractErrorCode(element);
        if (errorCode != null) {
            rule.setErrorCode(errorCode);
        }

        String message = extractMessage(element);
        if (message != null) {
            rule.setDefaultErrorMessage(message);
        }

        ErrorArgumentsResolver argumentsResolver = extractArgumentsResolver(element);
        if (argumentsResolver != null) {
            rule.setErrorArgumentsResolver(argumentsResolver);
        }

        Condition applicabilityCondition = extractApplicabilityCondition(element);
        if (applicabilityCondition != null) {
            rule.setApplicabilityCondition(applicabilityCondition);
        }

        String[] applicableContexts = extractApplicableContexts(element);
        if (applicableContexts != null) {
            rule.setContextTokens(applicableContexts);
        }

File Line
org/springmodules/validation/bean/conf/loader/xml/handler/AbstractClassValidationElementHandler.java 206
org/springmodules/validation/bean/conf/loader/xml/handler/AbstractPropertyValidationElementHandler.java 244
        String expression = element.getAttribute(APPLY_IF_ATTR);
        return (StringUtils.hasText(expression)) ? conditionExpressionParser.parse(expression) : null;
    }

    /**
     * Extracts the names of the validation context in which the valiation rule is applicable. Expects a "contexts"
     * attribute to hold a comma-separated list of context names. If no such attribute exists or if it holds an empty
     * string, <code>null </code> is returned. As the contract of {@link AbstractValidationRule#setContextTokens(String[])}
     * defines <code>null</code> means that the rule always applies regardless of the context.
     *
     * @param element The element that represents the validation rule.
     * @return The names of the validation contexts in which the
     */
    protected String[] extractApplicableContexts(Element element) {
        String contextString = element.getAttribute(CONTEXTS_ATTR);
        return (StringUtils.hasText(contextString)) ? StringUtils.commaDelimitedListToStringArray(contextString) : null;
    }

    /**
     * @see ConditionExpressionBased#setConditionExpressionParser(org.springmodules.validation.util.cel.ConditionExpressionParser)
     */
    public void setConditionExpressionParser(ConditionExpressionParser conditionExpressionParser) {
        this.conditionExpressionParser = conditionExpressionParser;
    }

    protected ConditionExpressionParser getConditionExpressionParser() {
        return conditionExpressionParser;
    }

    /**
     * @see FunctionExpressionBased#setFunctionExpressionParser(org.springmodules.validation.util.fel.FunctionExpressionParser)
     */
    public void setFunctionExpressionParser(FunctionExpressionParser functionExpressionParser) {
        this.functionExpressionParser = functionExpressionParser;
    }

    protected FunctionExpressionParser getFunctionExpressionParser() {
        return functionExpressionParser;
    }

    /**
     * Creates the validation rule represented and initialized by and with the given element.
     *
     * @param element The element that represents the validation rule.
     * @return The newly created validation rule.
     */
    protected abstract AbstractValidationRule createValidationRule(Element element);