javancss
Class Javancss

java.lang.Object
  extended by javancss.Javancss
All Implemented Interfaces:
ccl.util.Exitable

public class Javancss
extends java.lang.Object
implements ccl.util.Exitable

While the Java parser class might be the heart of JavaNCSS, this class is the brain. This class controls input and output and invokes the Java parser.

Version:
$Id: Javancss.java 121 2009-01-17 22:19:45Z hboutemy $
Author:
Chr. Clemens Lee , recursive feature by P??k? Hannu , additional javadoc metrics by Emilio Gongora , and Guillermo Rodriguez .

Field Summary
private  java.lang.Object[] _aoPackage
           
private  boolean _bExit
           
private  boolean _bXML
           
private  java.util.Map _htPackages
           
private  int _loc
           
private  int _ncss
           
private  ccl.util.Init _pInit
           
private  JavaParser _pJavaParser
           
private  java.lang.String _sErrorMessage
           
private  java.io.File _sJavaSourceFile
          Just used for parseImports.
private  java.lang.Throwable _thrwError
           
private  java.util.List _vFunctionMetrics
           
private  java.util.List _vImports
           
private  java.util.List _vJavaSourceFiles
           
private  java.util.List _vObjectMetrics
           
private  java.util.List _vPackageMetrics
           
private  java.lang.String encoding
           
private static java.lang.String S_INIT__FILE_CONTENT
           
 
Constructor Summary
Javancss()
          Only way to create object that does not immediately start to parse.
Javancss(java.io.File sJavaSourceFile_)
           
Javancss(java.util.List vJavaSourceFiles_)
           
Javancss(java.io.Reader reader)
           
Javancss(java.lang.String[] asArgs_, java.lang.String sRcsHeader_)
          This is the constructor used in the main routine in javancss.Main.
 
Method Summary
private static void _addJavaFiles(java.io.File dir, java.util.List v)
          recursively adds *.java files
private  void _measureFiles(java.util.List vJavaSourceFiles_)
           
private  void _measureRoot(java.io.Reader reader)
          If arguments were provided, they are used, otherwise the input stream is used.
private  void _measureSource(java.io.File sSourceFile_)
           
private  void _measureSource(java.io.Reader reader)
           
private  java.io.Reader createSourceReader(java.io.File sSourceFile_)
           
private  java.util.List findFiles(java.util.List filenames, boolean recursive)
           
 java.lang.String getEncoding()
           
 Formatter getFormatter()
           
 java.util.List getFunctionMetrics()
           
 java.util.List getFunctions()
          The same as getFunctionMetrics?!
 java.util.List getImports()
           
 int getJdcl()
          JDCL stands for javadoc comment lines (while jvdc stands for number of javadoc comments).
 int getJvdc()
           
 java.lang.Throwable getLastError()
           
 java.lang.String getLastErrorMessage()
           
 int getLOC()
           
 int getMl()
           
 int getNcss()
           
 java.util.List getObjectMetrics()
           
 java.lang.Object[] getPackage()
          Return info about package statement.
 java.util.List getPackageMetrics()
          Returns list of packages in the form PackageMetric objects.
 int getSl()
           
private  java.io.Reader newReader(java.io.File file)
           
private  java.io.Reader newReader(java.io.InputStream stream)
           
 boolean parseImports()
           
 java.lang.String printFunctionNcss()
           
 java.lang.String printJavaNcss()
           
 java.lang.String printObjectNcss()
           
 java.lang.String printPackageNcss()
           
 void setEncoding(java.lang.String encoding)
           
 void setExit()
           
 void setSourceFile(java.io.File javaSourceFile_)
           
 void setXML(boolean bXML)
           
 boolean useXML()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

S_INIT__FILE_CONTENT

private static final java.lang.String S_INIT__FILE_CONTENT
See Also:
Constant Field Values

_bExit

private boolean _bExit

_vJavaSourceFiles

private java.util.List _vJavaSourceFiles

encoding

private java.lang.String encoding

_sErrorMessage

private java.lang.String _sErrorMessage

_thrwError

private java.lang.Throwable _thrwError

_pJavaParser

private JavaParser _pJavaParser

_ncss

private int _ncss

_loc

private int _loc

_vFunctionMetrics

private java.util.List _vFunctionMetrics

_vObjectMetrics

private java.util.List _vObjectMetrics

_vPackageMetrics

private java.util.List _vPackageMetrics

_vImports

private java.util.List _vImports

_htPackages

private java.util.Map _htPackages

_aoPackage

private java.lang.Object[] _aoPackage

_sJavaSourceFile

private java.io.File _sJavaSourceFile
Just used for parseImports.


_pInit

private ccl.util.Init _pInit

_bXML

private boolean _bXML
Constructor Detail

Javancss

public Javancss(java.util.List vJavaSourceFiles_)

Javancss

public Javancss(java.io.File sJavaSourceFile_)

Javancss

public Javancss()
Only way to create object that does not immediately start to parse.


Javancss

public Javancss(java.io.Reader reader)

Javancss

public Javancss(java.lang.String[] asArgs_,
                java.lang.String sRcsHeader_)
         throws java.io.IOException
This is the constructor used in the main routine in javancss.Main. Other constructors might be helpful to use Javancss out of other programs.

Throws:
java.io.IOException
Method Detail

createSourceReader

private java.io.Reader createSourceReader(java.io.File sSourceFile_)

_measureSource

private void _measureSource(java.io.File sSourceFile_)
                     throws java.io.IOException,
                            ParseException,
                            TokenMgrError
Throws:
java.io.IOException
ParseException
TokenMgrError

_measureSource

private void _measureSource(java.io.Reader reader)
                     throws java.io.IOException,
                            ParseException,
                            TokenMgrError
Throws:
java.io.IOException
ParseException
TokenMgrError

_measureFiles

private void _measureFiles(java.util.List vJavaSourceFiles_)
                    throws java.io.IOException,
                           ParseException,
                           TokenMgrError
Throws:
java.io.IOException
ParseException
TokenMgrError

_measureRoot

private void _measureRoot(java.io.Reader reader)
                   throws java.io.IOException,
                          ParseException,
                          TokenMgrError
If arguments were provided, they are used, otherwise the input stream is used.

Throws:
java.io.IOException
ParseException
TokenMgrError

getImports

public java.util.List getImports()

getPackage

public java.lang.Object[] getPackage()
Return info about package statement. First element has name of package, then begin of line, etc.


getFunctions

public java.util.List getFunctions()
The same as getFunctionMetrics?!


printObjectNcss

public java.lang.String printObjectNcss()

printFunctionNcss

public java.lang.String printFunctionNcss()

printPackageNcss

public java.lang.String printPackageNcss()

printJavaNcss

public java.lang.String printJavaNcss()

parseImports

public boolean parseImports()

setSourceFile

public void setSourceFile(java.io.File javaSourceFile_)

_addJavaFiles

private static void _addJavaFiles(java.io.File dir,
                                  java.util.List v)
recursively adds *.java files

Parameters:
dir - the base directory to search
v - the list of file to add found files to

findFiles

private java.util.List findFiles(java.util.List filenames,
                                 boolean recursive)
                          throws java.io.IOException
Throws:
java.io.IOException

getNcss

public int getNcss()

getLOC

public int getLOC()

getJvdc

public int getJvdc()

getJdcl

public int getJdcl()
JDCL stands for javadoc comment lines (while jvdc stands for number of javadoc comments).


getSl

public int getSl()

getMl

public int getMl()

getFunctionMetrics

public java.util.List getFunctionMetrics()

getObjectMetrics

public java.util.List getObjectMetrics()

getPackageMetrics

public java.util.List getPackageMetrics()
Returns list of packages in the form PackageMetric objects.


getLastErrorMessage

public java.lang.String getLastErrorMessage()

getLastError

public java.lang.Throwable getLastError()

setExit

public void setExit()
Specified by:
setExit in interface ccl.util.Exitable

setXML

public void setXML(boolean bXML)

useXML

public boolean useXML()

getFormatter

public Formatter getFormatter()

getEncoding

public java.lang.String getEncoding()

setEncoding

public void setEncoding(java.lang.String encoding)

newReader

private java.io.Reader newReader(java.io.InputStream stream)
                          throws java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException

newReader

private java.io.Reader newReader(java.io.File file)
                          throws java.io.FileNotFoundException,
                                 java.io.UnsupportedEncodingException
Throws:
java.io.FileNotFoundException
java.io.UnsupportedEncodingException