CPD Results

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

Duplications

File Line
org/deegree/commons/index/RTree.java 351
org/deegree/commons/index/RTree.java 421
                NodeEntry<T>[] node = new NodeEntry[bigM + 1];
                float[] bbox = null;
                for ( int i = 0; i < bigM; ++i, ++idx ) {
                    if ( idx < slice.size() ) {
                        if ( list.isEmpty() ) {
                            list = iter.next();
                        }
                        Pair<float[], ?> p = list.poll();
                        node[i] = new NodeEntry<T>();
                        node[i].bbox = p.first;
                        if ( p.second instanceof NodeEntry<?>[] ) {
                            node[i].next = (NodeEntry<T>[]) p.second;
                        } else {
                            node[i].entryValue = (T) p.second;
                        }
                        if ( bbox == null ) {
                            bbox = new float[] { p.first[0], p.first[1], p.first[2], p.first[3] };
                        } else {
                            for ( int k = 0; k < 2; ++k ) {
                                if ( bbox[k] > p.first[k] ) {
                                    bbox[k] = p.first[k];
                                }
                            }
                            for ( int k = 2; k < 4; ++k ) {
                                if ( bbox[k] < p.first[k] ) {
                                    bbox[k] = p.first[k];
                                }
                            }
                        }
                    }
                }
                newRects.add( new Pair<float[], NodeEntry<T>[]>( bbox, node ) );
            }
        }

        return buildFromFloat( (List) newRects );
    }

    /**
     * RB: this method is a duplicate from buildTree, but used only with float arrays. (Sorry no time to refactor
     * buildtree).
     * 
     * @param rects
     */
    @SuppressWarnings("unchecked")
File Line
org/deegree/commons/mail/MailHelper.java 172
org/deegree/commons/mail/MailHelper.java 234
    public void createAndSendMail( MailMessage eMess, Session session, Object[] attachment, String[] mimeType )
                            throws SendMailException {
        if ( eMess == null || !eMess.isValid() ) {
            throw new SendMailException( "Not a valid e-mail!" );
        }
        try {
            int k = eMess.getMessageBody().length() > 60 ? 60 : eMess.getMessageBody().length() - 1;
            LOG.debug( "Sending message, From: " + eMess.getSender() + "\nTo: " + eMess.getReceiver() + "\nSubject: "
                       + eMess.getSubject() + "\nContents: " + eMess.getMessageBody().substring( 0, k ) + "..." );
            // construct the message
            MimeMessage msg = new MimeMessage( session );
            msg.setFrom( new InternetAddress( eMess.getSender() ) );
            msg.setRecipients( Message.RecipientType.TO, InternetAddress.parse( eMess.getReceiver(), false ) );
            msg.setSubject( eMess.getSubject(), Charset.defaultCharset().name() );
            msg.setHeader( "X-Mailer", "JavaMail" );
            msg.setSentDate( new Date() );

            // create and fill the first message part
            List<MimeBodyPart> mbps = new ArrayList<MimeBodyPart>();
            MimeBodyPart mbp = new MimeBodyPart();
            mbp.setContent( eMess.getMessageBody(), eMess.getMimeType() );
            mbps.add( mbp );
            if ( attachment != null ) {
File Line
org/deegree/commons/utils/net/HttpUtils.java 304
org/deegree/commons/utils/net/HttpUtils.java 347
    public static <T> T post( Worker<T> worker, String url, Map<String, String> params, Map<String, String> headers,
                              final int readTimeout )
                            throws IOException {
        DURL u = new DURL( url );
        LOG.debug( "Sending HTTP POST against {}", url );
        DefaultHttpClient client = enableProxyUsage( new DefaultHttpClient(), u );
        client.setKeepAliveStrategy( new DefaultConnectionKeepAliveStrategy() {
            @Override
            public long getKeepAliveDuration( HttpResponse response, HttpContext context ) {
                long keepAlive = super.getKeepAliveDuration( response, context );
                if ( keepAlive == -1 ) {
                    keepAlive = readTimeout * 1000;
                }
                return keepAlive;
            }
        } );
        HttpPost post = new HttpPost( url );
        List<BasicNameValuePair> list = new ArrayList<BasicNameValuePair>( params.size() );
        for ( Entry<String, String> e : params.entrySet() ) {
            list.add( new BasicNameValuePair( e.getKey(), e.getValue() ) );
        }

        post.setEntity( new UrlEncodedFormEntity( list, "UTF-8" ) );
        if ( headers != null ) {
            for ( String key : headers.keySet() ) {
                post.addHeader( key, headers.get( key ) );
            }
        }
File Line
org/deegree/commons/utils/math/Vectors3d.java 182
org/deegree/commons/utils/math/Vectors3f.java 214
    public final static void normal( double[] a, int ia, int ib, int ic, double[] result ) {

        // v[0] = a[ia] - a[ib];
        // v[1] = a[ia + 1] - a[ib + 1];
        // v[2] = a[ia + 2] - a[ib + 2];
        //
        // w[0] = a[ia] - a[ic];
        // w[1] = a[ia + 1] - a[ic + 1];
        // w[2] = a[ia + 2] - a[ic + 2];

        // result[0] = v[1] * w[2] - w[1] * v[2];
        // result[1] = v[2] * w[0] - w[2] * v[0];
        // result[2] = v[0] * w[1] - w[0] * v[1];

        result[0] = ( ( a[ia + 1] - a[ib + 1] ) * ( a[ia + 2] - a[ic + 2] ) )
                    - ( ( a[ia + 1] - a[ic + 1] ) * ( a[ia + 2] - a[ib + 2] ) );
        result[1] = ( ( a[ia + 2] - a[ib + 2] ) * ( a[ia] - a[ic] ) )
                    - ( ( a[ia + 2] - a[ic + 2] ) * ( a[ia] - a[ib] ) );
        result[2] = ( ( a[ia] - a[ib] ) * ( a[ia + 1] - a[ic + 1] ) )
                    - ( ( a[ia] - a[ic] ) * ( a[ia + 1] - a[ib + 1] ) );

    }

    /**
     * Calculate the normal vector for vectors starting at index by using the vectors a=(index, index+1, index+2),
     * b=(index+3, index+4, index+5) and c=(index+6, index+7, index+8) by calculating the cross product from ab x ac and
     * store the result in given array with length 3.
     * 
     * @param a
     *            an array containing the ordinates of the vectors with length > index + 9
     * @param index
     *            index of the first vector
     * @param result
     *            array with length 3
     * @throws IndexOutOfBoundsException
     *             if a.length < index +9
     */
    public final static void normal( double[] a, int index, double[] result ) {
File Line
org/deegree/commons/xml/schema/SchemaValidator.java 162
org/deegree/commons/xml/schema/SchemaValidator.java 257
            parserConfig.setErrorHandler( new XMLErrorHandler() {
                @SuppressWarnings("synthetic-access")
                @Override
                public void error( String domain, String key, XMLParseException e )
                                        throws XNIException {
                    LOG.debug( "Encountered error: " + toString( e ) );
                    errors.add( "Error: " + toString( e ) );
                }

                @SuppressWarnings("synthetic-access")
                @Override
                public void fatalError( String domain, String key, XMLParseException e )
                                        throws XNIException {
                    LOG.debug( "Encountered fatal error: " + toString( e ) );
                    errors.add( "Fatal error: " + toString( e ) );
                }

                @SuppressWarnings("synthetic-access")
                @Override
                public void warning( String domain, String key, XMLParseException e )
                                        throws XNIException {
                    LOG.debug( "Encountered warning: " + toString( e ) );
                    errors.add( "Warning: " + toString( e ) );
                }

                private String toString( XMLParseException e ) {
                    String s = e.getLocalizedMessage();
                    s += " (line: " + e.getLineNumber() + ", column: " + e.getColumnNumber();
                    s += e.getExpandedSystemId() != null ? ", SystemID: '" + e.getExpandedSystemId() + "')" : ")";
                    return s;
                }
            } );
File Line
org/deegree/commons/xml/stax/CoalescingXMLStreamWriter.java 70
org/deegree/commons/xml/stax/TrimmingXMLStreamWriter.java 65
        writer.flush();
    }

    public NamespaceContext getNamespaceContext() {
        return writer.getNamespaceContext();
    }

    public String getPrefix( String uri )
                            throws XMLStreamException {
        return writer.getPrefix( uri );
    }

    public Object getProperty( String name )
                            throws IllegalArgumentException {
        return writer.getProperty( name );
    }

    public void setDefaultNamespace( String uri )
                            throws XMLStreamException {
        writer.setDefaultNamespace( uri );
    }

    public void setNamespaceContext( NamespaceContext context )
                            throws XMLStreamException {
        writer.setNamespaceContext( context );
    }

    public void setPrefix( String prefix, String uri )
                            throws XMLStreamException {
        writer.setPrefix( prefix, uri );
    }

    public void writeAttribute( String prefix, String namespaceURI, String localName, String value )
                            throws XMLStreamException {
        writer.writeAttribute( prefix, namespaceURI, localName, value );
    }

    public void writeAttribute( String namespaceURI, String localName, String value )
                            throws XMLStreamException {
        writer.writeAttribute( namespaceURI, localName, value );
    }

    public void writeAttribute( String localName, String value )
                            throws XMLStreamException {
        writer.writeAttribute( localName, value );
    }

    public void writeCData( String data )
                            throws XMLStreamException {
File Line
org/deegree/commons/index/RTree.java 341
org/deegree/commons/index/RTree.java 411
        LinkedList<LinkedList<Pair<float[], ?>>> slices = slice( sortEnvelopes( rects, 0 ), bigM * bigM );
        ArrayList<Pair<float[], NodeEntry<T>[]>> newRects = new ArrayList<Pair<float[], NodeEntry<T>[]>>();

        for ( LinkedList<Pair<float[], ?>> slice : slices ) {
            TreeMap<Float, LinkedList<Pair<float[], ?>>> map = sort( slice, 1 );

            Iterator<LinkedList<Pair<float[], ?>>> iter = map.values().iterator();
            LinkedList<Pair<float[], ?>> list = iter.next();
            int idx = 0;
            while ( idx < slice.size() ) {
                NodeEntry<T>[] node = new NodeEntry[bigM + 1];
File Line
org/deegree/commons/jdbc/InsertRow.java 140
org/deegree/commons/jdbc/UpdateRow.java 114
            int columnId = 1;
            for ( Entry<SQLIdentifier, Object> entry : columnToObject.entrySet() ) {
                if ( entry.getValue() != null ) {
                    LOG.debug( "- Argument " + entry.getKey() + " = " + entry.getValue() + " ("
                               + entry.getValue().getClass() + ")" );
                    if ( entry.getValue() instanceof ParticleConversion<?> ) {
                        ParticleConversion<?> conversion = (ParticleConversion<?>) entry.getValue();
                        conversion.setParticle( stmt, columnId++ );
                    } else {
                        stmt.setObject( columnId++, entry.getValue() );
                    }
                } else {
                    LOG.debug( "- Argument " + entry.getKey() + " = NULL" );
                    stmt.setObject( columnId++, null );
                }
            }
            stmt.execute();
File Line
org/deegree/commons/xml/stax/SchemaLocationXMLStreamWriter.java 73
org/deegree/commons/xml/stax/TrimmingXMLStreamWriter.java 56
    }

    public void close()
                            throws XMLStreamException {
        writer.close();
    }

    public void flush()
                            throws XMLStreamException {
        writer.flush();
    }

    public NamespaceContext getNamespaceContext() {
        return writer.getNamespaceContext();
    }

    public String getPrefix( String uri )
                            throws XMLStreamException {
        return writer.getPrefix( uri );
    }

    public Object getProperty( String name )
                            throws IllegalArgumentException {
        return writer.getProperty( name );
    }

    public void setDefaultNamespace( String uri )
                            throws XMLStreamException {
        writer.setDefaultNamespace( uri );
    }

    public void setNamespaceContext( NamespaceContext context )
                            throws XMLStreamException {
        writer.setNamespaceContext( context );
    }

    public void setPrefix( String prefix, String uri )
                            throws XMLStreamException {
        writer.setPrefix( prefix, uri );
    }

    public void writeAttribute( String localName, String value )
File Line
org/deegree/commons/jdbc/InsertRow.java 91
org/deegree/commons/jdbc/InsertRow.java 181
    public String getSql() {
        StringBuilder sql = new StringBuilder( "INSERT INTO " + table + "(" );
        boolean first = true;
        for ( SQLIdentifier column : columnToLiteral.keySet() ) {
            if ( !first ) {
                sql.append( ',' );
            } else {
                first = false;
            }
            sql.append( column );
        }
        sql.append( ") VALUES(" );
        first = true;
        for ( Entry<SQLIdentifier, String> entry : columnToLiteral.entrySet() ) {
            if ( !first ) {
                sql.append( ',' );
            } else {
                first = false;
            }
            sql.append( entry.getValue() );
        }
        sql.append( ")" );
        return sql.toString();
    }
File Line
org/deegree/commons/concurrent/Executor.java 185
org/deegree/commons/concurrent/Executor.java 228
        List<Future<T>> futures = this.execService.invokeAll( tasks );

        for ( int i = 0; i < tasks.size(); i++ ) {

            ExecutionFinishedEvent<T> finishedEvent = null;
            Callable<T> task = tasks.get( i );
            Future<T> future = futures.get( i );

            try {
                T result = future.get();
                finishedEvent = new ExecutionFinishedEvent<T>( task, result );
            } catch ( ExecutionException e ) {
                finishedEvent = new ExecutionFinishedEvent<T>( e.getCause(), task );
            } catch ( CancellationException e ) {
                finishedEvent = new ExecutionFinishedEvent<T>( e, task );
            }
            results.add( finishedEvent );
        }
        return results;
    }
File Line
org/deegree/commons/xml/stax/XMLStreamReaderWrapper.java 173
org/deegree/commons/xml/stax/XMLStreamReaderWrapper.java 315
            int colonIdx = s.indexOf( ':' );
            if ( colonIdx < 0 ) {
                result = new QName( s );
            } else if ( colonIdx == s.length() - 1 ) {
                throw new XMLParsingException( this, "Invalid QName '" + s + "': no local name." );
            } else {
                String prefix = s.substring( 0, colonIdx );
                String localPart = s.substring( colonIdx + 1 );
                String nsUri = getNamespaceURI( prefix );
                if ( nsUri == null ) {
                    throw new XMLParsingException( this, "Invalid QName '" + s + "': prefix '" + prefix
                                                         + "' is unbound." );
                }
                result = new QName( nsUri, localPart, prefix );
            }
File Line
org/deegree/commons/xml/stax/CoalescingXMLStreamWriter.java 70
org/deegree/commons/xml/stax/SchemaLocationXMLStreamWriter.java 82
        writer.flush();
    }

    public NamespaceContext getNamespaceContext() {
        return writer.getNamespaceContext();
    }

    public String getPrefix( String uri )
                            throws XMLStreamException {
        return writer.getPrefix( uri );
    }

    public Object getProperty( String name )
                            throws IllegalArgumentException {
        return writer.getProperty( name );
    }

    public void setDefaultNamespace( String uri )
                            throws XMLStreamException {
        writer.setDefaultNamespace( uri );
    }

    public void setNamespaceContext( NamespaceContext context )
                            throws XMLStreamException {
        writer.setNamespaceContext( context );
    }

    public void setPrefix( String prefix, String uri )
                            throws XMLStreamException {
        writer.setPrefix( prefix, uri );
    }

    public void writeAttribute( String prefix, String namespaceURI, String localName, String value )
File Line
org/deegree/commons/mail/MailHelper.java 201
org/deegree/commons/mail/MailHelper.java 263
                    mbp.setFileName( "file" + i );
                    mbps.add( mbp );
                }
            }
            // create the Multipart and add its parts to it
            Multipart mp = new MimeMultipart();
            for ( int i = 0; i < mbps.size(); i++ ) {
                mp.addBodyPart( mbps.get( i ) );
            }
            msg.setContent( mp );
            // send the mail off
            Transport.send( msg );
            LOG.debug( "Mail sent successfully! Header=" + eMess.getHeader() );
        } catch ( Exception e ) {
            LOG.error( e.getMessage(), e );
            String s = Messages.getMessage( "MAIL_SEND_ERROR", eMess.getHeader() );
            throw new SendMailException( s, e );
        }
    }
File Line
org/deegree/commons/xml/stax/CoalescingXMLStreamWriter.java 191
org/deegree/commons/xml/stax/TrimmingXMLStreamWriter.java 170
        writer.writeEntityRef( name );
    }

    public void writeNamespace( String prefix, String namespaceURI )
                            throws XMLStreamException {
        writer.writeNamespace( prefix, namespaceURI );
    }

    public void writeProcessingInstruction( String target, String data )
                            throws XMLStreamException {
        writer.writeProcessingInstruction( target, data );
    }

    public void writeProcessingInstruction( String target )
                            throws XMLStreamException {
        writer.writeProcessingInstruction( target );
    }

    public void writeStartDocument()
                            throws XMLStreamException {
        writer.writeStartDocument();
    }

    public void writeStartDocument( String encoding, String version )
                            throws XMLStreamException {
        writer.writeStartDocument( encoding, version );
    }
File Line
org/deegree/commons/utils/net/HttpUtils.java 502
org/deegree/commons/utils/net/HttpUtils.java 586
        DefaultHttpClient client = enableProxyUsage( new DefaultHttpClient(), u );
        if ( user != null && pass != null ) {
            authenticate( client, user, pass, u );
        }
        HttpGet get = new HttpGet( url );
        if ( headers != null ) {
            for ( String key : headers.keySet() ) {
                get.addHeader( key, headers.get( key ) );
            }
        }
        HttpResponse response = client.execute( get );
        return new Pair<T, HttpResponse>( worker.work( response.getEntity().getContent() ), response );
    }

    public static void handleProxies( String protocol, DefaultHttpClient client, String host ) {
File Line
org/deegree/commons/xml/XMLAdapter.java 898
org/deegree/commons/xml/XMLAdapter.java 1001
            if ( node instanceof OMText ) {
                value = ( (OMText) node ).getTextAsQName();
            } else if ( node instanceof OMElement ) {
                OMElement element = (OMElement) node;
                value = element.resolveQName( element.getText() );
            } else if ( node instanceof OMAttribute ) {
                OMAttribute attribute = (OMAttribute) node;
                value = attribute.getOwner().resolveQName( attribute.getAttributeValue() );
            } else {
                String msg = "Unexpected node type '" + node.getClass() + "'.";
                throw new XMLParsingException( this, context, msg );