public class JavaSourceFileParser extends AbstractParser
JavaSourceFileParser
class is responsible
for parsing a Java source file to create a JavaClass
instance.DEBUG
Constructor and Description |
---|
JavaSourceFileParser()
Constructs a
JavaSourceFileParser instance
with the default package filter. |
JavaSourceFileParser(PackageFilter filter)
Constructs a
JavaSourceFileParser instance
with the specified package filter. |
Modifier and Type | Method and Description |
---|---|
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.
|
addParseListener, debug, getFilter, onParsedJavaClass
public JavaSourceFileParser()
JavaSourceFileParser
instance
with the default package filter.public JavaSourceFileParser(PackageFilter filter)
JavaSourceFileParser
instance
with the specified package filter.filter
- Package filter.public JavaClass parse(java.lang.String filename) throws java.io.IOException
JavaClass
instance.
Registered parser listeners are informed that the
resulting JavaClass
was parsed.
parse
in class AbstractParser
filename
- Java source file name.java.io.IOException
- If the file could not be parsed.protected boolean hasCommentPattern(java.lang.String line)
line
- Line to test.true
if the pattern exists;
false
otherwise.protected boolean isCommentTrailing(java.lang.String line, int commentIndex)
line
- Line to test.commentIndex
- Index of comment.true
if the pattern exists;
false
otherwise.protected boolean hasPackagePattern(java.lang.String line)
line
- Line to test.true
if the pattern exists;
false
otherwise.protected void addPackageName(JavaClass jClass, java.lang.String line)
jClass
- Class.line
- Line containing package pattern.protected java.lang.String parsePackageName(java.lang.String line)
line
- Line containing pattern.protected boolean hasImportPattern(java.lang.String line)
line
- Line to test.true
if the pattern exists;
false
otherwise.protected void addImport(JavaClass jClass, java.lang.String line)
jClass
- Class.line
- Line containing import pattern.protected java.lang.String parseImport(java.lang.String line)
line
- Line containing pattern.protected boolean hasClassPattern(java.lang.String line)
line
- Line to test.true
if the pattern exists;
false
otherwise.protected void addClassName(JavaClass jClass, java.lang.String line)
jClass
- Class.line
- Line containing class pattern.protected java.lang.String parseClassName(java.lang.String line)
line
- Line containing pattern.protected boolean hasInterfacePattern(java.lang.String line)
line
- Line to test.true
if the pattern exists;
false
otherwise.protected void addInterfaceName(JavaClass jClass, java.lang.String line)
jClass
- Class.line
- Line containing interface pattern.protected java.lang.String parseInterfaceName(java.lang.String line)
line
- Line containing pattern.protected boolean hasAbstractPattern(java.lang.String line)
line
- Line to test.true
if the pattern exists;
false
otherwise.protected void markAbstract(JavaClass jClass)
jClass
- Class.protected boolean hasClassModifier(java.lang.String line)
line
- Line to test.true
if the pattern exists;
false
otherwise.protected int getClassModifierIndex(java.lang.String line)
line
- Line to test.Copyright ? 1999-2002 Clarkware Consulting, Inc. All Rights Reserved.