hudson.plugins.dry.util
Class SourceDetail

java.lang.Object
  extended by hudson.plugins.dry.util.SourceDetail
All Implemented Interfaces:
hudson.model.ModelObject

public class SourceDetail
extends java.lang.Object
implements hudson.model.ModelObject

Renders a source file containing an annotation for the whole file or a specific line number.

Author:
Ulli Hafner

Field Summary
protected static int SOURCE_GENERATOR_OFFSET
          Offset of the source code generator.
 
Constructor Summary
SourceDetail(hudson.model.AbstractBuild<?,?> owner, FileAnnotation annotation, java.lang.String defaultEncoding)
          Creates a new instance of this source code object.
 
Method Summary
 java.lang.String getDisplayName()
          
 java.lang.String getFileName()
          Gets the file name of this source file.
 hudson.model.AbstractBuild<?,?> getOwner()
          Returns the build as owner of this object.
 java.lang.String getSourceCode()
          Returns the line that should be highlighted.
 java.lang.String highlightSource(java.io.InputStream file)
          Highlights the specified source and returns the result as an HTML string.
 void splitSourceFile(java.lang.String sourceFile)
          Splits the source code into three blocks: the line to highlight and the source code before and after this line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOURCE_GENERATOR_OFFSET

protected static final int SOURCE_GENERATOR_OFFSET
Offset of the source code generator. After this line the actual source file lines start.

See Also:
Constant Field Values
Constructor Detail

SourceDetail

public SourceDetail(hudson.model.AbstractBuild<?,?> owner,
                    FileAnnotation annotation,
                    java.lang.String defaultEncoding)
Creates a new instance of this source code object.

Parameters:
owner - the current build as owner of this object
annotation - the warning to display in the source file
defaultEncoding - the default encoding to be used when reading and parsing files
Method Detail

getDisplayName

public java.lang.String getDisplayName()

Specified by:
getDisplayName in interface hudson.model.ModelObject

highlightSource

public final java.lang.String highlightSource(java.io.InputStream file)
                                       throws java.io.IOException
Highlights the specified source and returns the result as an HTML string.

Parameters:
file - the source file to highlight
Returns:
the source as an HTML string
Throws:
java.io.IOException

splitSourceFile

public final void splitSourceFile(java.lang.String sourceFile)
Splits the source code into three blocks: the line to highlight and the source code before and after this line.

Parameters:
sourceFile - the source code of the whole file as rendered HTML string

getFileName

public java.lang.String getFileName()
Gets the file name of this source file.

Returns:
the file name

getOwner

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

Returns:
the build

getSourceCode

public java.lang.String getSourceCode()
Returns the line that should be highlighted.

Returns:
the line to highlight


Copyright © 2009. All Rights Reserved.