hudson.plugins.checkstyle.util
Class BuildResult

java.lang.Object
  extended by hudson.plugins.checkstyle.util.BuildResult
All Implemented Interfaces:
hudson.model.ModelObject, AnnotationProvider, java.io.Serializable
Direct Known Subclasses:
CheckStyleResult

public abstract class BuildResult
extends java.lang.Object
implements hudson.model.ModelObject, java.io.Serializable, AnnotationProvider

A base class for build results that is capable of storing a reference to the current build. Provides support for persisting the results of the build and loading and saving of annotations (all, new, and fixed) and delta computation.

Author:
Ulli Hafner
See Also:
Serialized Form

Field Summary
protected  java.lang.String high
          Deprecated. 
protected  java.lang.String low
          Deprecated. 
protected  java.lang.String normal
          Deprecated. 
protected static com.thoughtworks.xstream.XStream XSTREAM
          Serialization provider.
 
Constructor Summary
BuildResult(hudson.model.AbstractBuild<?,?> build, java.lang.String defaultEncoding, ParserResult result)
          Creates a new instance of BuildResult.
BuildResult(hudson.model.AbstractBuild<?,?> build, java.lang.String defaultEncoding, ParserResult result, BuildResult previous)
          Creates a new instance of BuildResult.
 
Method Summary
 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.
 AnnotationContainer getContainer()
          Gets the annotation container.
protected  hudson.XmlFile getDataFile()
          Returns the serialization file.
static long getDays(long ms)
          Returns the number of days for the specified number of milliseconds.
 java.lang.String getDefaultEncoding()
          Returns the defined default encoding.
 int getDelta()
          Returns the delta.
abstract  java.lang.String getDetails()
          Returns the detail messages for the summary.jelly file.
 java.lang.Object getDynamic(java.lang.String link, org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response)
          Returns the dynamic result of the selection element.
 java.util.List<java.lang.String> getErrors()
          Returns the error messages associated with this build.
 java.util.Collection<FileAnnotation> getFixedWarnings()
          Returns the fixed warnings of this build.
 long getHighScoreGap()
          Returns the number of msec still to go before a new highscore is reached.
 java.util.Collection<java.lang.String> getModules()
          Returns the modules of this build result.
 java.util.Collection<FileAnnotation> getNewWarnings()
          Returns the new warnings of this build.
 int getNumberOfAnnotations()
          Gets the number of warnings.
 int getNumberOfAnnotations(Priority priority)
          Returns the total number of warnings of the specified priority for this object.
 int getNumberOfAnnotations(java.lang.String priority)
          Returns the annotations of the specified priority for this object.
 int getNumberOfFixedWarnings()
          Gets the number of fixed warnings.
 int getNumberOfModules()
          Returns the number of modules in this project.
 int getNumberOfNewWarnings()
          Gets the number of new warnings.
 hudson.model.AbstractBuild<?,?> getOwner()
          Returns the build as owner of this action.
 JavaProject getPreviousResult()
          Returns the results of the previous build.
 Priority[] getPriorities()
          Returns all possible priorities.
 JavaProject getProject()
          Returns the associated project of this result.
protected abstract  java.lang.Class<? extends ResultAction<? extends BuildResult>> getResultActionType()
          Returns the actual type of the associated result action.
protected abstract  java.lang.String getSerializationFileName()
          Returns the name of the file to store the serialized annotations.
 long getZeroWarningsHighScore()
          Returns the maximum period with zero warnings in a build.
 int getZeroWarningsSinceBuild()
          Returns the build since we have zero warnings.
 long getZeroWarningsSinceDate()
          Returns the time since we have zero warnings.
 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.
 boolean hasError()
          Returns whether a module with an error is part of this project.
 boolean hasNoAnnotations()
          Returns whether this objects has no annotations.
 boolean hasNoAnnotations(Priority priority)
          Returns whether this objects has no annotations with the specified priority.
 boolean hasNoAnnotations(java.lang.String priority)
          Returns whether this objects has no annotations with the specified priority.
 boolean hasPreviousResult()
          Returns whether a previous build result exists.
 boolean isCurrent()
          Returns whether this result belongs to the last build.
 boolean isNewZeroWarningsHighScore()
          Returns if the current result reached the old zero warnings highscore.
protected  java.lang.Object readResolve()
          Initializes members that were not present in previous versions of this plug-in.
protected  void setHighWarnings(int highWarnings)
          Sets the number of high warnings to the specified value.
protected  void setLowWarnings(int lowWarnings)
          Sets the number of low warnings to the specified value.
protected  void setNormalWarnings(int normalWarnings)
          Sets the number of normal warnings to the specified value.
protected  void setWarnings(int warnings)
          Sets the number of warnings to the specified value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface hudson.model.ModelObject
getDisplayName
 

Field Detail

XSTREAM

protected static final com.thoughtworks.xstream.XStream XSTREAM
Serialization provider.


low

@Deprecated
protected transient java.lang.String low
Deprecated. 

normal

@Deprecated
protected transient java.lang.String normal
Deprecated. 

high

@Deprecated
protected transient java.lang.String high
Deprecated. 
Constructor Detail

BuildResult

public BuildResult(hudson.model.AbstractBuild<?,?> build,
                   java.lang.String defaultEncoding,
                   ParserResult result)
Creates a new instance of BuildResult.

Parameters:
build - the current build as owner of this action
defaultEncoding - the default encoding to be used when reading and parsing files
result - the parsed result with all annotations

BuildResult

public BuildResult(hudson.model.AbstractBuild<?,?> build,
                   java.lang.String defaultEncoding,
                   ParserResult result,
                   BuildResult previous)
Creates a new instance of BuildResult.

Parameters:
build - the current build as owner of this action
defaultEncoding - the default encoding to be used when reading and parsing files
result - the parsed result with all annotations
previous - the result of the previous build
Method Detail

getDays

public static long getDays(long ms)
Returns the number of days for the specified number of milliseconds.

Parameters:
ms - milliseconds
Returns:
the number of days

hasError

public boolean hasError()
Returns whether a module with an error is part of this project.

Returns:
true if at least one module has an error.

getErrors

public java.util.List<java.lang.String> getErrors()
Returns the error messages associated with this build.

Returns:
the error messages

readResolve

protected java.lang.Object readResolve()
Initializes members that were not present in previous versions of this plug-in.

Returns:
the created object

getModules

public java.util.Collection<java.lang.String> getModules()
Returns the modules of this build result.

Returns:
the modules

getNumberOfModules

public int getNumberOfModules()
Returns the number of modules in this project.

Returns:
the number of modules

getDefaultEncoding

public java.lang.String getDefaultEncoding()
Returns the defined default encoding.

Returns:
the default encoding

getDataFile

protected final hudson.XmlFile getDataFile()
Returns the serialization file.

Returns:
the serialization file.

getSerializationFileName

protected abstract java.lang.String getSerializationFileName()
Returns the name of the file to store the serialized annotations.

Returns:
the name of the file to store the serialized annotations

isCurrent

public final boolean isCurrent()
Returns whether this result belongs to the last build.

Returns:
true if this result belongs to the last build

getOwner

public final hudson.model.AbstractBuild<?,?> getOwner()
Returns the build as owner of this action.

Returns:
the owner

hasAnnotations

public 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 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.

hasAnnotations

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

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

hasNoAnnotations

public boolean hasNoAnnotations()
Returns whether this objects has no annotations.

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

hasNoAnnotations

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

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

hasNoAnnotations

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

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

getAnnotations

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

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

getAnnotation

public 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 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

setHighWarnings

protected void setHighWarnings(int highWarnings)
Sets the number of high warnings to the specified value.

Parameters:
highWarnings - the value to set

setNormalWarnings

protected void setNormalWarnings(int normalWarnings)
Sets the number of normal warnings to the specified value.

Parameters:
normalWarnings - the value to set

setLowWarnings

protected void setLowWarnings(int lowWarnings)
Sets the number of low warnings to the specified value.

Parameters:
lowWarnings - the value to set

setWarnings

protected void setWarnings(int warnings)
Sets the number of warnings to the specified value.

Parameters:
warnings - the value to set

getAnnotations

public 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

getDetails

public abstract java.lang.String getDetails()
Returns the detail messages for the summary.jelly file.

Returns:
the summary message

getZeroWarningsSinceBuild

public int getZeroWarningsSinceBuild()
Returns the build since we have zero warnings.

Returns:
the build since we have zero warnings

getZeroWarningsSinceDate

public long getZeroWarningsSinceDate()
Returns the time since we have zero warnings.

Returns:
the time since we have zero warnings

getZeroWarningsHighScore

public long getZeroWarningsHighScore()
Returns the maximum period with zero warnings in a build.

Returns:
the time since we have zero warnings

isNewZeroWarningsHighScore

public boolean isNewZeroWarningsHighScore()
Returns if the current result reached the old zero warnings highscore.

Returns:
true, if the current result reached the old zero warnings highscore.

getHighScoreGap

public long getHighScoreGap()
Returns the number of msec still to go before a new highscore is reached.

Returns:
the number of msec still to go before a new highscore is reached.

getNumberOfAnnotations

public int getNumberOfAnnotations()
Gets the number of warnings.

Specified by:
getNumberOfAnnotations in interface AnnotationProvider
Returns:
the number of warnings

getNumberOfAnnotations

public int getNumberOfAnnotations(Priority priority)
Returns the total number of warnings 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

getNumberOfFixedWarnings

public int getNumberOfFixedWarnings()
Gets the number of fixed warnings.

Returns:
the number of fixed warnings

getNumberOfNewWarnings

public int getNumberOfNewWarnings()
Gets the number of new warnings.

Returns:
the number of new warnings

getDelta

public int getDelta()
Returns the delta.

Returns:
the delta

getProject

public JavaProject getProject()
Returns the associated project of this result.

Returns:
the associated project of this result.

getNewWarnings

public java.util.Collection<FileAnnotation> getNewWarnings()
Returns the new warnings of this build.

Returns:
the new warnings of this build.

getFixedWarnings

public java.util.Collection<FileAnnotation> getFixedWarnings()
Returns the fixed warnings of this build.

Returns:
the fixed warnings of this build.

hasPreviousResult

public boolean hasPreviousResult()
Returns whether a previous build result exists.

Returns:
true if a previous build result exists.

getPreviousResult

public JavaProject getPreviousResult()
Returns the results of the previous build.

Returns:
the result of the previous build, or null if no such build exists

getResultActionType

protected abstract java.lang.Class<? extends ResultAction<? extends BuildResult>> getResultActionType()
Returns the actual type of the associated result action.

Returns:
the actual type of the associated result action

getDynamic

public java.lang.Object getDynamic(java.lang.String link,
                                   org.kohsuke.stapler.StaplerRequest request,
                                   org.kohsuke.stapler.StaplerResponse response)
Returns the dynamic result of the selection element.

Parameters:
link - the link to identify the sub page to show
request - Stapler request
response - Stapler response
Returns:
the dynamic result of the analysis (detail page).

getPriorities

public Priority[] getPriorities()
Returns all possible priorities.

Returns:
all priorities

getAnnotations

public 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(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

getContainer

public AnnotationContainer getContainer()
Gets the annotation container.

Returns:
the container


Copyright © 2009. All Rights Reserved.