CPD Results

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

Duplications

File Line
org/jomc/model/modlet/DefaultModelProcessor.java 462
org/jomc/model/modlet/DefaultModelProvider.java 601
        }
        catch ( final CancellationException e )
        {
            throw new ModelException( getMessage( e ), e );
        }
        catch ( final InterruptedException e )
        {
            throw new ModelException( getMessage( e ), e );
        }
        catch ( final ExecutionException e )
        {
            if ( e.getCause() instanceof ModelException )
            {
                throw (ModelException) e.getCause();
            }
            else if ( e.getCause() instanceof RuntimeException )
            {
                // The fork-join framework breaks the exception handling contract of Callable by re-throwing any
                // exception caught using a runtime exception.
                if ( e.getCause().getCause() instanceof ModelException )
                {
                    throw (ModelException) e.getCause().getCause();
                }
                else if ( e.getCause().getCause() instanceof RuntimeException )
                {
                    throw (RuntimeException) e.getCause().getCause();
                }
                else if ( e.getCause().getCause() instanceof Error )
                {
                    throw (Error) e.getCause().getCause();
                }
                else if ( e.getCause().getCause() instanceof Exception )
                {
                    // Checked exception not declared to be thrown by the Callable's 'call' method.
                    throw new UndeclaredThrowableException( e.getCause().getCause() );
                }
                else
                {
                    throw (RuntimeException) e.getCause();
                }
            }
            else if ( e.getCause() instanceof Error )
            {
                throw (Error) e.getCause();
            }
            else
            {
                // Checked exception not declared to be thrown by the Callable's 'call' method.
                throw new UndeclaredThrowableException( e.getCause() );
            }
        }
    }

    /**
     * {@inheritDoc}
     *
     * @see #isEnabled()
     * @see #getTransformerLocation()
     * @see #findTransformers(org.jomc.modlet.ModelContext, java.lang.String)
     * @see #ENABLED_ATTRIBUTE_NAME
     * @see #TRANSFORMER_LOCATION_ATTRIBUTE_NAME
     */
    public Model processModel( final ModelContext context, final Model model ) throws ModelException
File Line
org/jomc/model/modlet/DefaultModelProcessor.java 485
org/jomc/model/modlet/DefaultModelProvider.java 624
org/jomc/model/modlet/DefaultModelValidator.java 471
                else if ( e.getCause().getCause() instanceof RuntimeException )
                {
                    throw (RuntimeException) e.getCause().getCause();
                }
                else if ( e.getCause().getCause() instanceof Error )
                {
                    throw (Error) e.getCause().getCause();
                }
                else if ( e.getCause().getCause() instanceof Exception )
                {
                    // Checked exception not declared to be thrown by the Callable's 'call' method.
                    throw new UndeclaredThrowableException( e.getCause().getCause() );
                }
                else
                {
                    throw (RuntimeException) e.getCause();
                }
            }
            else if ( e.getCause() instanceof Error )
            {
                throw (Error) e.getCause();
            }
            else
            {
                // Checked exception not declared to be thrown by the Callable's 'call' method.
                throw new UndeclaredThrowableException( e.getCause() );
            }
        }
    }
File Line
org/jomc/model/modlet/DefaultModelValidator.java 1960
org/jomc/model/modlet/DefaultModelValidator.java 2109
                               m.getName(), overriddenImplementation.getIdentifier(), moduleOfMessage.getName(),
                               getNodePathString( overriddenMessage ) );

                }
            }

            retainFinalNodes( overriddenMessages );

            for ( final InheritanceModel.Node<Message> overriddenMessage : overriddenMessages )
            {
                Implementation overriddenImplementation = overriddenMessage.getImplementation();
                if ( overriddenMessage.getClassDeclaration() != null )
                {
                    overriddenImplementation = overriddenMessage.getClassDeclaration();
                }

                final Module moduleOfMessage = validationContext.getModuleOfImplementation(
                    overriddenImplementation.getIdentifier() );

                addDetail( validationContext.getReport(),
                           "IMPLEMENTATION_MESSAGE_INHERITANCE_CONSTRAINT",
                           Level.SEVERE, new ObjectFactory().createImplementation( impl ),
                           "implementationMessageFinalConstraint", impl.getIdentifier(),
                           validationContext.getModuleOfImplementation( impl.getIdentifier() ).getName(), m.getName(),
File Line
org/jomc/model/modlet/DefaultModelValidator.java 1892
org/jomc/model/modlet/DefaultModelValidator.java 3697
                               validationContext.getModuleOfImplementation( impl.getIdentifier() ).getName(),
                               m.getName(), t.getLanguage(),
                               message != null && message.length() > 0 ? " " + message : "" );

                }

                if ( validationContext.isValidateJava() )
                {
                    try
                    {
                        new MessageFormat( t.getValue(), new Locale( t.getLanguage() ) );
                    }
                    catch ( final IllegalArgumentException e )
                    {
                        final String message = getMessage( e );

                        if ( validationContext.getModelContext().isLoggable( Level.FINE ) )
                        {
                            validationContext.getModelContext().log( Level.FINE, message, e );
                        }

                        addDetail( validationContext.getReport(),
File Line
org/jomc/model/modlet/DefaultModelValidator.java 647
org/jomc/model/modlet/DefaultModelValidator.java 1893
org/jomc/model/modlet/DefaultModelValidator.java 3698
                                       "moduleMessageTemplateMimeTypeConstraint", m.getName(), msg.getName(),
                                       t.getLanguage(),
                                       message != null && message.length() > 0 ? " " + message : "" );

                        }

                        if ( validationContext.isValidateJava() )
                        {
                            try
                            {
                                new MessageFormat( t.getValue(), new Locale( t.getLanguage() ) );
                            }
                            catch ( final IllegalArgumentException e )
                            {
                                final String message = getMessage( e );

                                if ( validationContext.getModelContext().isLoggable( Level.FINE ) )
                                {
                                    validationContext.getModelContext().log( Level.FINE, message, e );
                                }

                                addDetail( validationContext.getReport(), "MODULE_MESSAGE_TEMPLATE_CONSTRAINT",
File Line
org/jomc/model/modlet/DefaultModelValidator.java 1943
org/jomc/model/modlet/DefaultModelValidator.java 2091
            if ( !( m.isOverride() || overriddenMessages.isEmpty() ) )
            {
                for ( final InheritanceModel.Node<Message> overriddenMessage : overriddenMessages )
                {
                    Implementation overriddenImplementation = overriddenMessage.getImplementation();
                    if ( overriddenMessage.getClassDeclaration() != null )
                    {
                        overriddenImplementation = overriddenMessage.getClassDeclaration();
                    }

                    final Module moduleOfMessage =
                        validationContext.getModuleOfImplementation( overriddenImplementation.getIdentifier() );

                    addDetail( validationContext.getReport(), "IMPLEMENTATION_MESSAGE_OVERRIDE_WARNING",
                               Level.WARNING, new ObjectFactory().createImplementation( impl ),
                               "implementationMessageOverrideWarning", impl.getIdentifier(),
                               validationContext.getModuleOfImplementation( impl.getIdentifier() ).getName(),
File Line
org/jomc/model/modlet/DefaultModelProcessor.java 165
org/jomc/model/modlet/DefaultModelProvider.java 198
    public DefaultModelProcessor()
    {
        super();
    }

    /**
     * Gets a flag indicating the processor is enabled by default.
     * <p>
     * The default enabled flag is controlled by system property
     * {@code org.jomc.model.modlet.DefaultModelProcessor.defaultEnabled} holding a value indicating the processor is
     * enabled by default. If that property is not set, the {@code true} default is returned.
     * </p>
     *
     * @return {@code true}, if the processor is enabled by default; {@code false}, if the processor is disabled by
     * default.
     *
     * @see #setDefaultEnabled(java.lang.Boolean)
     */
    public static boolean isDefaultEnabled()
    {
        if ( defaultEnabled == null )
        {
            defaultEnabled =
                Boolean.valueOf( System.getProperty( DEFAULT_ENABLED_PROPERTY_NAME,
                                                     System.getProperty( DEPRECATED_DEFAULT_ENABLED_PROPERTY_NAME,
                                                                         Boolean.toString( DEFAULT_ENABLED ) ) ) );

        }

        return defaultEnabled;
    }

    /**
     * Sets the flag indicating the processor is enabled by default.
     *
     * @param value The new value of the flag indicating the processor is enabled by default or {@code null}.
     *
     * @see #isDefaultEnabled()
     */
    public static void setDefaultEnabled( final Boolean value )
    {
        defaultEnabled = value;
    }

    /**
     * Gets a flag indicating the processor is enabled.
     *
     * @return {@code true}, if the processor is enabled; {@code false}, if the processor is disabled.
     *
     * @see #isDefaultEnabled()
     * @see #setEnabled(java.lang.Boolean)
     */
    public final boolean isEnabled()
    {
        if ( this.enabled == null )
        {
            this.enabled = isDefaultEnabled();
        }

        return this.enabled;
    }

    /**
     * Sets the flag indicating the processor is enabled.
     *
     * @param value The new value of the flag indicating the processor is enabled or {@code null}.
     *
     * @see #isEnabled()
     */
    public final void setEnabled( final Boolean value )
    {
        this.enabled = value;
    }

    /**
     * Gets the default location searched for transformer resources.
     * <p>
     * The default transformer location is controlled by system property
     * {@code org.jomc.model.modlet.DefaultModelProcessor.defaultTransformerLocation} holding the location to search for
     * transformer resources by default. If that property is not set, the {@code META-INF/jomc.xsl} default is
     * returned.
     * </p>
     *
     * @return The location searched for transformer resources by default.
     *
     * @see #setDefaultTransformerLocation(java.lang.String)
     */
    public static String getDefaultTransformerLocation()
File Line
org/jomc/model/modlet/DefaultModelValidator.java 2366
org/jomc/model/modlet/DefaultModelValidator.java 2438
                }
            }

            retainFinalNodes( overriddenProperties );

            for ( final InheritanceModel.Node<Property> overriddenProperty : overriddenProperties )
            {
                Implementation overriddenImplementation = overriddenProperty.getImplementation();
                if ( overriddenProperty.getClassDeclaration() != null )
                {
                    overriddenImplementation = overriddenProperty.getClassDeclaration();
                }

                final Module moduleOfProperty =
                    validationContext.getModuleOfImplementation(
                        overriddenImplementation.getIdentifier() );

                addDetail( validationContext.getReport(),
                           "IMPLEMENTATION_PROPERTY_INHERITANCE_CONSTRAINT",
                           Level.SEVERE, new ObjectFactory().createImplementation( impl ),
                           "implementationPropertyFinalConstraint", impl.getIdentifier(),
                           validationContext.getModuleOfImplementation( impl.getIdentifier() ).getName(), p.getName(),
File Line
org/jomc/model/modlet/DefaultModelValidator.java 903
org/jomc/model/modlet/DefaultModelValidator.java 2278
org/jomc/model/modlet/DefaultModelValidator.java 3385
org/jomc/model/modlet/DefaultModelValidator.java 3952
                                   "modulePropertyJavaVariableNameConstraint", m.getName(), p.getName(),
                                   message != null && message.length() > 0 ? " " + message : "" );

                    }

                    try
                    {
                        p.getJavaValue( validationContext.getModelContext().getClassLoader() );
                    }
                    catch ( final ModelObjectException e )
                    {
                        final String message = getMessage( e );

                        if ( validationContext.getModelContext().isLoggable( Level.FINE ) )
                        {
                            validationContext.getModelContext().log( Level.FINE, message, e );
                        }

                        addDetail( validationContext.getReport(), "MODULE_PROPERTY_JAVA_VALUE_CONSTRAINT",