CPD Results

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

Duplications

FileLine
org/apache/maven/doxia/docrenderer/pdf/fo/FoPdfRenderer.java180
org/apache/maven/doxia/docrenderer/pdf/itext/ITextPdfRenderer.java197
        generatePdf( outputFOFile, pdfOutputFile, documentModel );
    }

    /** {@inheritDoc} */
    @Override
    public void renderIndividual( Map<String, SiteModule> filesToProcess, File outputDirectory )
        throws DocumentRendererException, IOException
    {
        renderIndividual( filesToProcess, outputDirectory, null );
    }

    /** {@inheritDoc} */
    @Override
    public void renderIndividual( Map<String, SiteModule> filesToProcess, File outputDirectory,
                                  DocumentRendererContext context )
        throws DocumentRendererException, IOException
    {
        for ( Map.Entry<String, SiteModule> entry : filesToProcess.entrySet() )
        {
            String key = entry.getKey();
            SiteModule module = entry.getValue();

            File fullDoc = new File( getBaseDir(), module.getSourceDirectory() + File.separator + key );

            String output = key;
            String lowerCaseExtension = module.getExtension().toLowerCase( Locale.ENGLISH );
            if ( output.toLowerCase( Locale.ENGLISH ).indexOf( "." + lowerCaseExtension ) != -1 )
            {
                output =
                    output.substring( 0, output.toLowerCase( Locale.ENGLISH ).indexOf( "." + lowerCaseExtension ) );
            }

            File outputFOFile = new File( outputDirectory, output + ".fo" );
FileLine
org/apache/maven/doxia/docrenderer/pdf/fo/FoPdfRenderer.java289
org/apache/maven/doxia/docrenderer/pdf/itext/ITextPdfRenderer.java600
        Collection<SiteModule> modules = siteModuleManager.getSiteModules();
        for ( SiteModule module : modules )
        {
            File moduleBasedir = new File( getBaseDir(), module.getSourceDirectory() );

            if ( moduleBasedir.exists() )
            {
                String doc = href + "." + module.getExtension();
                File source = new File( moduleBasedir, doc );

                // Velocity file?
                if ( !source.exists() )
                {
                    if ( href.indexOf( "." + module.getExtension() ) != -1 )
                    {
                        doc = href + ".vm";
                    }
                    else
                    {
                        doc = href + "." + module.getExtension() + ".vm";
                    }
                    source = new File( moduleBasedir, doc );
                }

                if ( source.exists() )
                {
FileLine
org/apache/maven/doxia/docrenderer/itext/AbstractITextRender.java415
org/apache/maven/doxia/docrenderer/pdf/itext/ITextPdfRenderer.java349
                .getResourceAsStream( "/" + XSLT_RESOURCE ) ) );
            transformer.setErrorListener( TRANSFORMER_FACTORY.getErrorListener() );

            transformer.setOutputProperty( OutputKeys.OMIT_XML_DECLARATION, "false" );
            transformer.setOutputProperty( OutputKeys.INDENT, "yes" );
            transformer.setOutputProperty( OutputKeys.METHOD, "xml" );
            transformer.setOutputProperty( OutputKeys.ENCODING, "UTF-8" );

            return transformer;
        }
        catch ( TransformerConfigurationException e )
        {
            throw new DocumentRendererException( "Error configuring Transformer for " + XSLT_RESOURCE + ": "
                + e.getMessage() );
        }
        catch ( IllegalArgumentException e )
        {
            throw new DocumentRendererException( "Error configuring Transformer for " + XSLT_RESOURCE + ": "
                + e.getMessage() );
        }
    }

    /**
     * Add transformer parameters
     *
     * @param transformer
     * @param documentModel
     */
    private void addTransformerParameters( Transformer transformer, DocumentModel documentModel )
FileLine
org/apache/maven/doxia/docrenderer/itext/AbstractITextRender.java110
org/apache/maven/doxia/docrenderer/itext/AbstractITextRender.java198
        Collection<SiteModule> modules = siteModuleManager.getSiteModules();
        for ( SiteModule module : modules )
        {
            File moduleBasedir = new File( siteDirectory, module.getSourceDirectory() );

            if ( moduleBasedir.exists() )
            {
                @SuppressWarnings ( "unchecked" )
                List<String> docs =
                    FileUtils.getFileNames( moduleBasedir, "**/*." + module.getExtension(), null, false );

                for ( String doc : docs )
                {
                    String fullPathDoc = new File( moduleBasedir, doc ).getPath();

                    String outputITextName = doc.substring( 0, doc.indexOf( '.') + 1 ) + "xml";
FileLine
org/apache/maven/doxia/docrenderer/pdf/fo/FoPdfRenderer.java72
org/apache/maven/doxia/docrenderer/pdf/itext/ITextPdfRenderer.java134
    }

    /** {@inheritDoc} */
    @Override
    public void render( Map<String, SiteModule> filesToProcess, File outputDirectory, DocumentModel documentModel )
        throws DocumentRendererException, IOException
    {
        render( filesToProcess, outputDirectory, documentModel, null );
    }

    /** {@inheritDoc} */
    @Override
    public void render( Map<String, SiteModule> filesToProcess, File outputDirectory, DocumentModel documentModel,
                        DocumentRendererContext context )
        throws DocumentRendererException, IOException
    {
        // copy resources, images, etc.
        copyResources( outputDirectory );

        if ( documentModel == null )
        {
            getLogger().debug( "No document model, generating all documents individually." );

            renderIndividual( filesToProcess, outputDirectory, context );
            return;
        }

        String outputName = getOutputName( documentModel );

        File outputFOFile = new File( outputDirectory, outputName + ".fo" );