jdepend.framework
Class JavaSourceFileParser

java.lang.Object
  extended by jdepend.framework.AbstractParser
      extended by jdepend.framework.JavaSourceFileParser

public class JavaSourceFileParser
extends AbstractParser

The JavaSourceFileParser class is responsible for parsing a Java source file to create a JavaClass instance.

Author:
Mike Clark, Clarkware Consulting, Inc.

Field Summary
 
Fields inherited from class jdepend.framework.AbstractParser
DEBUG
 
Constructor Summary
JavaSourceFileParser()
          Constructs a JavaSourceFileParser instance with the default package filter.
JavaSourceFileParser(PackageFilter filter)
          Constructs a JavaSourceFileParser instance with the specified package filter.
 
Method Summary
protected  void addClassName(JavaClass jClass, java.lang.String line)
          Adds the class name represented in the specified line to the specified class.
protected  void addImport(JavaClass jClass, java.lang.String line)
          Adds the import represented in the specified line to the specified class.
protected  void addInterfaceName(JavaClass jClass, java.lang.String line)
          Adds the interface name represented in the specified line to the specified class.
protected  void addPackageName(JavaClass jClass, java.lang.String line)
          Adds the package name represented in the specified line to the specified class.
protected  int getClassModifierIndex(java.lang.String line)
          Returns the index of the class modifier pattern in the specified line.
protected  boolean hasAbstractPattern(java.lang.String line)
          Indicates whether the specified line contains an abstract pattern.
protected  boolean hasClassModifier(java.lang.String line)
          Indicates whether the specified line contains a class modifier pattern.
protected  boolean hasClassPattern(java.lang.String line)
          Indicates whether the specified line contains a class pattern.
protected  boolean hasCommentPattern(java.lang.String line)
          Indicates whether the specified line contains a comment pattern or is commented.
protected  boolean hasImportPattern(java.lang.String line)
          Indicates whether the specified line contains an import pattern.
protected  boolean hasInterfacePattern(java.lang.String line)
          Indicates whether the specified line contains an interface pattern.
protected  boolean hasPackagePattern(java.lang.String line)
          Indicates whether the specified line contains a package pattern.
protected  boolean isCommentTrailing(java.lang.String line, int commentIndex)
          Indicates whether the specified line contains a trailing comment for a class or interface declaration.
protected  void markAbstract(JavaClass jClass)
          Marks the specified class as being abstract.
 JavaClass parse(java.lang.String filename)
          Parses the specified Java source file and returns a representative JavaClass instance.
protected  java.lang.String parseClassName(java.lang.String line)
          Returns the class name in the specified line.
protected  java.lang.String parseImport(java.lang.String line)
          Returns the import name in the specified line.
protected  java.lang.String parseInterfaceName(java.lang.String line)
          Returns the interface name in the specified line.
protected  java.lang.String parsePackageName(java.lang.String line)
          Returns the package name in the specified line.
 
Methods inherited from class jdepend.framework.AbstractParser
addParseListener, debug, getFilter, onParsedJavaClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaSourceFileParser

public JavaSourceFileParser()
Constructs a JavaSourceFileParser instance with the default package filter.


JavaSourceFileParser

public JavaSourceFileParser(PackageFilter filter)
Constructs a JavaSourceFileParser instance with the specified package filter.

Parameters:
filter - Package filter.
Method Detail

parse

public JavaClass parse(java.lang.String filename)
                throws java.io.IOException
Parses the specified Java source file and returns a representative JavaClass instance.

Registered parser listeners are informed that the resulting JavaClass was parsed.

Specified by:
parse in class AbstractParser
Parameters:
filename - Java source file name.
Returns:
Java class.
Throws:
java.io.IOException - If the file could not be parsed.

hasCommentPattern

protected boolean hasCommentPattern(java.lang.String line)
Indicates whether the specified line contains a comment pattern or is commented.

Parameters:
line - Line to test.
Returns:
true if the pattern exists; false otherwise.

isCommentTrailing

protected boolean isCommentTrailing(java.lang.String line,
                                    int commentIndex)
Indicates whether the specified line contains a trailing comment for a class or interface declaration.

Parameters:
line - Line to test.
commentIndex - Index of comment.
Returns:
true if the pattern exists; false otherwise.

hasPackagePattern

protected boolean hasPackagePattern(java.lang.String line)
Indicates whether the specified line contains a package pattern.

Parameters:
line - Line to test.
Returns:
true if the pattern exists; false otherwise.

addPackageName

protected void addPackageName(JavaClass jClass,
                              java.lang.String line)
Adds the package name represented in the specified line to the specified class.

Parameters:
jClass - Class.
line - Line containing package pattern.

parsePackageName

protected java.lang.String parsePackageName(java.lang.String line)
Returns the package name in the specified line.

Parameters:
line - Line containing pattern.
Returns:
Package name.

hasImportPattern

protected boolean hasImportPattern(java.lang.String line)
Indicates whether the specified line contains an import pattern.

Parameters:
line - Line to test.
Returns:
true if the pattern exists; false otherwise.

addImport

protected void addImport(JavaClass jClass,
                         java.lang.String line)
Adds the import represented in the specified line to the specified class.

Parameters:
jClass - Class.
line - Line containing import pattern.

parseImport

protected java.lang.String parseImport(java.lang.String line)
Returns the import name in the specified line.

Parameters:
line - Line containing pattern.
Returns:
Import name.

hasClassPattern

protected boolean hasClassPattern(java.lang.String line)
Indicates whether the specified line contains a class pattern.

Parameters:
line - Line to test.
Returns:
true if the pattern exists; false otherwise.

addClassName

protected void addClassName(JavaClass jClass,
                            java.lang.String line)
Adds the class name represented in the specified line to the specified class.

Parameters:
jClass - Class.
line - Line containing class pattern.

parseClassName

protected java.lang.String parseClassName(java.lang.String line)
Returns the class name in the specified line.

Parameters:
line - Line containing pattern.
Returns:
Class name.

hasInterfacePattern

protected boolean hasInterfacePattern(java.lang.String line)
Indicates whether the specified line contains an interface pattern.

Parameters:
line - Line to test.
Returns:
true if the pattern exists; false otherwise.

addInterfaceName

protected void addInterfaceName(JavaClass jClass,
                                java.lang.String line)
Adds the interface name represented in the specified line to the specified class.

Parameters:
jClass - Class.
line - Line containing interface pattern.

parseInterfaceName

protected java.lang.String parseInterfaceName(java.lang.String line)
Returns the interface name in the specified line.

Parameters:
line - Line containing pattern.
Returns:
Interface name.

hasAbstractPattern

protected boolean hasAbstractPattern(java.lang.String line)
Indicates whether the specified line contains an abstract pattern.

Parameters:
line - Line to test.
Returns:
true if the pattern exists; false otherwise.

markAbstract

protected void markAbstract(JavaClass jClass)
Marks the specified class as being abstract.

Parameters:
jClass - Class.

hasClassModifier

protected boolean hasClassModifier(java.lang.String line)
Indicates whether the specified line contains a class modifier pattern.

Parameters:
line - Line to test.
Returns:
true if the pattern exists; false otherwise.

getClassModifierIndex

protected int getClassModifierIndex(java.lang.String line)
Returns the index of the class modifier pattern in the specified line.

Parameters:
line - Line to test.
Returns:
Pattern index, or -1 if the pattern was not found.


Copyright ? 1999-2002 Clarkware Consulting, Inc. All Rights Reserved.