org.gmetrics.source
Class AbstractSourceCode

java.lang.Object
  extended by org.gmetrics.source.AbstractSourceCode
All Implemented Interfaces:
groovy.lang.GroovyObject, SourceCode
Direct Known Subclasses:
SourceFile, SourceString

public abstract class AbstractSourceCode
extends java.lang.Object
implements groovy.lang.GroovyObject, SourceCode

Abstract superclass for SourceCode implementations

Version:
$Revision: 32 $ - $Date: 2009-12-15 21:37:46 -0500 (Tue, 15 Dec 2009) $
Author:
Chris Mair

Constructor Summary
AbstractSourceCode()
           
 
Method Summary
protected abstract  java.lang.Object createSourceUnit()
           
 org.codehaus.groovy.ast.ModuleNode getAst()
          Return the Groovy AST (Abstract Syntax Tree) for this source file
static java.lang.Object getFILE_SEPARATOR()
           
 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()
           
static java.lang.Object getLOG()
           
 groovy.lang.MetaClass getMetaClass()
           
 java.lang.Object getProperty(java.lang.String name)
           
 java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args)
           
 java.lang.String line(int lineNumber)
          Get the trimmed line at the specified index
protected  java.lang.String normalizePath(java.lang.String path)
          Return the normalized value of the specified path.
 void setMetaClass(groovy.lang.MetaClass metaClass)
           
 void setProperty(java.lang.String name, java.lang.Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.gmetrics.source.SourceCode
getName, getPath, getText
 

Constructor Detail

AbstractSourceCode

public AbstractSourceCode()
Method Detail

getLOG

public static final java.lang.Object getLOG()

getFILE_SEPARATOR

public static final java.lang.Object getFILE_SEPARATOR()

createSourceUnit

protected abstract java.lang.Object createSourceUnit()

getLines

public java.util.List getLines()
Specified by:
getLines in interface SourceCode
Returns:
the List of lines of the source code (with line terminators removed)

line

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

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

getAst

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

Specified by:
getAst in interface SourceCode
Returns:
the ModuleNode representing the AST for this source file

getLineNumberForCharacterIndex

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

Specified by:
getLineNumberForCharacterIndex in interface SourceCode
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.

normalizePath

protected java.lang.String normalizePath(java.lang.String path)
Return the normalized value of the specified path. Convert file separator chars to standard '/'.

Parameters:
path - - the path to normalize
Returns:
the normalized value

getMetaClass

public groovy.lang.MetaClass getMetaClass()
Specified by:
getMetaClass in interface groovy.lang.GroovyObject

setMetaClass

public void setMetaClass(groovy.lang.MetaClass metaClass)
Specified by:
setMetaClass in interface groovy.lang.GroovyObject

invokeMethod

public java.lang.Object invokeMethod(java.lang.String name,
                                     java.lang.Object args)
Specified by:
invokeMethod in interface groovy.lang.GroovyObject

getProperty

public java.lang.Object getProperty(java.lang.String name)
Specified by:
getProperty in interface groovy.lang.GroovyObject

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
Specified by:
setProperty in interface groovy.lang.GroovyObject


Copyright © 2010. All Rights Reserved.