
hudson.plugins.checkstyle.util.AbstractAnnotationsDetail Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of checkstyle Show documentation
Show all versions of checkstyle Show documentation
This plug-in generates the trend report for
Checkstyle, an open source static code analysis program.
package hudson.plugins.checkstyle.util;
import hudson.model.AbstractBuild;
import hudson.model.ModelObject;
import hudson.plugins.checkstyle.util.model.AnnotationContainer;
import hudson.plugins.checkstyle.util.model.FileAnnotation;
import hudson.plugins.checkstyle.util.model.Priority;
import java.util.Collection;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
/**
* Base class for annotation detail objects. Instances of this class could be used for
* Hudson Stapler objects that contain a subset of annotations.
*
* @author Ulli Hafner
*/
public abstract class AbstractAnnotationsDetail extends AnnotationContainer implements ModelObject {
/** Unique identifier of this class. */
private static final long serialVersionUID = 1750266351592937774L;
/** Current build as owner of this object. */
private final AbstractBuild, ?> owner;
/** The default encoding to be used when reading and parsing files. */
private final String defaultEncoding;
/**
* Creates a new instance of {@link AbstractAnnotationsDetail}.
*
* @param owner
* current build as owner of this object.
* @param annotations
* the set of warnings represented by this object
* @param defaultEncoding
* the default encoding to be used when reading and parsing files
* @param name
* the name of this object
* @param hierarchy
* the hierarchy level of this detail object
*/
public AbstractAnnotationsDetail(final AbstractBuild, ?> owner, final Collection annotations, final String defaultEncoding, final String name, final Hierarchy hierarchy) {
super(name, hierarchy);
this.owner = owner;
this.defaultEncoding = defaultEncoding;
addAnnotations(annotations);
}
/**
* Returns the defined default encoding.
*
* @return the default encoding
*/
public String getDefaultEncoding() {
return defaultEncoding;
}
/**
* Returns the header for the detail screen.
*
* @return the header
*/
public String getHeader() {
return getName() + " - " + getDisplayName();
}
/**
* Returns the build as owner of this object.
*
* @return the owner
*/
public final AbstractBuild, ?> getOwner() {
return owner;
}
/**
* Returns whether this build is the last available build.
*
* @return true
if this build is the last available build
*/
public final boolean isCurrent() {
return owner.getProject().getLastBuild().number == owner.number;
}
/**
* Returns a localized priority name.
*
* @param priorityName
* priority as String value
* @return localized priority name
*/
public String getLocalizedPriority(final String priorityName) {
return Priority.fromString(priorityName).getLongLocalizedString();
}
/**
* Returns the dynamic result of this module detail view. Depending on the
* number of packages, one of the following detail objects is returned:
*
* - A detail object for a single workspace file (if the module contains
* only one package).
* - A package detail object for a specified package (in any other case).
*
*
* @param link
* the link to identify the sub page to show
* @param request
* Stapler request
* @param response
* Stapler response
* @return the dynamic result of this module detail view
*/
public Object getDynamic(final String link, final StaplerRequest request, final StaplerResponse response) {
return DetailBuilder.create().createDetails(link, owner, getContainer(), defaultEncoding, getDisplayName());
}
/**
* Returns all possible priorities.
*
* @return all priorities
*/
public Priority[] getPriorities() {
return Priority.values();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy