hudson.plugins.dry.parser
Class DuplicateCode

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

public class DuplicateCode
extends hudson.plugins.analysis.util.model.AbstractAnnotation

A serializable Java Bean class representing a duplicate code warning.

Note: this class has a natural ordering that is inconsistent with equals.

Author:
Ulli Hafner
See Also:
Serialized Form

Field Summary
static String ORIGIN
          Origin of the annotation.
 
Fields inherited from class hudson.plugins.analysis.util.model.AbstractAnnotation
WORKSPACE_FILES
 
Constructor Summary
DuplicateCode(hudson.plugins.analysis.util.model.Priority priority, int firstLine, int numberOfLines, String fileName)
          Creates a new instance of DuplicateCode.
DuplicateCode(hudson.plugins.analysis.util.model.Priority priority, int firstLine, int numberOfLines, String fileName, boolean isDerived)
          Creates a new instance of DuplicateCode.
 
Method Summary
 boolean equals(Object obj)
           
 String getFormattedSourceCode()
          Returns the duplicate source code fragment as formatted HTML string.
 hudson.plugins.analysis.util.model.FileAnnotation getLink(long linkHashCode)
          Returns the link with the specified hash code.
 Collection<DuplicateCode> getLinks()
          Returns the links to the duplicated code in other files.
 String getMessage()
           
 int getNumberOfLines()
          Returns the total number of duplicate lines.
 String getSourceCode()
          Returns the duplicate source code fragment.
 String getToolTip()
          
 String getType()
           
 int hashCode()
           
 boolean isDerived()
          Returns whether this duplication as derived.
 int length()
          Returns the total number of duplicate lines.
 void linkTo(List<DuplicateCode> codeBlocks)
          Creates links to the specified collection of other code blocks.
 void setSourceCode(String sourceCode)
          Sets the duplicate source code fragment to the specified value.
 int size()
          Returns the total number of duplicate lines.
 
Methods inherited from class hudson.plugins.analysis.util.model.AbstractAnnotation
addLineRange, canDisplayFile, compareTo, getCategory, getContextHashCode, getFileName, getKey, getLineRanges, getLinkLineNumber, getLinkName, getModuleName, getOrigin, getPackageName, getPathName, getPrimaryLineNumber, getPriority, getShortFileName, getTempName, hasPackageName, intern, intern, setColumnPosition, setContextHashCode, setFileName, setModuleName, setOrigin, setPackageName, setPathName, setPriority, superReadResolve, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ORIGIN

public static final String ORIGIN
Origin of the annotation.

See Also:
Constant Field Values
Constructor Detail

DuplicateCode

public DuplicateCode(hudson.plugins.analysis.util.model.Priority priority,
                     int firstLine,
                     int numberOfLines,
                     String fileName)
Creates a new instance of DuplicateCode.

Parameters:
priority - the priority of the warning
firstLine - the starting line of the duplication
numberOfLines - total number of duplicate lines
fileName - name of the file that contains the duplication

DuplicateCode

public DuplicateCode(hudson.plugins.analysis.util.model.Priority priority,
                     int firstLine,
                     int numberOfLines,
                     String fileName,
                     boolean isDerived)
Creates a new instance of DuplicateCode.

Parameters:
priority - the priority of the warning
firstLine - the starting line of the duplication
numberOfLines - total number of duplicate lines
fileName - name of the file that contains the duplication
isDerived - determines if this duplication is derived. Derived duplications will not be shown in the user interface
Method Detail

isDerived

public boolean isDerived()
Returns whether this duplication as derived. Derived duplications will not be shown in the user interface.

Returns:
true if this duplication as derived, false if it is the master duplication

getType

public String getType()
Specified by:
getType in interface hudson.plugins.analysis.util.model.FileAnnotation
Overrides:
getType in class hudson.plugins.analysis.util.model.AbstractAnnotation

getMessage

public String getMessage()
Specified by:
getMessage in interface hudson.plugins.analysis.util.model.FileAnnotation
Overrides:
getMessage in class hudson.plugins.analysis.util.model.AbstractAnnotation

getNumberOfLines

public int getNumberOfLines()
Returns the total number of duplicate lines.

Returns:
the number of duplicate lines

size

public int size()
Returns the total number of duplicate lines.

Returns:
the number of duplicate lines

length

public int length()
Returns the total number of duplicate lines.

Returns:
the number of duplicate lines

getToolTip

public String getToolTip()


linkTo

public void linkTo(List<DuplicateCode> codeBlocks)
Creates links to the specified collection of other code blocks.

Parameters:
codeBlocks - the code blocks to links to

getLinks

public Collection<DuplicateCode> getLinks()
Returns the links to the duplicated code in other files.

Returns:
the links

getSourceCode

public String getSourceCode()
Returns the duplicate source code fragment.

Returns:
the duplicate source code fragment

getFormattedSourceCode

public String getFormattedSourceCode()
Returns the duplicate source code fragment as formatted HTML string.

Returns:
the duplicate source code fragment

setSourceCode

public void setSourceCode(String sourceCode)
Sets the duplicate source code fragment to the specified value.

Parameters:
sourceCode - the duplicate code fragment

hashCode

public int hashCode()
Overrides:
hashCode in class hudson.plugins.analysis.util.model.AbstractAnnotation

equals

public boolean equals(Object obj)
Overrides:
equals in class hudson.plugins.analysis.util.model.AbstractAnnotation

getLink

public hudson.plugins.analysis.util.model.FileAnnotation getLink(long linkHashCode)
Returns the link with the specified hash code.

Parameters:
linkHashCode - the hash code of the linked annotation
Returns:
the link with the specified hash code


Copyright © 2004-2013 Hudson. All Rights Reserved.