CPD Results

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

Duplications

FileLine
org\apache\maven\doxia\docrenderer\pdf\fo\FoPdfRenderer.java176
org\apache\maven\doxia\docrenderer\pdf\itext\ITextPdfRenderer.java193
        generatePdf( iTextFile, iTextOutput );
    }

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

    /** {@inheritDoc} */
    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 outputITextFile = new File( outputDirectory, output + ".xml" );
FileLine
org\apache\maven\doxia\docrenderer\pdf\fo\FoPdfRenderer.java283
org\apache\maven\doxia\docrenderer\pdf\itext\ITextPdfRenderer.java594
            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.java413
org\apache\maven\doxia\docrenderer\pdf\itext\ITextPdfRenderer.java343
                .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" );

            // No doctype since itext doctype is not up to date!

            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 from a DocumentModel.
     *
     * @param transformer the Transformer to set the parameters.
     * @param documentModel the DocumentModel to take the parameters from, could be null.
     * @param iTextFile the iTextFile not null for the relative paths.
     * @param generateTOC not null, possible values are: 'none', 'start' and 'end'.
     */
    private void addTransformerParameters( Transformer transformer, DocumentModel documentModel, File iTextFile,