org.gmetrics.source
Interface SourceCode

All Known Implementing Classes:
AbstractSourceCode, SourceFile, SourceString

public interface SourceCode

Represents a unit of source code to be analyzed

Version:
$Revision: 24 $ - $Date: 2009-12-10 21:17:05 -0500 (Thu, 10 Dec 2009) $
Author:
Chris Mair

Method Summary
 org.codehaus.groovy.ast.ModuleNode getAst()
          Return the Groovy AST (Abstract Syntax Tree) for this source file
 int getLineNumberForCharacterIndex(int charIndex)
          Return the line index for the line containing the character at the specified index within the source code.
 java.util.List getLines()
           
 java.lang.String getName()
          Get the logical name for this source code.
 java.lang.String getPath()
          Get the logical path for this source code.
 java.lang.String getText()
           
 java.lang.String line(int lineNumber)
          Get the trimmed line at the specified index
 

Method Detail

getName

java.lang.String getName()
Get the logical name for this source code. If this object is a file, then the name is the filename, without a path.

Returns:
the name for this source; may be null

getPath

java.lang.String getPath()
Get the logical path for this source code. If this object is a file, then the name is the full path in the filesystem. File separators are normalized to forward slash (/).

Returns:
the name for this source; may be null

getText

java.lang.String getText()
Returns:
the full text of the source code

getLines

java.util.List getLines()
Returns:
the List of lines of the source code (with line terminators removed)

line

java.lang.String line(int lineNumber)
Get the trimmed line at the specified index

Parameters:
lineNumber - - the line number; may be negative
Returns:
the trimmed line at the specified index, or null if lineNumber is not valid

getAst

org.codehaus.groovy.ast.ModuleNode getAst()
Return the Groovy AST (Abstract Syntax Tree) for this source file

Returns:
the ModuleNode representing the AST for this source file

getLineNumberForCharacterIndex

int getLineNumberForCharacterIndex(int charIndex)
Return the line index for the line containing the character at the specified index within the source code.

Parameters:
charIndex - - the index of the character within the source code (zero-based)
Returns:
the line number (one-based) containing the specified character; Return -1 if charIndex is not valid.


Copyright © 2010. All Rights Reserved.