hudson.plugins.analysis.util.model
Class AbstractAnnotation

java.lang.Object
  extended by hudson.plugins.analysis.util.model.AbstractAnnotation
All Implemented Interfaces:
FileAnnotation, Serializable, Comparable<FileAnnotation>

@ExportedBean
public abstract class AbstractAnnotation
extends Object
implements FileAnnotation, Serializable

A base class for annotations.

Author:
Ulli Hafner
See Also:
Serialized Form

Field Summary
static String WORKSPACE_FILES
          Temporary directory holding the workspace files.
 
Constructor Summary
AbstractAnnotation(AbstractAnnotation copy)
          Copy constructor: Creates a new instance of AbstractAnnotation.
AbstractAnnotation(Priority priority, String message, int start, int end, String category, String type)
          Creates a new instance of AbstractAnnotation.
AbstractAnnotation(String message, int start, int end, String category, String type)
          Creates a new instance of AbstractAnnotation.
 
Method Summary
 void addLineRange(LineRange lineRange)
          Adds another line range to this annotation.
 boolean canDisplayFile(hudson.model.AbstractBuild<?,?> owner)
          Checks if the file exists and the user is authorized to see the contents of the file.
 int compareTo(FileAnnotation other)
          
 boolean equals(Object obj)
           
 String getCategory()
          Returns the category of the annotation.
 long getContextHashCode()
          Returns a hash code of the surrounding context of this annotation.
 String getFileName()
          Returns the absolute path of the workspace file that contains this annotation.
 long getKey()
          Returns the unique key of this annotation.
 Collection<LineRange> getLineRanges()
          Returns a collection of line ranges for this annotation.
 int getLinkLineNumber()
          Returns the line number that should be shown on top of the source code view.
 String getLinkName()
          Returns the name of this annotation that could be used as text in links.
 String getMessage()
          Returns the message of this annotation.
 String getModuleName()
          Returns the name of the maven or ant module that contains this annotation.
 String getOrigin()
          Returns the origin of the annotation.
 String getPackageName()
          Returns the name of package (or namespace) that contains this annotation.
 String getPathName()
          Returns the path name of this annotation (relative path to the affected file).
 int getPrimaryLineNumber()
          Returns the primary line number of this annotation that defines the anchor of this annotation.
 Priority getPriority()
          Returns the priority of this annotation.
 String getShortFileName()
          Gets the associated file name of this bug (without path).
 String getTempName(hudson.model.AbstractBuild<?,?> owner)
          Returns a file name for a temporary file that will hold the contents of the source.
 String getType()
          Returns the annotation type.
 int hashCode()
           
 boolean hasPackageName()
          Returns whether a package name is defined for this annotation.
static Collection<FileAnnotation> intern(Collection<FileAnnotation> annotations)
          Let FileAnnotations share some of their internal data structure to reduce memory footprint.
 void intern(TreeStringBuilder builder)
          AbstractAnnotationParser can call this method to let AbstractAnnotations to reduce their memory footprint by sharing what they can share with other AbstractAnnotations.
 void setColumnPosition(int columnStart, int columnEnd)
          Sets the column position of this warning.
 void setContextHashCode(long contextHashCode)
          Sets the context hash code to the specified value.
 void setFileName(String fileName)
          Sets the file name to the specified value.
 void setModuleName(String moduleName)
          Sets the module name to the specified value.
 void setOrigin(String origin)
          Sets the origin of this annotation to the specified value.
 void setPackageName(String packageName)
          Sets the package name to the specified value.
 void setPathName(String workspacePath)
          Sets the pathname for this warning.
 void setPriority(Priority priority)
          Sets the priority to the specified value.
protected  void superReadResolve()
          Simply calls readResolve().
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface hudson.plugins.analysis.util.model.FileAnnotation
getToolTip
 

Field Detail

WORKSPACE_FILES

public static final String WORKSPACE_FILES
Temporary directory holding the workspace files.

See Also:
Constant Field Values
Constructor Detail

AbstractAnnotation

public AbstractAnnotation(String message,
                          int start,
                          int end,
                          String category,
                          String type)
Creates a new instance of AbstractAnnotation.

Parameters:
message - the message of the warning
start - the first line of the line range
end - the last line of the line range
category - the category of the annotation
type - the type of the annotation

AbstractAnnotation

public AbstractAnnotation(Priority priority,
                          String message,
                          int start,
                          int end,
                          String category,
                          String type)
Creates a new instance of AbstractAnnotation.

Parameters:
priority - the priority
message - the message of the warning
start - the first line of the line range
end - the last line of the line range
category - the category of the annotation
type - the type of the annotation

AbstractAnnotation

public AbstractAnnotation(AbstractAnnotation copy)
Copy constructor: Creates a new instance of AbstractAnnotation.

Parameters:
copy - the annotation to copy the values from
Method Detail

superReadResolve

protected void superReadResolve()
Simply calls readResolve().


intern

public void intern(TreeStringBuilder builder)
AbstractAnnotationParser can call this method to let AbstractAnnotations to reduce their memory footprint by sharing what they can share with other AbstractAnnotations.

Parameters:
builder - caches previously used strings
Since:
1.43

intern

public static Collection<FileAnnotation> intern(Collection<FileAnnotation> annotations)
Let FileAnnotations share some of their internal data structure to reduce memory footprint.

Parameters:
annotations - the annotations to compress
Returns:
The same object as passed in the 'annotations' parameter to let this function used as a filter.

setColumnPosition

public void setColumnPosition(int columnStart,
                              int columnEnd)
Sets the column position of this warning.

Parameters:
columnStart - starting column
columnEnd - ending column

getLinkName

public String getLinkName()
Returns the name of this annotation that could be used as text in links.

Specified by:
getLinkName in interface FileAnnotation
Returns:
the link name of this duplication

hasPackageName

public boolean hasPackageName()
Returns whether a package name is defined for this annotation.

Specified by:
hasPackageName in interface FileAnnotation
Returns:
true if this annotation has a package or namespace name, false otherwise

setPathName

public void setPathName(String workspacePath)
Sets the pathname for this warning.

Specified by:
setPathName in interface FileAnnotation
Parameters:
workspacePath - the workspace path

getPathName

public String getPathName()
Returns the path name of this annotation (relative path to the affected file).

Specified by:
getPathName in interface FileAnnotation
Returns:
the path name

getOrigin

public String getOrigin()
Returns the origin of the annotation. Might be an empty string.

Specified by:
getOrigin in interface FileAnnotation
Returns:
the origin of the annotation

setOrigin

public void setOrigin(String origin)
Sets the origin of this annotation to the specified value.

Parameters:
origin - the value to set

setPriority

public void setPriority(Priority priority)
Sets the priority to the specified value.

Parameters:
priority - the value to set

getMessage

@Exported
public String getMessage()
Returns the message of this annotation.

Specified by:
getMessage in interface FileAnnotation
Returns:
the message of this annotation

getPriority

@Exported
public Priority getPriority()
Returns the priority of this annotation.

Specified by:
getPriority in interface FileAnnotation
Returns:
the priority of this annotation

getKey

@Exported
public final long getKey()
Returns the unique key of this annotation.

Specified by:
getKey in interface FileAnnotation
Returns:
the unique key of this annotation.

getFileName

@Exported
public final String getFileName()
Returns the absolute path of the workspace file that contains this annotation.

Specified by:
getFileName in interface FileAnnotation
Returns:
the name of the workspace file that contains this annotation

getTempName

public String getTempName(hudson.model.AbstractBuild<?,?> owner)
Returns a file name for a temporary file that will hold the contents of the source. This temporary file is used in a master - slave scenario where the original file remains on the slave while this temporary file is transferred to the master.

Specified by:
getTempName in interface FileAnnotation
Parameters:
owner - the owner that provides the root directory where the files are stored
Returns:
the temporary name

getCategory

public String getCategory()
Returns the category of the annotation. Might be an empty string if there is no category.

Specified by:
getCategory in interface FileAnnotation
Returns:
the annotation category

getType

public String getType()
Returns the annotation type. Might be an empty string if there is no type.

Specified by:
getType in interface FileAnnotation
Returns:
the annotation type

setFileName

public final void setFileName(String fileName)
Sets the file name to the specified value.

Specified by:
setFileName in interface FileAnnotation
Parameters:
fileName - the value to set

getModuleName

public final String getModuleName()
Returns the name of the maven or ant module that contains this annotation.

Specified by:
getModuleName in interface FileAnnotation
Returns:
the name of the module that contains this annotation

setModuleName

public final void setModuleName(String moduleName)
Sets the module name to the specified value.

Specified by:
setModuleName in interface FileAnnotation
Parameters:
moduleName - the value to set

getPackageName

public final String getPackageName()
Returns the name of package (or namespace) that contains this annotation.

Specified by:
getPackageName in interface FileAnnotation
Returns:
the name of the package that contains this annotation

setPackageName

public final void setPackageName(String packageName)
Sets the package name to the specified value.

Parameters:
packageName - the value to set

getLineRanges

public final Collection<LineRange> getLineRanges()
Returns a collection of line ranges for this annotation.

Specified by:
getLineRanges in interface FileAnnotation
Returns:
the collection of line ranges for this annotation.

getPrimaryLineNumber

@Exported
public final int getPrimaryLineNumber()
Returns the primary line number of this annotation that defines the anchor of this annotation.

Specified by:
getPrimaryLineNumber in interface FileAnnotation
Returns:
the primary line number of this annotation

getLinkLineNumber

public final int getLinkLineNumber()
Returns the line number that should be shown on top of the source code view.

Returns:
the line number

addLineRange

public void addLineRange(LineRange lineRange)
Adds another line range to this annotation.

Parameters:
lineRange - the line range to add

getContextHashCode

public long getContextHashCode()
Returns a hash code of the surrounding context of this annotation.

Specified by:
getContextHashCode in interface FileAnnotation
Returns:
a hash code of the surrounding context of this annotation.

setContextHashCode

public void setContextHashCode(long contextHashCode)
Sets the context hash code to the specified value.

Specified by:
setContextHashCode in interface FileAnnotation
Parameters:
contextHashCode - the value to set

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

getShortFileName

public String getShortFileName()
Gets the associated file name of this bug (without path).

Specified by:
getShortFileName in interface FileAnnotation
Returns:
the short file name

canDisplayFile

public final boolean canDisplayFile(hudson.model.AbstractBuild<?,?> owner)
Checks if the file exists and the user is authorized to see the contents of the file.

Specified by:
canDisplayFile in interface FileAnnotation
Parameters:
owner - the owner that provides the root directory where the files are stored
Returns:
true, if successful

compareTo

public int compareTo(FileAnnotation other)

Specified by:
compareTo in interface Comparable<FileAnnotation>

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2004-2012 Hudson. All Rights Reserved.