org.gmetrics.source
Class SourceString

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

public class SourceString
extends AbstractSourceCode
implements groovy.lang.GroovyObject

SourceCode implementation that uses source from a pre-defined String. Note that the path is normalized: file separator chars are normalized to standard '/'.

Version:
$Revision: 29 $ - $Date: 2009-12-13 15:50:29 -0500 (Sun, 13 Dec 2009) $
Author:
Chris Mair

Constructor Summary
SourceString(java.lang.String source, java.lang.String path, java.lang.String name)
          Construct a new instance for the file at the specified path
 
Method Summary
protected  java.lang.Object createSourceUnit()
           
 groovy.lang.MetaClass getMetaClass()
           
 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.Object getProperty(java.lang.String name)
           
 java.lang.String getText()
           
 java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args)
           
 void setMetaClass(groovy.lang.MetaClass metaClass)
           
 void setName(java.lang.String value)
           
 void setPath(java.lang.String path)
           
 void setProperty(java.lang.String name, java.lang.Object value)
           
 java.lang.String toString()
           
 
Methods inherited from class org.gmetrics.source.AbstractSourceCode
getAst, getFILE_SEPARATOR, getLineNumberForCharacterIndex, getLines, getLOG, line, normalizePath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SourceString

public SourceString(java.lang.String source,
                    java.lang.String path,
                    java.lang.String name)
Construct a new instance for the file at the specified path

Parameters:
source - - the source; must not be null or empty
path - - the path for the source code; may be null; defaults to null
name - - the name for the source code; may be null; defaults to null
Method Detail

getPath

public java.lang.String getPath()
Description copied from interface: SourceCode
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 (/).

Specified by:
getPath in interface SourceCode
Returns:
the name for this source; may be null

getName

public java.lang.String getName()
Description copied from interface: SourceCode
Get the logical name for this source code. If this object is a file, then the name is the filename, without a path.

Specified by:
getName in interface SourceCode
Returns:
the name for this source; may be null

setName

public void setName(java.lang.String value)

getText

public java.lang.String getText()
Specified by:
getText in interface SourceCode
Returns:
the full text of the source code

setPath

public void setPath(java.lang.String path)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

createSourceUnit

protected java.lang.Object createSourceUnit()
Specified by:
createSourceUnit in class AbstractSourceCode

getMetaClass

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

setMetaClass

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

invokeMethod

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

getProperty

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

setProperty

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


Copyright © 2010. All Rights Reserved.