de.rwth.utils
Class AbstractClassProcessor

java.lang.Object
  |
  +--de.rwth.utils.AbstractClassProcessor
Direct Known Subclasses:
AbstractAnalyser

public abstract class AbstractClassProcessor
extends java.lang.Object

An abstract class for building applications which can process the methods in a class file based on BCEL. It does command line processing.

Version:
$Id: AbstractClassProcessor.java,v 1.4 2002/09/17 06:53:53 mohnen Exp $
Author:
Markus Mohnen

Field Summary
protected  java.io.File file
          The file to process.
protected  java.util.Collection flags
          The flags detected by this processor.
 
Constructor Summary
AbstractClassProcessor(java.lang.String[] args, java.util.Collection validFlags)
          Creates a new AbstractClassProcessor instance.
 
Method Summary
 void process()
          Processes the file.
abstract  void process(de.fub.bytecode.classfile.JavaClass jclass, java.lang.String filename)
          Supposed to process a BCEL class data structure.
 void usage(java.lang.String[] args, int conflictIndex, java.lang.String errorText, java.util.Collection validFlags)
          Prints a usage message to standard error and exits.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

flags

protected java.util.Collection flags
The flags detected by this processor.

file

protected java.io.File file
The file to process.
Constructor Detail

AbstractClassProcessor

public AbstractClassProcessor(java.lang.String[] args,
                              java.util.Collection validFlags)
Creates a new AbstractClassProcessor instance. Prints an error message if the command line is not of the form '[options] file'. Otherwise, it sets the flags and the file according to the command line. Implementations must override process() and call it.
Parameters:
args - a String[] value: The command line arguments.
validFlags - a Collection value: A set containing the base names of options, i.e. "v" for "-v".
Method Detail

usage

public void usage(java.lang.String[] args,
                  int conflictIndex,
                  java.lang.String errorText,
                  java.util.Collection validFlags)
Prints a usage message to standard error and exits.
Parameters:
args - a String[] value
conflictIndex - an int value
errorText - a String value
validFlags - a Collection value

process

public void process()
             throws java.io.FileNotFoundException,
                    java.io.IOException
Processes the file. It opens a FileInputStream, parses the class file using BCEL and passes control to process(JavaClass,String).
Throws:
java.io.FileNotFoundException - if an error occurs
java.io.IOException - if an error occurs

process

public abstract void process(de.fub.bytecode.classfile.JavaClass jclass,
                             java.lang.String filename)
Supposed to process a BCEL class data structure.
Parameters:
jclass - a JavaClass value
filename - a String value