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.java178
org\apache\maven\doxia\docrenderer\pdf\itext\ITextPdfRenderer.java195
        generatePdf( iTextFile, iTextOutput );
    }

    /** {@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 outputITextFile = new File( outputDirectory, output + ".xml" );
FileLine
org\apache\maven\doxia\docrenderer\pdf\fo\FoPdfRenderer.java287
org\apache\maven\doxia\docrenderer\pdf\itext\ITextPdfRenderer.java598
            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.java347
                .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,
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.lastIndexOf( '.') + 1 ) + "xml";
FileLine
org\apache\maven\doxia\docrenderer\pdf\fo\FoPdfRenderer.java70
org\apache\maven\doxia\docrenderer\pdf\itext\ITextPdfRenderer.java132
    }

    /** {@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 outputITextFile = new File( outputDirectory, outputName + ".xml" );