hudson.plugins.findbugs.util.model
Class AnnotationContainer

java.lang.Object
  extended by hudson.plugins.findbugs.util.model.AnnotationContainer
All Implemented Interfaces:
AnnotationProvider, java.io.Serializable
Direct Known Subclasses:
AbstractAnnotationsDetail, JavaPackage, JavaProject, MavenModule, WorkspaceFile

public class AnnotationContainer
extends java.lang.Object
implements AnnotationProvider, java.io.Serializable

A container for annotations.

Author:
Ulli Hafner
See Also:
Serialized Form

Constructor Summary
  AnnotationContainer()
          Creates a new instance of AnnotationContainer.
protected AnnotationContainer(boolean handleFiles, java.lang.String name)
          Creates a new instance of AnnotationContainer.
 
Method Summary
 void addAnnotation(FileAnnotation annotation)
          Adds the specified annotation to this container.
 void addAnnotations(java.util.Collection<? extends FileAnnotation> newAnnotations)
          Adds the specified annotations to this container.
 void addAnnotations(FileAnnotation[] newAnnotations)
          Adds the specified annotations to this container.
protected  void addFile(FileAnnotation annotation)
          Adds a new file to this container that will contain the specified annotation.
protected  void annotationAdded(FileAnnotation annotation)
          Called if the specified annotation has been added to this container.
 FileAnnotation getAnnotation(long key)
          Returns the annotation with the specified key.
 FileAnnotation getAnnotation(java.lang.String key)
          Returns the annotation with the specified key.
 java.util.Collection<FileAnnotation> getAnnotations()
          Returns the annotations for this object.
 java.util.Collection<FileAnnotation> getAnnotations(Priority priority)
          Returns the annotations of the specified priority for this object.
 java.util.Collection<FileAnnotation> getAnnotations(java.lang.String priority)
          Returns the annotations of the specified priority for this object.
 WorkspaceFile getFile(java.lang.String fileName)
          Gets the file with the given name.
 java.util.Collection<WorkspaceFile> getFiles()
          Gets the files of this container that have annotations.
 java.lang.String getName()
          Returns the name of this container.
 int getNumberOfAnnotations()
          Returns the total number of annotations for this object.
 int getNumberOfAnnotations(Priority priority)
          Returns the total number of annotations of the specified priority for this object.
 int getNumberOfAnnotations(java.lang.String priority)
          Returns the annotations of the specified priority for this object.
 java.lang.String getPackageCategoryName()
          Returns the package category name for the scanned files.
 java.lang.String getToolTip()
          Returns a tooltip showing the distribution of priorities for this container.
 boolean hasAnnotations()
          Returns whether this objects has annotations.
 boolean hasAnnotations(Priority priority)
          Returns whether this objects has annotations with the specified priority.
 boolean hasAnnotations(java.lang.String priority)
          Returns whether this objects has annotations with the specified priority.
protected  void rebuildMappings(boolean handleFilesByContainer)
          Rebuilds the priorities and files after deserialization.
 void setName(java.lang.String name)
          Sets the name of this container.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationContainer

public AnnotationContainer()
Creates a new instance of AnnotationContainer.


AnnotationContainer

protected AnnotationContainer(boolean handleFiles,
                              java.lang.String name)
Creates a new instance of AnnotationContainer.

Parameters:
handleFiles - determines whether to build up a set of WorkspaceFiles. If set to true then this container will automatically build up a workspace file mapping that could be used by clients of this class. Set this value to false if your subclass already has such a mapping or provides a faster implementation of the associated methods getFiles() and getFile(String).
name - the name of this container
Method Detail

getName

public final java.lang.String getName()
Returns the name of this container.

Returns:
the name of this container

setName

public final void setName(java.lang.String name)
Sets the name of this container.

Parameters:
name - the name of this container

rebuildMappings

protected void rebuildMappings(boolean handleFilesByContainer)
Rebuilds the priorities and files after deserialization.

Parameters:
handleFilesByContainer - determines whether to build up a set of WorkspaceFiles. If set to true then this container will automatically build up a workspace file mapping that could be used by clients of this class. Set this value to false if your subclass already has such a mapping or provides a faster implementation of the associated methods getFiles() and getFile(String).

addFile

protected final void addFile(FileAnnotation annotation)
Adds a new file to this container that will contain the specified annotation. If the file already exists, then the annotation is only added to this file.

Parameters:
annotation - the new annotation

addAnnotation

public final void addAnnotation(FileAnnotation annotation)
Adds the specified annotation to this container.

Parameters:
annotation - the annotation to add

addAnnotations

public final void addAnnotations(java.util.Collection<? extends FileAnnotation> newAnnotations)
Adds the specified annotations to this container.

Parameters:
newAnnotations - the annotations to add

addAnnotations

public final void addAnnotations(FileAnnotation[] newAnnotations)
Adds the specified annotations to this container.

Parameters:
newAnnotations - the annotations to add

annotationAdded

protected void annotationAdded(FileAnnotation annotation)
Called if the specified annotation has been added to this container. Subclasses may override this default empty implementation.

Parameters:
annotation - the added annotation

getAnnotations

public final java.util.Collection<FileAnnotation> getAnnotations()
Returns the annotations for this object.

Specified by:
getAnnotations in interface AnnotationProvider
Returns:
annotations for this object

getAnnotations

public final java.util.Collection<FileAnnotation> getAnnotations(Priority priority)
Returns the annotations of the specified priority for this object.

Specified by:
getAnnotations in interface AnnotationProvider
Parameters:
priority - the priority
Returns:
annotations of the specified priority for this object

getAnnotations

public final java.util.Collection<FileAnnotation> getAnnotations(java.lang.String priority)
Returns the annotations of the specified priority for this object.

Specified by:
getAnnotations in interface AnnotationProvider
Parameters:
priority - the priority as a string object
Returns:
annotations of the specified priority for this object

getNumberOfAnnotations

public int getNumberOfAnnotations()
Returns the total number of annotations for this object.

Specified by:
getNumberOfAnnotations in interface AnnotationProvider
Returns:
total number of annotations for this object

getNumberOfAnnotations

public int getNumberOfAnnotations(Priority priority)
Returns the total number of annotations of the specified priority for this object.

Specified by:
getNumberOfAnnotations in interface AnnotationProvider
Parameters:
priority - the priority
Returns:
total number of annotations of the specified priority for this object

getNumberOfAnnotations

public final int getNumberOfAnnotations(java.lang.String priority)
Returns the annotations of the specified priority for this object.

Specified by:
getNumberOfAnnotations in interface AnnotationProvider
Parameters:
priority - the priority as a string object
Returns:
annotations of the specified priority for this object

hasAnnotations

public final boolean hasAnnotations()
Returns whether this objects has annotations.

Specified by:
hasAnnotations in interface AnnotationProvider
Returns:
true if this objects has annotations.

hasAnnotations

public final boolean hasAnnotations(Priority priority)
Returns whether this objects has annotations with the specified priority.

Specified by:
hasAnnotations in interface AnnotationProvider
Parameters:
priority - the priority
Returns:
true if this objects has annotations.

hasAnnotations

public final boolean hasAnnotations(java.lang.String priority)
Returns whether this objects has annotations with the specified priority.

Specified by:
hasAnnotations in interface AnnotationProvider
Parameters:
priority - the priority as a string object
Returns:
true if this objects has annotations.

getAnnotation

public final FileAnnotation getAnnotation(long key)
Returns the annotation with the specified key.

Specified by:
getAnnotation in interface AnnotationProvider
Parameters:
key - the key of the annotation
Returns:
the annotation with the specified key

getAnnotation

public final FileAnnotation getAnnotation(java.lang.String key)
Returns the annotation with the specified key.

Specified by:
getAnnotation in interface AnnotationProvider
Parameters:
key - the key of the annotation as a long value in string representation
Returns:
the annotation with the specified key

getToolTip

public java.lang.String getToolTip()
Returns a tooltip showing the distribution of priorities for this container.

Returns:
a tooltip showing the distribution of priorities

getPackageCategoryName

public final java.lang.String getPackageCategoryName()
Returns the package category name for the scanned files. Currently, only java and c# files are supported.

Returns:
the package category name for the scanned files

getFiles

public java.util.Collection<WorkspaceFile> getFiles()
Gets the files of this container that have annotations.

Returns:
the files with annotations

getFile

public WorkspaceFile getFile(java.lang.String fileName)
Gets the file with the given name.

Parameters:
fileName - the short name of the file
Returns:
the file with the given name


Copyright © 2008. All Rights Reserved.