CPD Results

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

Duplications

FileLine
org/apache/maven/index/util/zip/JavaZipFileHandle.java37
org/apache/maven/index/util/zip/TrueZipZipFileHandle.java38
    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();
    }
}
FileLine
org/apache/maven/index/DefaultSearchEngine.java155
org/apache/maven/index/DefaultSearchEngine.java210
                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.repository = context.getRepositoryId();
                        artifactInfo.context = context.getId();

                        if ( req.getArtifactInfoFilter() != null )
                        {
                            if ( !req.getArtifactInfoFilter().accepts( context, artifactInfo ) )
                            {
                                continue;
                            }
                        }
                        if ( req.getArtifactInfoPostprocessor() != null )
                        {
                            req.getArtifactInfoPostprocessor().postprocess( context, artifactInfo );
                        }