CPD Results

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

Duplications

FileLine
org/apache/geronimo/system/configuration/condition/OgnlConditionParser.java47
org/apache/geronimo/system/configuration/condition/JexlConditionParser.java49
    public JexlConditionParser() {
        // Setup the default vars
        vars = new HashMap();

        vars.put("props", Collections.unmodifiableMap(System.getProperties()));
        vars.put("java", new JavaVariable());
        vars.put("os", new OsVariable());
    }

    /**
     * Evaluate a condition expression.
     *
     * @param expression    The condition expression to evaluate; must not be null
     * @return              True if the condition is satisfied
     *
     * @throws org.apache.geronimo.system.configuration.condition.ConditionParserException     Failed to evaluate condition expression
     */
    public boolean evaluate(final String expression) throws ConditionParserException {
        if (expression == null) {
            throw new IllegalArgumentException("Expression must not be null");
        }

        // Empty expressions are true
        if (expression.trim().length() == 0) {
            log.debug("Expression is empty; skipping evaluation");

            return true;
        }

        Object result;
        try {
            result = doEvaluate(expression);
        }
        catch (Exception e) {
            throw new ConditionParserException("Failed to evaluate expression: " + expression, e);
        }

        if (result instanceof Boolean) {
            return ((Boolean)result).booleanValue();
        }
        else {
            throw new ConditionParserException("Expression '" + expression + "' did not evaluate to a boolean value; found: " + result);
        }
    }

    private Object doEvaluate(final String expression) throws Exception {
        assert expression != null;

        boolean debug = log.isDebugEnabled();

        if (debug) {
            log.debug("Evaluating expression: " + expression);
        }

FileLine
org/apache/geronimo/system/repository/Maven2Repository.java133
org/apache/geronimo/system/repository/Maven2Repository.java168
                } else if (groupId != null) {
                    String version = versionDir.getName();
                    String fileHeader = artifactId + "-" + version + ".";

                    String fileName = file.getName();
                    if (fileName.startsWith(fileHeader)) {
                        // type is everything after the file header
                        String type = fileName.substring(fileHeader.length());

                        if (!type.endsWith(".sha1") && !type.endsWith(".md5")) {
                            if(artifactMatch != null && !artifactMatch.equals(artifactId)) {
                                continue;
                            }
                            if(typeMatch != null && !typeMatch.equals(type)) {
                                continue;
                            }
                            if(versionMatch != null && !versionMatch.equals(version)) {
                                continue;
                            }
                            artifacts.add(new Artifact(groupId,
                                    artifactId,
                                    version,
                                    type
                            ));
                        }
                    }
                }

FileLine
org/apache/geronimo/system/configuration/XMLSerializer.java348
org/apache/geronimo/system/configuration/XMLSerializer.java550
        tagName = elem.getTagName();
        state = getElementState();
        if ( isDocumentState() ) {
            // If this is the root element handle it differently.
            // If the first root element in the document, serialize
            // the document's DOCTYPE. Space preserving defaults
            // to that of the output format.
            if ( ! started )
                startDocument( tagName );
        } else {
            // For any other element, if first in parent, then
            // close parent's opening tag and use the parnet's
            // space preserving.
            if ( state.empty )
                printer.printText( '>' );
            // Must leave CData section first
            if ( state.inCData )
            {
                printer.printText( "]]>" );
                state.inCData = false;
            }
            // Indent this element on a new line if the first
            // content of the parent element or immediately
            // following an element.
            if ( indenting && ! state.preserveSpace &&
                 ( state.empty || state.afterElement || state.afterComment) )
                printer.breakLine();
        }
        preserveSpace = state.preserveSpace;

        // Do not change the current element state yet.
        // This only happens in endElement().

        printer.printText( '<' );
        printer.printText( tagName );
        printer.indent();

FileLine
org/apache/geronimo/system/repository/UnpackArtifactTypeHandler.java35
org/apache/geronimo/system/repository/CopyArtifactTypeHandler.java33
public class CopyArtifactTypeHandler implements ArtifactTypeHandler {
    private final static int TRANSFER_NOTIFICATION_SIZE = 10240;  // announce every this many bytes
    private final static int TRANSFER_BUF_SIZE = 10240;  // try this many bytes at a time

    public void install(InputStream source, int size, Artifact artifact, FileWriteMonitor monitor, File target) throws IOException {
        // assure that the target directory exists
        File parent = target.getParentFile();
        if (!parent.exists() && !parent.mkdirs()) {
            throw new RuntimeException("Unable to create directory " + parent.getAbsolutePath());
        }

        // copy it
        if (monitor != null) {
            monitor.writeStarted(artifact.toString(), size);
        }
        int total = 0;