CPD Results

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

Duplications

File Line
org\apache\maven\index\util\zip\JavaZipFileHandle.java 37
org\apache\maven\index\util\zip\TrueZipZipFileHandle.java 38
    public JavaZipFileHandle( final File targetFile )
        throws IOException
    {
        super( targetFile );

        this.zipFile = new ZipFile( targetFile );
    }

    protected ZipFile getZipFile()
    {
        return zipFile;
    }

    public boolean hasEntry( String path )
        throws IOException
    {
        return getZipFile().getEntry( path ) != null;
    }

    public List<String> getEntries()
    {
        return getEntries( new EntryNameFilter()
        {
            public boolean accepts( String entryName )
            {
                return true;
            }
        } );
    }

    public List<String> getEntries( EntryNameFilter filter )
    {
        ArrayList<String> entries = new ArrayList<String>();

        Enumeration<? extends ZipEntry> en = getZipFile().entries();

        while ( en.hasMoreElements() )
        {
            final ZipEntry e = en.nextElement();

            final String name = e.getName();

            if ( filter != null && !filter.accepts( name ) )
            {
                continue;
            }

            entries.add( name );
        }

        return entries;
    }

    public InputStream getEntryContent( String path )
        throws IOException
    {
        ZipEntry entry = getZipFile().getEntry( path );

        if ( entry != null )
        {
            return getZipFile().getInputStream( entry );
        }
        else
        {
            return null;
        }
    }

    public void close()
        throws IOException
    {
        getZipFile().close();
    }
}
File Line
org\apache\maven\index\DefaultSearchEngine.java 165
org\apache\maven\index\DefaultSearchEngine.java 220
                for ( int i = start; i < scoreDocs.length; i++ )
                {
                    Document doc = indexSearcher.doc( scoreDocs[i].doc );

                    ArtifactInfo artifactInfo = IndexUtils.constructArtifactInfo( doc, context );

                    if ( artifactInfo != null )
                    {
                        artifactInfo.setRepository( context.getRepositoryId() );
                        artifactInfo.setContext( context.getId() );

                        if ( req.getArtifactInfoFilter() != null )
                        {
                            if ( !req.getArtifactInfoFilter().accepts( context, artifactInfo ) )
                            {
                                continue;
                            }
                        }
                        if ( req.getArtifactInfoPostprocessor() != null )
                        {
                            req.getArtifactInfoPostprocessor().postprocess( context, artifactInfo );
                        }
File Line
org\apache\maven\index\artifact\M1ArtifactRecognizer.java 26
org\apache\maven\index\artifact\M2ArtifactRecognizer.java 26
{
    /**
     * Is this item M1 Checksum?
     */
    public static boolean isChecksum( String path )
    {
        return path.endsWith( ".sha1" ) || path.endsWith( ".md5" );
    }

    /**
     * Is this item M1 POM?
     */
    public static boolean isPom( String path )
    {
        return path.endsWith( ".pom" ) || path.endsWith( ".pom.sha1" ) || path.endsWith( ".pom.md5" );
    }

    /**
     * Is this item M1 snapshot?
     */
    public static boolean isSnapshot( String path )
    {
        return path.indexOf( "SNAPSHOT" ) != -1;
    }

    /**
     * Is this item M1 metadata? There is no such!
     */
    public static boolean isMetadata( String path )
    {
        return path.endsWith( "maven-metadata.xml" ) || path.endsWith( "maven-metadata.xml.sha1" )
            || path.endsWith( "maven-metadata.xml.md5" );
    }