public abstract class OfflineInstrumenterBase extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
OfflineInstrumenterBase.ManifestBuilder
Thiscallback is notified whenever an entry has been added to the output zip file.
|
Modifier and Type | Field and Description |
---|---|
protected ClassHierarchyProvider |
cha |
Modifier | Constructor and Description |
---|---|
protected |
OfflineInstrumenterBase() |
Modifier and Type | Method and Description |
---|---|
void |
addInputClass(File baseDirectory,
File f)
Add a class file containing a source class to instrument.
|
void |
addInputDirectory(File baseDirectory,
File d)
Add a directory containing class files to instrument.
|
boolean |
addInputElement(File baseDirectory,
String a)
Add something to instrument --- the name of a JAR file, a class file, a directory or an entry within a jar file (as
filename#entryname).
|
void |
addInputJar(File f)
Add a JAR file containing source classes to instrument.
|
void |
addInputJarEntry(File f,
String name)
Add a JAR entry containing a source class to instrument.
|
OutputStream |
addOutputJarEntry(ZipEntry ze)
Add a raw ZipEntry to the output JAR.
|
void |
beginTraversal()
Start traversing the source class list from the beginning.
|
void |
close()
Call this when you're done modifying classes.
|
static void |
copyStream(InputStream in,
OutputStream out) |
void |
endOutputJarEntry()
Complete and flush the entry initiated by addOutputJarEntry.
|
protected abstract String |
getClassName(Object cl) |
String |
getLastClassResourceName()
Get the name of the resource containing the last class returned.
|
int |
getNumInputClasses() |
File |
getOutputFile()
Returns the File we are storing classes into.
|
protected Object |
internalNextClass() |
protected boolean |
internalOutputModifiedClass(Object cf,
String name,
Object mods) |
protected abstract Object |
makeClassFromStream(String inputName,
BufferedInputStream s) |
String[] |
parseStandardArgs(String[] args)
Parse an argument list to find elements to instrument and the name of the output file.
|
void |
setClassHierarchyProvider(ClassHierarchyProvider cha) |
void |
setIgnore(boolean ignore)
Skip the last class returned in every future traversal of the class list.
|
void |
setJARComment(String comment)
Set the JAR Comment for the output JAR.
|
void |
setManifestBuilder(OfflineInstrumenterBase.ManifestBuilder mb)
This installs a ManifestBuilder callback that this class will notify whenever an entry has been added to the output zip file.
|
void |
setOutputJar(File f)
Set the file in which instrumented classes will be deposited.
|
void |
setPassUnmodifiedClasses(boolean pass)
Indicate whether classes which are not modified will be put into the output jar anyway.
|
protected abstract void |
writeClassTo(Object cl,
Object mods,
OutputStream s) |
void |
writeUnmodifiedClasses()
Call this to copy any unmodified classes to the output.
|
protected ClassHierarchyProvider cha
public void setManifestBuilder(OfflineInstrumenterBase.ManifestBuilder mb)
public void setClassHierarchyProvider(ClassHierarchyProvider cha)
public final void setOutputJar(File f)
public final void setPassUnmodifiedClasses(boolean pass)
public final void addInputJar(File f) throws IOException
IOException
public final void addInputJarEntry(File f, String name) throws IOException
IOException
public final void addInputClass(File baseDirectory, File f)
public final void addInputDirectory(File baseDirectory, File d) throws IOException, IllegalArgumentException
IllegalArgumentException
- if d is nullIOException
public final boolean addInputElement(File baseDirectory, String a) throws IOException
IllegalArgumentException
- if a is nullIOException
public final String[] parseStandardArgs(String[] args) throws IllegalArgumentException, IOException
IllegalArgumentException
- if args == nullIOException
public final int getNumInputClasses()
public final void beginTraversal()
protected abstract Object makeClassFromStream(String inputName, BufferedInputStream s) throws IOException
IOException
protected abstract void writeClassTo(Object cl, Object mods, OutputStream s) throws IOException
IOException
protected final Object internalNextClass() throws IOException
IOException
public final String getLastClassResourceName()
public final File getOutputFile()
protected final boolean internalOutputModifiedClass(Object cf, String name, Object mods) throws IOException
IOException
public final void setJARComment(String comment) throws IOException, IllegalStateException
IOException
IllegalStateException
public final void setIgnore(boolean ignore) throws IllegalArgumentException
IllegalArgumentException
public static void copyStream(InputStream in, OutputStream out) throws IllegalArgumentException, IOException
IllegalArgumentException
IOException
public final OutputStream addOutputJarEntry(ZipEntry ze) throws IOException, IllegalStateException
IOException
IllegalStateException
public final void endOutputJarEntry() throws IOException, IllegalStateException
IOException
IllegalStateException
public final void writeUnmodifiedClasses() throws IOException, IllegalStateException
IOException
IllegalStateException
public final void close() throws IOException, IllegalStateException
IOException
IllegalStateException