hudson.plugins.dry.parser
Class DuplicateCode

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

public class DuplicateCode
extends 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
 
Fields inherited from class hudson.plugins.dry.util.model.AbstractAnnotation
WORKSPACE_FILES
 
Constructor Summary
DuplicateCode(int firstLine, int numberOfLines, java.lang.String fileName)
          Creates a new instance of DuplicateCode.
 
Method Summary
 boolean equals(java.lang.Object obj)
          
 java.lang.String getFormattedSourceCode()
          Returns the duplicate source code fragment as formatted HTML string.
 FileAnnotation getLink(long linkHashCode)
          Returns the link with the specified hash code.
 java.util.Collection<DuplicateCode> getLinks()
          Returns the links to the duplicated code in other files.
 int getNumberOfLines()
          Returns the total number of duplicate lines.
 java.lang.String getSourceCode()
          Returns the duplicate source code fragment.
 java.lang.String getToolTip()
          Returns the a detailed description that will be used as tooltip.
 int hashCode()
          
 int length()
          Returns the total number of duplicate lines.
 void linkTo(java.util.ArrayList<DuplicateCode> codeBlocks)
          Creates links to the specified collection of other code blocks.
 void setSourceCode(java.lang.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.dry.util.model.AbstractAnnotation
addLineRange, canDisplayFile, compareTo, getCategory, getFileName, getKey, getLineRanges, getMessage, getModuleName, getPackageName, getPrimaryLineNumber, getPriority, getShortFileName, getTempName, getType, hasPackageName, setFileName, setModuleName, setPackageName, setPriority
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DuplicateCode

public DuplicateCode(int firstLine,
                     int numberOfLines,
                     java.lang.String fileName)
Creates a new instance of DuplicateCode.

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

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 java.lang.String getToolTip()
Returns the a detailed description that will be used as tooltip.

Returns:
the tooltip of this annotation

linkTo

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

Parameters:
codeBlocks - the code blocks to links to

getLinks

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

Returns:
the links

getSourceCode

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

Returns:
the duplicate source code fragment

getFormattedSourceCode

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

Returns:
the duplicate source code fragment

setSourceCode

public void setSourceCode(java.lang.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 AbstractAnnotation

equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class AbstractAnnotation

getLink

public 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 © 2009. All Rights Reserved.