jdepend.framework.AbstractParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jdepend Show documentation
Show all versions of jdepend Show documentation
A fork to the jdepend project which applies bugfixes.
package jdepend.framework;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
/**
* The AbstractParser
class is the base class
* for classes capable of parsing files to create a
* JavaClass
instance.
*
* @author Mike Clark
* @author Clarkware Consulting, Inc.
*/
public abstract class AbstractParser {
private List parseListeners;
private PackageFilter filter;
public static boolean DEBUG = false;
public AbstractParser() {
this(PackageFilter.all().excludingProperties());
}
public AbstractParser(PackageFilter filter) {
setFilter(filter);
parseListeners = new ArrayList();
}
public void addParseListener(ParserListener listener) {
parseListeners.add(listener);
}
/**
* Registered parser listeners are informed that the resulting
* JavaClass
was parsed.
*/
public abstract JavaClass parse(InputStream is) throws IOException;
/**
* Informs registered parser listeners that the specified
* JavaClass
was parsed.
*
* @param jClass Parsed Java class.
*/
protected void onParsedJavaClass(JavaClass jClass) {
for (ParserListener parseListener : parseListeners) {
parseListener.onParsedJavaClass(jClass);
}
}
protected PackageFilter getFilter() {
if (filter == null) {
setFilter(PackageFilter.all().excludingProperties());
}
return filter;
}
protected void setFilter(PackageFilter filter) {
this.filter = filter;
}
protected void debug(String message) {
if (DEBUG) {
System.err.println(message);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy