CPD Results
The following document contains the results of PMD's CPD 5.0.2.
Duplications
File | Line |
---|
org/jomc/tools/ClassFileProcessor.java | 2600 |
org/jomc/tools/ResourceFileProcessor.java | 550 |
randomAccessFile = new RandomAccessFile( classFile, "rw" );
fileChannel = randomAccessFile.getChannel();
fileLock = fileChannel.lock();
fileChannel.truncate( bytes.length );
fileChannel.position( 0L );
fileChannel.write( ByteBuffer.wrap( bytes ) );
fileChannel.force( true );
suppressExceptionOnClose = false;
}
finally
{
this.releaseAndClose( fileLock, fileChannel, randomAccessFile, suppressExceptionOnClose );
}
}
private void releaseAndClose( final FileLock fileLock, final FileChannel fileChannel,
final Closeable closeable, final boolean suppressExceptions )
throws IOException
{
try
{
if ( fileLock != null )
{
fileLock.release();
}
}
catch ( final IOException e )
{
if ( suppressExceptions )
{
this.log( Level.SEVERE, null, e );
}
else
{
throw e;
}
}
finally
{
try
{
if ( fileChannel != null )
{
fileChannel.close();
}
}
catch ( final IOException e )
{
if ( suppressExceptions )
{
this.log( Level.SEVERE, null, e );
}
else
{
throw e;
}
}
finally
{
try
{
if ( closeable != null )
{
closeable.close();
}
}
catch ( final IOException e )
{
if ( suppressExceptions )
{
this.log( Level.SEVERE, null, e );
}
else
{
throw e;
}
}
}
}
}
private static String getMessage( final String key, final Object... arguments )
{ |
File | Line |
---|
org/jomc/tools/modlet/ToolsModelProcessor.java | 127 |
org/jomc/tools/modlet/ToolsModelProvider.java | 139 |
public ToolsModelProcessor()
{
super();
}
/**
* Gets a flag indicating the processor is enabled by default.
* <p>The default enabled flag is controlled by system property
* {@code org.jomc.tools.modlet.ToolsModelProcessor.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,
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 a flag indicating model object class path resolution is enabled by default.
* <p>The model object class path resolution default enabled flag is controlled by system property
* {@code org.jomc.tools.modlet.ToolsModelProcessor.defaultModelObjectClasspathResolutionEnabled} holding a value
* indicating model object class path resolution is enabled by default. If that property is not set, the
* {@code true} default is returned.</p>
*
* @return {@code true}, if model object class path resolution is enabled by default; {@code false}, if model object
* class path resolution is disabled by default.
*
* @see #setDefaultModelObjectClasspathResolutionEnabled(java.lang.Boolean)
*/
public static boolean isDefaultModelObjectClasspathResolutionEnabled()
{
if ( defaultModelObjectClasspathResolutionEnabled == null )
{
defaultModelObjectClasspathResolutionEnabled = Boolean.valueOf( System.getProperty(
DEFAULT_MODEL_OBJECT_CLASSPATH_RESOLUTION_ENABLED_PROPERTY_NAME,
Boolean.toString( DEFAULT_MODEL_OBJECT_CLASSPATH_RESOLUTION_ENABLED ) ) );
}
return defaultModelObjectClasspathResolutionEnabled;
}
/**
* Sets the flag indicating model object class path resolution is enabled by default.
*
* @param value The new value of the flag indicating model object class path resolution is enabled by default or
* {@code null}.
*
* @see #isDefaultModelObjectClasspathResolutionEnabled()
*/
public static void setDefaultModelObjectClasspathResolutionEnabled( final Boolean value )
{
defaultModelObjectClasspathResolutionEnabled = value;
}
/**
* Gets a flag indicating model object class path resolution is enabled.
*
* @return {@code true}, if model object class path resolution is enabled; {@code false}, if model object class path
* resolution is disabled.
*
* @see #isDefaultModelObjectClasspathResolutionEnabled()
* @see #setModelObjectClasspathResolutionEnabled(java.lang.Boolean)
*/
public final boolean isModelObjectClasspathResolutionEnabled()
{
if ( this.modelObjectClasspathResolutionEnabled == null )
{
this.modelObjectClasspathResolutionEnabled = isDefaultModelObjectClasspathResolutionEnabled();
}
return this.modelObjectClasspathResolutionEnabled;
}
/**
* Sets the flag indicating model object class path resolution is is enabled.
*
* @param value The new value of the flag indicating model object class path resolution is enabled or {@code null}.
*
* @see #isModelObjectClasspathResolutionEnabled()
*/
public final void setModelObjectClasspathResolutionEnabled( final Boolean value )
{
this.modelObjectClasspathResolutionEnabled = value;
}
/**
* {@inheritDoc}
*
* @see #isEnabled()
* @see #isModelObjectClasspathResolutionEnabled()
* @see #ENABLED_ATTRIBUTE_NAME
* @see #MODEL_OBJECT_CLASSPATH_RESOLUTION_ENABLED_ATTRIBUTE_NAME
*/
public Model processModel( final ModelContext context, final Model model ) throws ModelException |
File | Line |
---|
org/jomc/tools/ClassFileProcessor.java | 2145 |
org/jomc/tools/ClassFileProcessor.java | 2177 |
final String classLocation = specification.getClazz().replace( '.', File.separatorChar ) + ".class";
final File classFile = new File( classesDirectory, classLocation );
if ( !classesDirectory.isDirectory() )
{
throw new IOException( getMessage( "directoryNotFound", classesDirectory.getAbsolutePath() ) );
}
if ( !classFile.isFile() )
{
throw new IOException( getMessage( "fileNotFound", classFile.getAbsolutePath() ) );
}
if ( !( classFile.canRead() && classFile.canWrite() ) )
{
throw new IOException( getMessage( "fileAccessDenied", classFile.getAbsolutePath() ) );
}
if ( this.isLoggable( Level.INFO ) )
{
this.log( Level.INFO, getMessage( "committing", classFile.getAbsolutePath() ), null );
}
final JavaClass javaClass = this.readJavaClass( classFile );
this.commitModelObjects( specification, marshaller, javaClass ); |
File | Line |
---|
org/jomc/tools/ClassFileProcessor.java | 2244 |
org/jomc/tools/ClassFileProcessor.java | 2283 |
final String classLocation = specification.getClazz().replace( '.', File.separatorChar ) + ".class";
final File classFile = new File( classesDirectory, classLocation );
if ( !classesDirectory.isDirectory() )
{
throw new IOException( getMessage( "directoryNotFound", classesDirectory.getAbsolutePath() ) );
}
if ( !classFile.isFile() )
{
throw new IOException( getMessage( "fileNotFound", classFile.getAbsolutePath() ) );
}
if ( !classFile.canRead() )
{
throw new IOException( getMessage( "fileAccessDenied", classFile.getAbsolutePath() ) );
}
if ( this.isLoggable( Level.INFO ) )
{
this.log( Level.INFO, getMessage( "validating", classFile.getAbsolutePath() ), null );
}
final JavaClass javaClass = this.readJavaClass( classFile );
report.getDetails().addAll(
this.validateModelObjects( specification, unmarshaller, javaClass ).getDetails() ); |
File | Line |
---|
org/jomc/tools/ClassFileProcessor.java | 2502 |
org/jomc/tools/ClassFileProcessor.java | 2535 |
final String classLocation = specification.getClazz().replace( '.', File.separatorChar ) + ".class";
final File classFile = new File( classesDirectory, classLocation );
if ( !classesDirectory.isDirectory() )
{
throw new IOException( getMessage( "directoryNotFound", classesDirectory.getAbsolutePath() ) );
}
if ( !classFile.isFile() )
{
throw new IOException( getMessage( "fileNotFound", classFile.getAbsolutePath() ) );
}
if ( !( classFile.canRead() && classFile.canWrite() ) )
{
throw new IOException( getMessage( "fileAccessDenied", classFile.getAbsolutePath() ) );
}
if ( this.isLoggable( Level.INFO ) )
{
this.log( Level.INFO, getMessage( "transforming", classFile.getAbsolutePath() ), null );
}
final JavaClass javaClass = this.readJavaClass( classFile );
this.transformModelObjects( specification, marshaller, unmarshaller, javaClass, transformers ); |
File | Line |
---|
org/jomc/tools/modlet/ToolsModelProcessor.java | 305 |
org/jomc/tools/modlet/ToolsModelProvider.java | 317 |
final Modules modules = ModelHelper.getModules( processed );
if ( modules != null )
{
Module classpathModule = null;
if ( contextModelObjectClasspathResolutionEnabled )
{
classpathModule = modules.getClasspathModule( Modules.getDefaultClasspathModuleName(),
context.getClassLoader() );
if ( classpathModule != null
&& modules.getModule( Modules.getDefaultClasspathModuleName() ) == null )
{
modules.getModule().add( classpathModule );
}
else
{
classpathModule = null;
}
}
if ( modules.getSpecifications() != null )
{
for ( int i = 0, s0 = modules.getSpecifications().getSpecification().size(); i < s0; i++ )
{
final Specification specification = modules.getSpecifications().getSpecification().get( i );
final SourceFileType sourceFileType = specification.getAnyObject( SourceFileType.class );
final SourceFilesType sourceFilesType = specification.getAnyObject( SourceFilesType.class );
if ( sourceFileType != null ) |
File | Line |
---|
org/jomc/tools/ClassFileProcessor.java | 2141 |
org/jomc/tools/ClassFileProcessor.java | 2498 |
final File classesDirectory ) throws IOException
{
if ( specification.isClassDeclaration() )
{
final String classLocation = specification.getClazz().replace( '.', File.separatorChar ) + ".class";
final File classFile = new File( classesDirectory, classLocation );
if ( !classesDirectory.isDirectory() )
{
throw new IOException( getMessage( "directoryNotFound", classesDirectory.getAbsolutePath() ) );
}
if ( !classFile.isFile() )
{
throw new IOException( getMessage( "fileNotFound", classFile.getAbsolutePath() ) );
}
if ( !( classFile.canRead() && classFile.canWrite() ) )
{
throw new IOException( getMessage( "fileAccessDenied", classFile.getAbsolutePath() ) );
}
if ( this.isLoggable( Level.INFO ) )
{
this.log( Level.INFO, getMessage( "committing", classFile.getAbsolutePath() ), null ); |
File | Line |
---|
org/jomc/tools/ClassFileProcessor.java | 2173 |
org/jomc/tools/ClassFileProcessor.java | 2531 |
final File classesDirectory ) throws IOException
{
if ( implementation.isClassDeclaration() )
{
final String classLocation = implementation.getClazz().replace( '.', File.separatorChar ) + ".class";
final File classFile = new File( classesDirectory, classLocation );
if ( !classesDirectory.isDirectory() )
{
throw new IOException( getMessage( "directoryNotFound", classesDirectory.getAbsolutePath() ) );
}
if ( !classFile.isFile() )
{
throw new IOException( getMessage( "fileNotFound", classFile.getAbsolutePath() ) );
}
if ( !( classFile.canRead() && classFile.canWrite() ) )
{
throw new IOException( getMessage( "fileAccessDenied", classFile.getAbsolutePath() ) );
}
if ( this.isLoggable( Level.INFO ) )
{
this.log( Level.INFO, getMessage( "committing", classFile.getAbsolutePath() ), null ); |
File | Line |
---|
org/jomc/tools/JomcTool.java | 1691 |
org/jomc/tools/JomcTool.java | 1753 |
String methodParameterName = null;
if ( str != null )
{
final int len = str.length();
final StringBuilder builder = new StringBuilder( len );
boolean uc = false;
for ( int i = 0; i < len; i++ )
{
final char c = str.charAt( i );
final String charString = Character.toString( c );
if ( builder.length() > 0 )
{
if ( Character.isJavaIdentifierPart( c ) )
{
builder.append( uc ? charString.toUpperCase( this.getLocale() ) : charString );
uc = false;
}
else
{
uc = true;
}
}
else if ( Character.isJavaIdentifierStart( c ) )
{
builder.append( charString.toLowerCase( this.getLocale() ) );
}
} |
File | Line |
---|
org/jomc/tools/ClassFileProcessor.java | 2145 |
org/jomc/tools/ClassFileProcessor.java | 2535 |
final String classLocation = specification.getClazz().replace( '.', File.separatorChar ) + ".class";
final File classFile = new File( classesDirectory, classLocation );
if ( !classesDirectory.isDirectory() )
{
throw new IOException( getMessage( "directoryNotFound", classesDirectory.getAbsolutePath() ) );
}
if ( !classFile.isFile() )
{
throw new IOException( getMessage( "fileNotFound", classFile.getAbsolutePath() ) );
}
if ( !( classFile.canRead() && classFile.canWrite() ) )
{
throw new IOException( getMessage( "fileAccessDenied", classFile.getAbsolutePath() ) );
}
if ( this.isLoggable( Level.INFO ) )
{
this.log( Level.INFO, getMessage( "committing", classFile.getAbsolutePath() ), null ); |
File | Line |
---|
org/jomc/tools/ClassFileProcessor.java | 2177 |
org/jomc/tools/ClassFileProcessor.java | 2502 |
final String classLocation = implementation.getClazz().replace( '.', File.separatorChar ) + ".class";
final File classFile = new File( classesDirectory, classLocation );
if ( !classesDirectory.isDirectory() )
{
throw new IOException( getMessage( "directoryNotFound", classesDirectory.getAbsolutePath() ) );
}
if ( !classFile.isFile() )
{
throw new IOException( getMessage( "fileNotFound", classFile.getAbsolutePath() ) );
}
if ( !( classFile.canRead() && classFile.canWrite() ) )
{
throw new IOException( getMessage( "fileAccessDenied", classFile.getAbsolutePath() ) );
}
if ( this.isLoggable( Level.INFO ) )
{
this.log( Level.INFO, getMessage( "committing", classFile.getAbsolutePath() ), null ); |
File | Line |
---|
org/jomc/tools/ClassFileProcessor.java | 408 |
org/jomc/tools/ClassFileProcessor.java | 1038 |
final ObjectFactory of = new ObjectFactory();
Dependencies dependencies = this.getModules().getDependencies( implementation.getIdentifier() );
if ( dependencies == null )
{
dependencies = new Dependencies();
}
Properties properties = this.getModules().getProperties( implementation.getIdentifier() );
if ( properties == null )
{
properties = new Properties();
}
Messages messages = this.getModules().getMessages( implementation.getIdentifier() );
if ( messages == null )
{
messages = new Messages();
}
Specifications specifications = this.getModules().getSpecifications( implementation.getIdentifier() );
if ( specifications == null )
{
specifications = new Specifications();
} |
File | Line |
---|
org/jomc/tools/ClassFileProcessor.java | 1662 |
org/jomc/tools/ClassFileProcessor.java | 1876 |
this.log( Level.WARNING, getMessage( "specificationNotFound", specification.getIdentifier() ), null );
}
}
catch ( final JAXBException e )
{
String message = getMessage( e );
if ( message == null && e.getLinkedException() != null )
{
message = getMessage( e.getLinkedException() );
}
// JDK: As of JDK 6, "new IOException( message, cause )".
throw (IOException) new IOException( message ).initCause( e );
}
catch ( final TransformerException e )
{
String message = getMessage( e );
if ( message == null && e.getException() != null )
{
message = getMessage( e.getException() );
}
// JDK: As of JDK 6, "new IOException( message, cause )".
throw (IOException) new IOException( message ).initCause( e );
}
}
/**
* Transforms model objects of a given implementation of the modules of the instance.
*
* @param implementation The implementation to process.
* @param marshaller The marshaller to use for transforming model objects.
* @param unmarshaller The unmarshaller to use for transforming model objects.
* @param javaClass The java class to transform model object of.
* @param transformers The transformers to use for transforming the model objects.
*
* @throws NullPointerException if {@code implementation}, {@code marshaller}, {@code unmarshaller},
* {@code javaClass} or {@code transformers} is {@code null}.
* @throws IOException if transforming model objects fails.
*/
public void transformModelObjects( final Implementation implementation, final Marshaller marshaller, |
File | Line |
---|
org/jomc/tools/ClassFileProcessor.java | 2365 |
org/jomc/tools/ClassFileProcessor.java | 2427 |
this.log( Level.INFO, getMessage( "validatingSpecification", specification.getIdentifier() ), null );
}
InputStream in = null;
JavaClass javaClass = null;
boolean suppressExceptionOnClose = true;
try
{
in = classUrl.openStream();
javaClass = new ClassParser( in, classUrl.toExternalForm() ).parse();
suppressExceptionOnClose = false;
}
finally
{
try
{
if ( in != null )
{
in.close();
}
}
catch ( final IOException e )
{
if ( suppressExceptionOnClose )
{
this.log( Level.SEVERE, getMessage( e ), e );
}
else
{
throw e;
}
}
}
report.getDetails().addAll(
this.validateModelObjects( specification, unmarshaller, javaClass ).getDetails() ); |
File | Line |
---|
org/jomc/tools/modlet/ToolsModelProcessor.java | 540 |
org/jomc/tools/modlet/ToolsModelProcessor.java | 825 |
final JavaTypeName javaTypeName = specification.getJavaTypeName();
if ( javaTypeName != null )
{
if ( javaTypeName.getName( false ).equals( s.getName() ) )
{
if ( !isFieldSet( s, "editable" ) )
{
s.setEditable( true );
}
if ( !isFieldSet( s, "indentationLevel" ) )
{
s.setIndentationLevel( 1 );
}
}
}
}
catch ( final ModelObjectException e )
{
context.log( Level.WARNING, getMessage( e ), null );
}
this.applyDefaults( context, modules, specification, s.getSourceSections() ); |