Browse Source

checkstyle - mostly javadoc

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278358 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 20 years ago
parent
commit
6a659a85b7
18 changed files with 588 additions and 161 deletions
  1. +8
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/DefaultJspCompilerAdapter.java
  2. +8
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java
  3. +3
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JspCompilerAdapter.java
  4. +4
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JspCompilerAdapterFactory.java
  5. +26
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovBase.java
  6. +21
    -5
      src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java
  7. +45
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java
  8. +62
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Coverage.java
  9. +33
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Filters.java
  10. +34
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/sitraka/ReportFilters.java
  11. +7
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Socket.java
  12. +33
    -19
      src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Triggers.java
  13. +82
    -10
      src/main/org/apache/tools/ant/taskdefs/optional/sitraka/XMLReport.java
  14. +45
    -20
      src/main/org/apache/tools/ant/taskdefs/optional/sitraka/bytecode/ClassFile.java
  15. +16
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/sitraka/bytecode/ClassPathLoader.java
  16. +60
    -7
      src/main/org/apache/tools/ant/taskdefs/optional/sitraka/bytecode/MethodInfo.java
  17. +89
    -75
      src/main/org/apache/tools/ant/taskdefs/optional/sitraka/bytecode/Utils.java
  18. +12
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/sitraka/bytecode/attributes/AttributeInfo.java

+ 8
- 4
src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/DefaultJspCompilerAdapter.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2001-2004 The Apache Software Foundation
* Copyright 2001-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,6 +38,9 @@ public abstract class DefaultJspCompilerAdapter
/**
* Logs the compilation parameters, adds the files to compile and logs the
* "niceSourceList"
* @param jspc the compiler task for logging
* @param compileList the list of files to compile
* @param cmd the command line used
*/
protected void logAndAddFilesToCompile(JspC jspc,
Vector compileList,
@@ -70,6 +73,7 @@ public abstract class DefaultJspCompilerAdapter

/**
* set the owner
* @param owner the owner JspC compiler
*/
public void setJspc(JspC owner) {
this.owner = owner;
@@ -85,7 +89,7 @@ public abstract class DefaultJspCompilerAdapter

/**
* add an argument oneple to the argument list, if the value aint null
*
* @param cmd the command line
* @param argument The argument
*/
protected void addArg(CommandlineJava cmd, String argument) {
@@ -97,7 +101,7 @@ public abstract class DefaultJspCompilerAdapter

/**
* add an argument tuple to the argument list, if the value aint null
*
* @param cmd the command line
* @param argument The argument
* @param value the parameter
*/
@@ -110,7 +114,7 @@ public abstract class DefaultJspCompilerAdapter

/**
* add an argument tuple to the arg list, if the file parameter aint null
*
* @param cmd the command line
* @param argument The argument
* @param file the parameter
*/


+ 8
- 2
src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java View File

@@ -41,12 +41,18 @@ public class JasperC extends DefaultJspCompilerAdapter {
*/
JspMangler mangler;

/**
* Constructor for JasperC.
* @param mangler a filename converter
*/
public JasperC(JspMangler mangler) {
this.mangler = mangler;
}

/**
* our execute method
* Our execute method.
* @return true if successful
* @throws BuildException on error
*/
public boolean execute()
throws BuildException {
@@ -69,7 +75,7 @@ public class JasperC extends DefaultJspCompilerAdapter {
java.setDir(getProject().getBaseDir());
java.setClassname("org.apache.jasper.JspC");
//this is really irritating; we need a way to set stuff
String args[] = cmd.getJavaCommand().getArguments();
String []args = cmd.getJavaCommand().getArguments();
for (int i = 0; i < args.length; i++) {
java.createArg().setValue(args[i]);
}


+ 3
- 1
src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JspCompilerAdapter.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2001-2004 The Apache Software Foundation
* Copyright 2001-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@ public interface JspCompilerAdapter {

/**
* Sets the compiler attributes, which are stored in the Jspc task.
* @param attributes the jsp compiler attributes
*/
void setJspc(JspC attributes);

@@ -43,6 +44,7 @@ public interface JspCompilerAdapter {
* Executes the task.
*
* @return has the compilation been successful
* @throws BuildException on error
*/
boolean execute() throws BuildException;



+ 4
- 2
src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JspCompilerAdapterFactory.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2001-2004 The Apache Software Foundation
* Copyright 2001-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ import org.apache.tools.ant.taskdefs.optional.jsp.Jasper41Mangler;
* Creates the necessary compiler adapter, given basic criteria.
*
*/
public class JspCompilerAdapterFactory {
public final class JspCompilerAdapterFactory {

/** This is a singleton -- can't create instances!! */
private JspCompilerAdapterFactory() {
@@ -46,6 +46,7 @@ public class JspCompilerAdapterFactory {
* @param compilerType either the name of the desired compiler, or the
* full classname of the compiler's adapter.
* @param task a task to log through.
* @return the compiler
* @throws BuildException if the compiler type could not be resolved into
* a compiler adapter.
*/
@@ -69,6 +70,7 @@ public class JspCompilerAdapterFactory {
* full classname of the compiler's adapter.
* @param task a task to log through.
* @param loader AntClassLoader with which the compiler should be loaded
* @return the compiler
* @throws BuildException if the compiler type could not be resolved into
* a compiler adapter.
*/


+ 26
- 0
src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovBase.java View File

@@ -36,15 +36,24 @@ public abstract class CovBase extends Task {

/**
* The directory where JProbe is installed.
* @param value the JProbe directory
*/
public void setHome(File value) {
this.home = value;
}

/**
* Get the JProbe directory.
* @return the JProbe directory
*/
protected File getHome() {
return home;
}

/**
* Get the location of the JProbe coverage jar file.
* @return the location of the JProbe coverage jar file
*/
protected File findCoverageJar() {
File loc = null;
if (isJProbe4) {
@@ -63,6 +72,11 @@ public abstract class CovBase extends Task {
return loc;
}

/**
* Find the JProbe executable.
* @param relativePath the name of the executuable without the trailing .exe on dos
* @return the absolute path to the executable
*/
protected String findExecutable(String relativePath) {
if (isDos) {
relativePath += ".exe";
@@ -84,16 +98,28 @@ public abstract class CovBase extends Task {
return loc.getAbsolutePath();
}

/**
* Create a temporary file.
* @param prefix a prefix to use in the filename
* @return a File reference to the temporary file
*/
protected File createTempFile(String prefix) {
return FILE_UTILS.createTempFile(prefix, ".tmp", null);
}

/**
* Get the param file arguement.
* This checks the version of jprobe to return the correct name of
* the parameter.
* @return the name of the argument
*/
protected String getParamFileArgument() {
return "-" + (!isJProbe4 ? "jp_" : "") + "paramfile=";
}

/**
* Are we running on a version of JProbe 4.x or higher?
* @return true if we are running JProbe 4 or higher
*/
protected boolean isJProbe4Plus() {
return isJProbe4;


+ 21
- 5
src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovMerge.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2001-2004 The Apache Software Foundation
* Copyright 2001-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,6 +47,7 @@ public class CovMerge extends CovBase {

/**
* Set the output snapshot file.
* @param value the snapshot file
*/
public void setTofile(File value) {
this.tofile = value;
@@ -55,6 +56,7 @@ public class CovMerge extends CovBase {
/**
* If true, perform the merge in verbose mode giving details
* about the snapshot processing.
* @param flag if true perform the merge in verbose mode
*/
public void setVerbose(boolean flag) {
this.verbose = flag;
@@ -62,6 +64,7 @@ public class CovMerge extends CovBase {

/**
* add a fileset containing the snapshots to include.
* @param fs nested fileset element
*/
public void addFileset(FileSet fs) {
filesets.addElement(fs);
@@ -69,10 +72,14 @@ public class CovMerge extends CovBase {

//---------------- the tedious job begins here

/** Constructor for CovMerge. */
public CovMerge() {
}

/** execute the jpcovmerge by providing a parameter file */
/**
* Execute the jpcovmerge by providing a parameter file.
* @throws BuildException on error
*/
public void execute() throws BuildException {
checkOptions();

@@ -112,7 +119,10 @@ public class CovMerge extends CovBase {
}
}

/** check for mandatory options */
/**
* Check for mandatory options.
* @throws BuildException on error
*/
protected void checkOptions() throws BuildException {
if (tofile == null) {
throw new BuildException("'tofile' attribute must be set.");
@@ -128,7 +138,10 @@ public class CovMerge extends CovBase {
}
}

/** get the snapshots from the filesets */
/**
* Get the snapshots from the filesets.
* @return an array of snapshot files
*/
protected File[] getSnapshots() {
Vector v = new Vector();
final int size = filesets.size();
@@ -152,8 +165,10 @@ public class CovMerge extends CovBase {


/**
* create the parameters file that contains all file to merge
* Create the parameters file that contains all file to merge
* and the output filename.
* @return the parameters file
* @throws BuildException on error
*/
protected File createParamFile() throws BuildException {
File[] snapshots = getSnapshots();
@@ -179,6 +194,7 @@ public class CovMerge extends CovBase {
try {
fw.close();
} catch (IOException ignored) {
// Ignore Exception
}
}
}


+ 45
- 3
src/main/org/apache/tools/ant/taskdefs/optional/sitraka/CovReport.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2001-2004 The Apache Software Foundation
* Copyright 2001-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -121,7 +121,9 @@ public class CovReport extends CovBase {
private Reference reference = null;


/** Enumerated type for format attribute. */
public static class ReportFormat extends EnumeratedAttribute {
/** @see EnumeratedAttribute@getValues() */
public String[] getValues() {
return new String[]{"html", "text", "xml"};
}
@@ -129,12 +131,15 @@ public class CovReport extends CovBase {

/**
* set the format of the report: "html", "text", or "xml"
* @param value an enumerated <code>ReportFormat</code> value
*/
public void setFormat(ReportFormat value) {
this.format = value.getValue();
}

/** Enumerated type for type attribute. */
public static class ReportType extends EnumeratedAttribute {
/** @see EnumeratedAttribute@getValues() */
public String[] getValues() {
return new String[]{"executive", "summary", "detailed", "verydetailed"};
}
@@ -143,6 +148,7 @@ public class CovReport extends CovBase {
/**
* The type of report to be generated: "executive", "summary",
* "detailed" or "verydetailed".
* @param value an enumerated <code>ReportType</code> value
*/
public void setType(ReportType value) {
this.type = value.getValue();
@@ -151,6 +157,7 @@ public class CovReport extends CovBase {
/**
* If true, include text of the source code lines.
* Only applies to format="xml" and type="verydetailed"
* @param value a <code>boolean</code> value
*/
public void setIncludesource(boolean value) {
this.includeSource = value;
@@ -159,6 +166,7 @@ public class CovReport extends CovBase {
/**
* A numeric value for the threshold for printing methods.
* Must be between 0 and 100.
* @param value an <code>Integer</code> value
*/
public void setPercent(Integer value) {
this.percent = value;
@@ -166,6 +174,7 @@ public class CovReport extends CovBase {

/**
* set the filters
* @param values a <code>String</code> value
* @ant.attribute ignore="true"
*/
public void setFilters(String values) {
@@ -174,6 +183,7 @@ public class CovReport extends CovBase {

/**
* Adds a path to source files.
* @return a path to be configured
*/
public Path createSourcepath() {
if (sourcePath == null) {
@@ -184,6 +194,7 @@ public class CovReport extends CovBase {

/**
* The name of the snapshot file that is the source to the report.
* @param value the snapshot file
*/
public void setSnapshot(File value) {
this.snapshot = value;
@@ -191,12 +202,14 @@ public class CovReport extends CovBase {

/**
* The name of the generated output file.
* @param value the output file
*/
public void setTofile(File value) {
this.tofile = value;
}

/**
* @return a path to be configured
* @todo needs to be removed
* @ant.element ignore="true"
*/
@@ -210,6 +223,7 @@ public class CovReport extends CovBase {
/**
* Adds a set of classes whose coverage information will be
* checked against.
* @return a <code>CovReport.Reference</code> object to be configured
*/
public Reference createReference() {
if (reference == null) {
@@ -219,10 +233,14 @@ public class CovReport extends CovBase {
}


/** Constructor for CovReport. */
public CovReport() {
}

/** check for mandatory options */
/**
* Check for mandatory options.
* @throws BuildException on error
*/
protected void checkOptions() throws BuildException {
if (tofile == null) {
throw new BuildException("'tofile' attribute must be set.");
@@ -244,6 +262,10 @@ public class CovReport extends CovBase {

}

/**
* Execute the task.
* @throws BuildException on error
*/
public void execute() throws BuildException {
checkOptions();
try {
@@ -278,6 +300,10 @@ public class CovReport extends CovBase {
}


/**
* Get the parameters for the executable.
* @return an array of parameters
*/
protected String[] getParameters() {
Vector v = new Vector();
if (format != null) {
@@ -311,10 +337,17 @@ public class CovReport extends CovBase {
}


/**
* An inner class for the reference element.
*/
public class Reference {
protected Path classPath;
protected ReportFilters filters;

/**
* Create a path for the reference.
* @return a path to be configured
*/
public Path createClasspath() {
if (classPath == null) {
classPath = new Path(CovReport.this.getProject());
@@ -322,6 +355,10 @@ public class CovReport extends CovBase {
return classPath.createPath();
}

/**
* An nested element to include/exclude classes/methods.
* @return ReportFilters to be configured
*/
public ReportFilters createFilters() {
if (filters == null) {
filters = new ReportFilters();
@@ -329,6 +366,10 @@ public class CovReport extends CovBase {
return filters;
}

/**
* Create the xml report.
* @throws BuildException on error
*/
protected void createEnhancedXMLReport() throws BuildException {
// we need a classpath element
if (classPath == null) {
@@ -337,7 +378,8 @@ public class CovReport extends CovBase {
// and a valid one...
String[] paths = classPath.list();
if (paths.length == 0) {
throw new BuildException("Coverage path is invalid. It does not contain any existing path.");
throw new BuildException(
"Coverage path is invalid. It does not contain any existing path.");
}
// and we need at least one filter include/exclude.
if (filters == null || filters.size() == 0) {


+ 62
- 4
src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Coverage.java View File

@@ -90,12 +90,17 @@ public class Coverage extends CovBase {

//--------- setters used via reflection --

/** seed name for snapshot file. Can be null, default to snap */
/**
* Set the seed name for snapshot file. Can be null, default to snap.
* @param value a <code>String</code> value
*/
public void setSeedname(String value) {
seedName = value;
}

/**
* Set the input file.
* @param value a <code>File</code> value
* @ant.attribute ignore="true"
*/
public void setInputfile(File value) {
@@ -104,12 +109,20 @@ public class Coverage extends CovBase {

/**
* Path to the java executable.
* @param value the path to the java executable
*/
public void setJavaexe(File value) {
javaExe = value;
}

/**
* Enumerated type corresponding to the javavms known by the task.
*/
public static class Javavm extends EnumeratedAttribute {
/**
* Get the valid javavms names.
* @return an array of strings = "java2", "jdk118", and "jdk117"
*/
public String[] getValues() {
return new String[]{"java2", "jdk118", "jdk117"};
}
@@ -117,13 +130,16 @@ public class Coverage extends CovBase {

/**
* Indicates which virtual machine to run: "jdk117", "jdk118" or "java2".
* Can be null, default to "java2". */
* Can be null, default to "java2".
* @param value an enumerated value
*/
public void setVm(Javavm value) {
vm = value.getValue();
}

/**
* If true, run an applet.
* @param value a <code>boolean</code> value
*/
public void setApplet(boolean value) {
applet = value;
@@ -131,6 +147,7 @@ public class Coverage extends CovBase {

/**
* Toggles display of the console prompt: always, error, never
* @param value when to display the prompt - "always", "error" or "never"
*/
public void setExitprompt(String value) {
exitPrompt = value;
@@ -139,6 +156,7 @@ public class Coverage extends CovBase {
/**
* Defines class/method filters based on pattern matching.
* The syntax is filters is similar to a fileset.
* @return the filters to be configured
*/
public Filters createFilters() {
return filters;
@@ -151,6 +169,7 @@ public class Coverage extends CovBase {
* For example you may run a whole application but only decide
* to collect data once it reaches a certain method and once it
* exits another one.
* @return the triggers to be configured
*/
public Triggers createTriggers() {
if (triggers == null) {
@@ -162,6 +181,7 @@ public class Coverage extends CovBase {
/**
* Define a host and port to connect to if you want to do
* remote viewing.
* @return the socket to be configured
*/
public Socket createSocket() {
if (socket == null) {
@@ -170,7 +190,14 @@ public class Coverage extends CovBase {
return socket;
}

/**
* Enumerated type for finalsnapshot attribute.
*/
public static class Finalsnapshot extends EnumeratedAttribute {
/**
* Get the valid strings for the attribute.
* @return an array of strings - "coverage", "none" and "all"
*/
public String[] getValues() {
return new String[]{"coverage", "none", "all"};
}
@@ -179,19 +206,29 @@ public class Coverage extends CovBase {
/**
* Type of snapshot to send at program termination: none, coverage, all.
* Can be null, default to none
* @param value a <code>String</code> value
*/
public void setFinalsnapshot(String value) {
finalSnapshot = value;
}

/**
* Enumerated type for recordfromstart attribute.
*/
public static class Recordfromstart extends EnumeratedAttribute {
/**
* Get the valid strings for the attribute.
* @return an array of strings - "coverage", "none" and "all"
*/
public String[] getValues() {
return new String[]{"coverage", "none", "all"};
}
}

/**
* Set the recordfromstart attribute, valid values are
* "all", "coverage", or "none".
* @param value an enumerated type having the correct values.
*/
public void setRecordfromstart(Recordfromstart value) {
recordFromStart = value.getValue();
@@ -199,6 +236,7 @@ public class Coverage extends CovBase {

/**
* Set warning level (0-3, where 0 is the least amount of warnings).
* @param value an <code>Integer</code> value
*/
public void setWarnlevel(Integer value) {
warnLevel = value.intValue();
@@ -209,6 +247,7 @@ public class Coverage extends CovBase {
* Choose a directory that is reachable by both the remote
* and local computers, and enter the same path on the command-line
* and in the viewer.
* @param value the snapshot directory
*/
public void setSnapshotdir(File value) {
snapshotDir = value;
@@ -216,6 +255,7 @@ public class Coverage extends CovBase {

/**
* The physical path to the working directory for the VM.
* @param value the working directory
*/
public void setWorkingdir(File value) {
workingDir = value;
@@ -223,6 +263,7 @@ public class Coverage extends CovBase {

/**
* If true, track native methods.
* @param value a <code>boolean</code> value
*/
public void setTracknatives(boolean value) {
trackNatives = value;
@@ -232,6 +273,7 @@ public class Coverage extends CovBase {

/**
* Adds a JVM argument.
* @return a command line argument to configure
*/
public Commandline.Argument createJvmarg() {
return cmdlJava.createVmArgument();
@@ -239,6 +281,7 @@ public class Coverage extends CovBase {

/**
* Adds a command argument.
* @return a command line argument to configure
*/
public Commandline.Argument createArg() {
return cmdlJava.createArgument();
@@ -246,6 +289,7 @@ public class Coverage extends CovBase {

/**
* classpath to run the files.
* @return a Path to configure
*/
public Path createClasspath() {
return cmdlJava.createClasspath(getProject()).createPath();
@@ -253,6 +297,7 @@ public class Coverage extends CovBase {

/**
* classname to run as standalone or runner for filesets.
* @param value a <code>String</code> value for the classname
*/
public void setClassname(String value) {
cmdlJava.setClassname(value);
@@ -260,6 +305,7 @@ public class Coverage extends CovBase {

/**
* the classnames to execute.
* @param fs a nested fileset element
*/
public void addFileset(FileSet fs) {
filesets.addElement(fs);
@@ -268,10 +314,16 @@ public class Coverage extends CovBase {

//---------------- the tedious job begins here

/**
* Constructor for Coverage.
*/
public Coverage() {
}

/** execute the jplauncher by providing a parameter file */
/**
* Execute the jplauncher by providing a parameter file.
* @throws BuildException on error
*/
public void execute() throws BuildException {
File paramfile = null;
// if an input file is used, all other options are ignored...
@@ -305,7 +357,10 @@ public class Coverage extends CovBase {
}
}

/** wheck what is necessary to check, Coverage will do the job for us */
/**
* Check what is necessary to check, Coverage will do the job for us.
* @throws BuildException on error
*/
protected void checkOptions() throws BuildException {
// check coverage home
if (getHome() == null || !getHome().isDirectory()) {
@@ -343,6 +398,7 @@ public class Coverage extends CovBase {
* return the command line parameters. Parameters can either be passed
* to the command line and stored to a file (then use the -jp_input=&lt;filename&gt;)
* if they are too numerous.
* @return the command line parameters
*/
protected String[] getParameters() {
Vector params = new Vector();
@@ -435,6 +491,7 @@ public class Coverage extends CovBase {
try {
fw.close();
} catch (IOException ignored) {
// Ignore Exception
}
}
}
@@ -457,6 +514,7 @@ public class Coverage extends CovBase {
try {
os.close();
} catch (IOException ignored) {
// Ignore exception
}
}
}


+ 33
- 1
src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Filters.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2001-2002,2004 The Apache Software Foundation
* Copyright 2001-2002,2004-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,12 +34,14 @@ public class Filters {
/** user defined filters */
protected Vector filters = new Vector();

/** Constructor for Filters. */
public Filters() {
}

/**
* Automatically exclude all classes and methods
* unless included in nested elements; optional, default true.
* @param value a <code>boolean</code> value
*/
public void setDefaultExclude(boolean value) {
defaultExclude = value;
@@ -47,6 +49,7 @@ public class Filters {

/**
* include classes and methods in the analysis
* @param incl an nested Include object
*/
public void addInclude(Include incl) {
filters.addElement(incl);
@@ -54,11 +57,16 @@ public class Filters {

/**
* exclude classes and methods from the analysis
* @param excl an nested Exclude object
*/
public void addExclude(Exclude excl) {
filters.addElement(excl);
}

/**
* Get a comma separated list of filters.
* @return a comma separated list of filters
*/
public String toString() {
StringBuffer buf = new StringBuffer();
final int size = filters.size();
@@ -87,6 +95,7 @@ public class Filters {

/**
* this one is deprecated.
* @param value a <code>String</code> value
* @ant.task ignore="true"
*/

@@ -97,6 +106,7 @@ public class Filters {
/**
* The classname mask as a simple regular expression;
* optional, defaults to "*"
* @param value a <code>String</code> value
*/
public void setClass(String value) {
clazz = value;
@@ -105,6 +115,7 @@ public class Filters {
/**
* The method mask as a simple regular expression;
* optional, defaults to "*"
* @param value a <code>String</code> value
*/
public void setMethod(String value) {
method = value;
@@ -112,24 +123,45 @@ public class Filters {

/**
* enable or disable the filter; optional, default true
* @param value a <code>boolean</code> value
*/

public void setEnabled(boolean value) {
enabled = value;
}

/**
* The classname and the method.
* @return the classname and the method - "class.method()"
*/
public String toString() {
return clazz + "." + method + "()";
}
}

/**
* A class for the nested include element.
*/
public static class Include extends FilterElement {
/**
* The classname and method postfixed with ":I" and (#) if not
* enabled.
* @return a string version of this filter that can be used on the commandline
*/
public String toString() {
return super.toString() + ":I" + (enabled ? "" : "#");
}
}

/**
* A class for the nested exclude element.
*/
public static class Exclude extends FilterElement {
/**
* The classname and method postfixed with ":E" and (#) if not
* enabled.
* @return a string version of this filter that can be used on the commandline
*/
public String toString() {
return super.toString() + ":E" + (enabled ? "" : "#");
}


+ 34
- 1
src/main/org/apache/tools/ant/taskdefs/optional/sitraka/ReportFilters.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2001-2002,2004 The Apache Software Foundation
* Copyright 2001-2002,2004-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,17 +33,30 @@ public class ReportFilters {
/** cached matcher for each filter */
protected Vector matchers = null;

/** Constructor for ReportFilters. */
public ReportFilters() {
}

/**
* Add an include nested element.
* @param incl an include filter element
*/
public void addInclude(Include incl) {
filters.addElement(incl);
}

/**
* Add an exclude nested element.
* @param excl an exclude filter element
*/
public void addExclude(Exclude excl) {
filters.addElement(excl);
}

/**
* Get the number of nested filters.
* @return the number
*/
public int size() {
return filters.size();
}
@@ -52,6 +65,7 @@ public class ReportFilters {
* Check whether a given &lt;classname&gt;&lt;method&gt;() is accepted by the list
* of filters or not.
* @param methodname the full method name in the format &lt;classname&gt;&lt;method&gt;()
* @return true if the methodname passes the list of filters
*/
public boolean accept(String methodname) {
// I'm deferring matcher instantiations at runtime to avoid computing
@@ -98,14 +112,28 @@ public class ReportFilters {
protected String clazz = "*"; // default is all classes
protected String method = "*"; // default is all methods

/**
* Set the class name to match
* Default is match all classes
* @param value the classname to match
*/
public void setClass(String value) {
clazz = value;
}

/**
* Set the method name to match.
* Default is "*", match all methods
* @param value the method name to match
*/
public void setMethod(String value) {
method = value;
}

/**
* Get a regular expression matching this filter.
* @return a regular expression pattern matching this filer.
*/
public String getAsPattern() {
StringBuffer buf = new StringBuffer(toString());
StringUtil.replace(buf, ".", "\\.");
@@ -115,6 +143,11 @@ public class ReportFilters {
return buf.toString();
}

/**
* Get this object as a string.
* The form is ClassName.method().
* @return this filter as a string.
*/
public String toString() {
return clazz + "." + method + "()";
}


+ 7
- 2
src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Socket.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2001-2002,2004 The Apache Software Foundation
* Copyright 2001-2002,2004-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@ public class Socket {
/**
* the host name/ip of the machine on which the Viewer is running;
* defaults to localhost.
* @param value the home name/ip
*/
public void setHost(String value) {
host = value;
@@ -43,12 +44,16 @@ public class Socket {

/**
* Optional port number for the viewer; default is 4444
* @param value the port number
*/
public void setPort(Integer value) {
port = value.intValue();
}

/** if no host is set, returning ':&lt;port&gt;', will take localhost */
/**
* if no host is set, returning ':&lt;port&gt;', will take localhost
* @return "host:port"
*/
public String toString() {
return host + ":" + port;
}


+ 33
- 19
src/main/org/apache/tools/ant/taskdefs/optional/sitraka/Triggers.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2001-2002,2004 The Apache Software Foundation
* Copyright 2001-2002,2004-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,18 +30,24 @@ public class Triggers {

protected Vector triggers = new Vector();

/** Constructor of Triggers. */
public Triggers() {
}


/**
* add a method trigger
* @param method a method to trigger on
*/
public void addMethod(Method method) {
triggers.addElement(method);
}

// -jp_trigger=ClassName.*():E:S,ClassName.MethodName():X:X
/**
* Get the command line option of the form
* -jp_trigger=ClassName.*():E:S,ClassName.MethodName():X:X
* @return a trigger option
*/
public String toString() {
StringBuffer buf = new StringBuffer();
final int size = triggers.size();
@@ -68,6 +74,7 @@ public class Triggers {
* The name of the method(s) as a regular expression. The name
* is the fully qualified name on the form <tt>package.classname.method</tt>
* required.
* @param value the fully qualified name
*/
public void setName(String value) {
name = value;
@@ -77,10 +84,11 @@ public class Triggers {
* the event on the method that will trigger the action. Must be
* &quot;enter&quot; or &quot;exit&quot;
* required.
* @param value the event - either "enter" or "exit"
*/
public void setEvent(String value) {
if (eventMap.get(value) == null) {
throw new BuildException("Invalid event, must be one of " + eventMap);
if (EVENT_MAP.get(value) == null) {
throw new BuildException("Invalid event, must be one of " + EVENT_MAP);
}
event = value;
}
@@ -90,27 +98,33 @@ public class Triggers {
* &quot;pause&quot;, &quot;resume&quot;, &quot;snapshot&quot;, &quot;suspend&quot;,
* or &quot;exit&quot;. They respectively clear recording, pause recording,
* resume recording, take a snapshot, suspend the recording and exit the program.
* @param value the action - "clear", "pause", "resume", "snapshot", "suspend"
* or "exit"
* @throws BuildException on error
*/
public void setAction(String value) throws BuildException {
if (actionMap.get(value) == null) {
throw new BuildException("Invalid action, must be one of " + actionMap);
if (ACTION_MAP.get(value) == null) {
throw new BuildException("Invalid action, must be one of " + ACTION_MAP);
}
action = value;
}

/**
* A alphanumeric custom name for the snapshot; optional.
* @param value the custom name for the snapshot
*/
public void setParam(String value) {
param = value;
}

// return <name>:<event>:<action>[:param]
/**
* @return <name>:<event>:<action>[:param]
*/
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append(name).append(":"); //@todo name must not be null, check for it
buf.append(eventMap.get(event)).append(":");
buf.append(actionMap.get(action));
buf.append(EVENT_MAP.get(event)).append(":");
buf.append(ACTION_MAP.get(action));
if (param != null) {
buf.append(":").append(param);
}
@@ -119,21 +133,21 @@ public class Triggers {
}

/** mapping of actions to cryptic command line mnemonics */
private static final Hashtable actionMap = new Hashtable(3);
private static final Hashtable ACTION_MAP = new Hashtable(3);

/** mapping of events to cryptic command line mnemonics */
private static final Hashtable eventMap = new Hashtable(3);
private static final Hashtable EVENT_MAP = new Hashtable(3);

static {
actionMap.put("enter", "E");
actionMap.put("exit", "X");
ACTION_MAP.put("enter", "E");
ACTION_MAP.put("exit", "X");
// clear|pause|resume|snapshot|suspend|exit
eventMap.put("clear", "C");
eventMap.put("pause", "P");
eventMap.put("resume", "R");
eventMap.put("snapshot", "S");
eventMap.put("suspend", "A");
eventMap.put("exit", "X");
EVENT_MAP.put("clear", "C");
EVENT_MAP.put("pause", "P");
EVENT_MAP.put("resume", "R");
EVENT_MAP.put("snapshot", "S");
EVENT_MAP.put("suspend", "A");
EVENT_MAP.put("exit", "X");
}

}

+ 82
- 10
src/main/org/apache/tools/ant/taskdefs/optional/sitraka/XMLReport.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2001-2004 The Apache Software Foundation
* Copyright 2001-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -71,23 +71,36 @@ public class XMLReport {
/** method filters */
private ReportFilters filters;

/** create a new XML report, logging will be on stdout */
/**
* Create a new XML report, logging will be on stdout.
* @param file the file to place the report in
*/
public XMLReport(File file) {
this(null, file);
}

/** create a new XML report, logging done on the task */
/**
* Create a new XML report, logging done on the task.
* @param task the task to use for logging
* @param file the file to place the report in
*/
public XMLReport(Task task, File file) {
this.file = file;
this.task = task;
}

/** set the JProbe home path. Used to get the DTD */
/**
* Set the JProbe home path. Used to get the DTD.
* @param home the JProbe directory
*/
public void setJProbehome(File home) {
jprobeHome = home;
}

/** set the */
/**
* set the filters attribute.
* @param filters a filtersreport value
*/
public void setReportFilters(ReportFilters filters) {
this.filters = filters;
}
@@ -154,7 +167,12 @@ public class XMLReport {
log("Indexed " + classMap.size() + " classes in " + pkgMap.size() + " packages");
}

/** create the whole new document */
/**
* Create the whole new document.
* @param classPath the classpath
* @return a dom document
* @throws Exception on error
*/
public Document createDocument(String[] classPath) throws Exception {

// Iterate over the classpath to identify reference classes
@@ -199,6 +217,9 @@ public class XMLReport {
* JProbe does not put the java.lang prefix for classes
* in this package, so used this nice method so that
* I have the same signature for methods
* @param method info on a method
* @return a method signature with the "java.lang" prefixes removed from
* the method arguments
*/
protected String getMethodSignature(MethodInfo method) {
StringBuffer buf = new StringBuffer(method.getName());
@@ -224,6 +245,9 @@ public class XMLReport {

/**
* Convert to a CovReport-like signature - &lt;classname&gt;&#046;&lt;method&gt;().
* @param clazz the class to use
* @param method the method to use
* @return the CovReport-like signature
*/
protected String getMethodSignature(ClassFile clazz, MethodInfo method) {
StringBuffer buf = new StringBuffer(clazz.getFullName());
@@ -236,6 +260,8 @@ public class XMLReport {
/**
* Do additional work on an element to remove abstract methods that
* are reported by JProbe 3.0
* @param classFile the class to use
* @param classNode information on the class
*/
protected void removeAbstractMethods(ClassFile classFile, Element classNode) {
MethodInfo[] methods = classFile.getMethods();
@@ -254,7 +280,11 @@ public class XMLReport {
}
}

/** create an empty method element with its cov.data values */
/**
* Create an empty method element with its cov.data values.
* @param method jprobe info on a method
* @return the method element
*/
protected Element createMethodElement(MethodInfo method) {
String methodsig = getMethodSignature(method);
Element methodElem = report.createElement("method");
@@ -268,7 +298,11 @@ public class XMLReport {
return methodElem;
}

/** create an empty package element with its default cov.data (0) */
/**
* Create an empty package element with its default cov.data (0).
* @param pkgname the packet name
* @return the package element
*/
protected Element createPackageElement(String pkgname) {
Element pkgElem = report.createElement("package");
pkgElem.setAttribute("name", pkgname);
@@ -284,7 +318,11 @@ public class XMLReport {
return pkgElem;
}

/** create an empty class element with its default cov.data (0) */
/**
* Create an empty class element with its default cov.data (0).
* @param classFile jprobe class info
* @return an class element
*/
protected Element createClassElement(ClassFile classFile) {
// create the class element
Element classElem = report.createElement("class");
@@ -305,7 +343,10 @@ public class XMLReport {
return classElem;
}

/** serialize a classfile into XML */
/**
* serialize a classfile into XML.
* @param classFile the class file to serialize
*/
protected void serializeClass(ClassFile classFile) {
// the class already is reported so ignore it
String fullclassname = classFile.getFullName();
@@ -368,6 +409,11 @@ public class XMLReport {
classMap.put(fullclassname, classElem);
}

/**
* Get the methods from a classFile that pass the filters.
* @param classFile the class file to get the methods from
* @return the list of methods
*/
protected Vector getFilteredMethods(ClassFile classFile) {
MethodInfo[] methodlist = classFile.getMethods();
Vector methods = new Vector(methodlist.length);
@@ -449,6 +495,13 @@ public class XMLReport {
covdata.setAttribute("total_lines", String.valueOf(total_lines));
}

/**
* Search for an element with the tag "cov.data" in the children
* of the parent element and return it.
* @param parent the parent element to search in
* @return the "cov.data" element
* @throws NoSuchElementException if unable to find a cov.data element
*/
protected Element getCovDataChild(Element parent) {
NodeList children = parent.getChildNodes();
int len = children.getLength();
@@ -465,6 +518,11 @@ public class XMLReport {
+ "element in parent '" + parent.getNodeName() + "'");
}

/**
* Get the method elements of an class element.
* @param clazz the element to search it
* @return a name to element map of methods
*/
protected Hashtable getMethods(Element clazz) {
Hashtable map = new Hashtable();
NodeList children = clazz.getChildNodes();
@@ -482,6 +540,11 @@ public class XMLReport {
return map;
}

/**
* Get the class elements of an package element.
* @param pkg the element to search it
* @return an array of class elements
*/
protected Element[] getClasses(Element pkg) {
Vector v = new Vector();
NodeList children = pkg.getChildNodes();
@@ -501,6 +564,11 @@ public class XMLReport {

}

/**
* Get the package elements of an snapshot element.
* @param snapshot the element to search it
* @return an array of package elements
*/
protected Element[] getPackages(Element snapshot) {
Vector v = new Vector();
NodeList children = snapshot.getChildNodes();
@@ -530,6 +598,10 @@ public class XMLReport {
}
}

/**
* Log a message to the associated task.
* @param message a <code>String</code> attribute
*/
public void log(String message) {
if (task == null) {
//System.out.println(message);


+ 45
- 20
src/main/org/apache/tools/ant/taskdefs/optional/sitraka/bytecode/ClassFile.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2001-2002,2004 The Apache Software Foundation
* Copyright 2001-2002,2004-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,6 +44,11 @@ public final class ClassFile {

private int access_flags;

/**
* Constructor for ClassFile.
* @param is the input stream containing the class.
* @throws IOException on error
*/
public ClassFile(InputStream is) throws IOException {
DataInputStream dis = new DataInputStream(is);
ConstantPool constantPool = new ConstantPool();
@@ -57,8 +62,9 @@ public final class ClassFile {

// class information
access_flags = dis.readShort();
int this_class = dis.readShort();
fullname = ((ClassCPInfo) constantPool.getEntry(this_class)).getClassName().replace('/', '.');
int thisClass = dis.readShort();
fullname = ((ClassCPInfo) constantPool.getEntry(
thisClass)).getClassName().replace('/', '.');
/* int super_class = */ dis.readShort();

// skip interfaces...
@@ -71,8 +77,8 @@ public final class ClassFile {
// 3 short: access flags, name index, descriptor index
dis.skip(2 * 3);
// attribute list...
int attributes_count = dis.readUnsignedShort();
for (int j = 0; j < attributes_count; j++) {
int attributesCount = dis.readUnsignedShort();
for (int j = 0; j < attributesCount; j++) {
dis.skipBytes(2); // skip attr_id (short)
int len = dis.readInt();
dis.skipBytes(len);
@@ -80,44 +86,64 @@ public final class ClassFile {
}

// read methods
int method_count = dis.readShort();
methods = new MethodInfo[method_count];
for (int i = 0; i < method_count; i++) {
int methodCount = dis.readShort();
methods = new MethodInfo[methodCount];
for (int i = 0; i < methodCount; i++) {
methods[i] = new MethodInfo();
methods[i].read(constantPool, dis);
}

// get interesting attributes.
int attributes_count = dis.readUnsignedShort();
for (int j = 0; j < attributes_count; j++) {
int attr_id = dis.readShort();
int attributesCount = dis.readUnsignedShort();
for (int j = 0; j < attributesCount; j++) {
int attrId = dis.readShort();
int len = dis.readInt();
String attr_name = Utils.getUTF8Value(constantPool, attr_id);
if (AttributeInfo.SOURCE_FILE.equals(attr_name)) {
int name_index = dis.readShort();
sourceFile = ((Utf8CPInfo) constantPool.getEntry(name_index)).getValue();
String attrName = Utils.getUTF8Value(constantPool, attrId);
if (AttributeInfo.SOURCE_FILE.equals(attrName)) {
int nameIndex = dis.readShort();
sourceFile = ((Utf8CPInfo) constantPool.getEntry(nameIndex)).getValue();
} else {
dis.skipBytes(len);
}
}
}

/**
* Get the access flags of the class.
* @return the flags
*/
public int getAccess() {
return access_flags;
}

/**
* Get the source filename
* @return the source filename
*/
public String getSourceFile() {
return sourceFile;
}

/**
* Get the methods of the class.
* @return the methods
*/
public MethodInfo[] getMethods() {
return methods;
}

/**
* Get the full name of the class.
* @return the full name
*/
public String getFullName() {
return fullname;
}

/**
* Get the name of the class (minus package name)
* @return the name
*/
public String getName() {
String name = getFullName();
int pos = name.lastIndexOf('.');
@@ -127,6 +153,10 @@ public final class ClassFile {
return name.substring(pos + 1);
}

/**
* Get the package name of the class.
* @return the package name
*/
public String getPackage() {
String name = getFullName();
int pos = name.lastIndexOf('.');
@@ -137,8 +167,3 @@ public final class ClassFile {
}

}






+ 16
- 3
src/main/org/apache/tools/ant/taskdefs/optional/sitraka/bytecode/ClassPathLoader.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2001-2004 The Apache Software Foundation
* Copyright 2001-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,6 +38,7 @@ import java.util.zip.ZipFile;
*/
public class ClassPathLoader {

/** A null loader */
public static final FileLoader NULL_LOADER = new NullLoader();

/** the list of files to look for */
@@ -80,10 +81,17 @@ public class ClassPathLoader {

/** the interface to implement to look up for specific resources */
public interface FileLoader {
/** the file url that is looked for .class files */
/**
* the file url that is looked for .class files.
* @return the file
*/
File getFile();

/** return the set of classes found in the file */
/**
* Return the set of classes found in the file.
* @return the list of classes
* @throws IOException on error
*/
ClassFile[] getClasses() throws IOException;
}

@@ -104,6 +112,7 @@ public class ClassPathLoader {
* @return the hashtable containing ALL classes that are found in the given
* classpath. Note that the first entry of a given classname will shadow
* classes with the same name (as a classloader does)
* @throws IOException on error
*/
public Hashtable getClasses() throws IOException {
Hashtable map = new Hashtable();
@@ -159,6 +168,9 @@ public class ClassPathLoader {
* useful methods to read the whole input stream in memory so that
* it can be accessed faster. Processing rt.jar and tools.jar from JDK 1.3.1
* brings time from 50s to 7s.
* @param is the inout stream to cache
* @return the cached input stream
* @throws IOException on error
*/
public static InputStream getCachedStream(InputStream is) throws IOException {
final InputStream bis = new BufferedInputStream(is);
@@ -266,6 +278,7 @@ final class DirectoryLoader implements ClassPathLoader.FileLoader {
try {
is.close();
} catch (IOException ignored) {
// Ignore Exception
}
}
}


+ 60
- 7
src/main/org/apache/tools/ant/taskdefs/optional/sitraka/bytecode/MethodInfo.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2001-2002,2004 The Apache Software Foundation
* Copyright 2001-2002,2004-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,16 +27,23 @@ import org.apache.tools.ant.taskdefs.optional.sitraka.bytecode.attributes.Attrib
*
*/
public final class MethodInfo {
private int access_flags;
private int accessFlags;
private int loc = -1;
private String name;
private String descriptor;

/** Constructor for MethodInfo. */
public MethodInfo() {
}

/**
* Read the method info from a data input stream.
* @param constantPool a constant pool
* @param dis the data input stream
* @throws IOException on error
*/
public void read(ConstantPool constantPool, DataInputStream dis) throws IOException {
access_flags = dis.readShort();
accessFlags = dis.readShort();

int name_index = dis.readShort();
name = Utils.getUTF8Value(constantPool, name_index);
@@ -58,6 +65,12 @@ public final class MethodInfo {

}

/**
* Read a code from a data input stream.
* @param constantPool a constant pool
* @param dis the data input stream
* @throws IOException on error
*/
protected void readCode(ConstantPool constantPool, DataInputStream dis) throws IOException {
// skip max_stack (short), max_local (short)
dis.skipBytes(2 * 2);
@@ -87,22 +100,44 @@ public final class MethodInfo {
}
}

/**
* Get the access flags.
* @return the access flags
*/
public int getAccessFlags() {
return access_flags;
return accessFlags;
}

/**
* Get the name.
* @return the name
*/
public String getName() {
return name;
}

/**
* Get the descriptor.
* @return the descriptor
*/
public String getDescriptor() {
return descriptor;
}

/**
* Get the full signature of the method.
* This is the return type, the name and the parameters.
* @return the full signature
*/
public String getFullSignature() {
return getReturnType() + " " + getShortSignature();
}

/**
* Get the short signature of the method.
* This is just the name and the parameters.
* @return the short signature
*/
public String getShortSignature() {
StringBuffer buf = new StringBuffer(getName());
buf.append("(");
@@ -117,22 +152,42 @@ public final class MethodInfo {
return buf.toString();
}

/**
* Get the return type.
* @return the return type
*/
public String getReturnType() {
return Utils.getMethodReturnType(getDescriptor());
}

/**
* Get the paramaters types.
* @return an array of types
*/
public String[] getParametersType() {
return Utils.getMethodParams(getDescriptor());
}

/**
* Get the number of lines in the method.
* @return the number of lines
*/
public int getNumberOfLines() {
return loc;
}

/**
* Get the access flags as a string.
* @return the access flags.
*/
public String getAccess() {
return Utils.getMethodAccess(access_flags);
return Utils.getMethodAccess(accessFlags);
}

/**
* Return a string represention of this object.
* @return the access, and the full signature
*/
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("Method: ").append(getAccess()).append(" ");
@@ -140,5 +195,3 @@ public final class MethodInfo {
return sb.toString();
}
}



+ 89
- 75
src/main/org/apache/tools/ant/taskdefs/optional/sitraka/bytecode/Utils.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2001-2004 The Apache Software Foundation
* Copyright 2001-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@ import org.apache.tools.ant.taskdefs.optional.depend.constantpool.Utf8CPInfo;
* Utilities mostly to manipulate methods and access flags.
*
*/
public class Utils {
public final class Utils {
/** public access flag */
public static final short ACC_PUBLIC = 1;
/** private access flag */
@@ -98,7 +98,7 @@ public class Utils {

/**
* return the object type of a return type.
* @param descriptor
* @param descriptor the description symbol
* @return get the return type objet of a given descriptor
*/
public static String getMethodReturnType(String descriptor) {
@@ -172,143 +172,157 @@ public class Utils {

/**
* check for abstract access
* @param access_flags access flags
* @param accessFlags access flags
* @return true if there is abstact access
*/
public static boolean isAbstract(int access_flags) {
return (access_flags & ACC_ABSTRACT) != 0;
public static boolean isAbstract(int accessFlags) {
return (accessFlags & ACC_ABSTRACT) != 0;
}

/**
* check for public access
* @param access_flags access flags
* @param accessFlags access flags
* @return true if there is public access
*/
public static boolean isPublic(int access_flags) {
return (access_flags & ACC_PUBLIC) != 0;
public static boolean isPublic(int accessFlags) {
return (accessFlags & ACC_PUBLIC) != 0;
}

/**
* check for a static access
* @param access_flags access flags
* @param accessFlags access flags
* @return true if there is static access
*/
public static boolean isStatic(int access_flags) {
return (access_flags & ACC_STATIC) != 0;
public static boolean isStatic(int accessFlags) {
return (accessFlags & ACC_STATIC) != 0;
}

/**
* check for native access
* @param access_flags access flags
* check for native access
* @param accessFlags access flags
* @return true if there is native access
*/
public static boolean isNative(int access_flags) {
return (access_flags & ACC_NATIVE) != 0;
public static boolean isNative(int accessFlags) {
return (accessFlags & ACC_NATIVE) != 0;
}

/**
* check for class access
* @param access_flags access flags
* @param accessFlags access flags
* @return true if there is class access
*/
public static boolean isClass(int access_flags) {
return !isInterface(access_flags);
public static boolean isClass(int accessFlags) {
return !isInterface(accessFlags);
}

/**
* check for strict access
* @param access_flags access flags
* @param accessFlags access flags
* @return true if there is strict access
*/
public static boolean isStrict(int access_flags) {
return (access_flags & ACC_STRICT) != 0;
public static boolean isStrict(int accessFlags) {
return (accessFlags & ACC_STRICT) != 0;
}

/**
* check for interface access
* @param access_flags access flags
* @param accessFlags access flags
* @return true if there is interface access
*/
public static boolean isInterface(int access_flags) {
return (access_flags & ACC_INTERFACE) != 0;
public static boolean isInterface(int accessFlags) {
return (accessFlags & ACC_INTERFACE) != 0;
}

/**
* check for private access
* @param access_flags access flags
* @param accessFlags access flags
* @return true if there is private access
*/
public static boolean isPrivate(int access_flags) {
return (access_flags & ACC_PRIVATE) != 0;
public static boolean isPrivate(int accessFlags) {
return (accessFlags & ACC_PRIVATE) != 0;
}

/**
* check for transient flag
* @param access_flags access flags
* @param accessFlags access flags
* @return true if there is transient access
*/
public static boolean isTransient(int access_flags) {
return (access_flags & ACC_TRANSIENT) != 0;
public static boolean isTransient(int accessFlags) {
return (accessFlags & ACC_TRANSIENT) != 0;
}

/**
* check for volatile flag
* @param access_flags access flags
* @param accessFlags access flags
* @return true if there is volatile access
*/
public static boolean isVolatile(int access_flags) {
return (access_flags & ACC_VOLATILE) != 0;
public static boolean isVolatile(int accessFlags) {
return (accessFlags & ACC_VOLATILE) != 0;
}

/**
* check for super flag
* @param access_flags access flag
* @param accessFlags access flag
* @return true if there the super flag is set
*/
public static boolean isSuper(int access_flags) {
return (access_flags & ACC_SUPER) != 0;
public static boolean isSuper(int accessFlags) {
return (accessFlags & ACC_SUPER) != 0;
}

/**
* check for protected flag
* @param access_flags access flags
* @param accessFlags access flags
* @return true if there is protected access
*/
public static boolean isProtected(int access_flags) {
return (access_flags & ACC_PROTECTED) != 0;
public static boolean isProtected(int accessFlags) {
return (accessFlags & ACC_PROTECTED) != 0;
}

/**
* chck for final flag
* @param access_flags access flags
* @param accessFlags access flags
* @return true if there the final flag is set
*/
public static boolean isFinal(int access_flags) {
return (access_flags & ACC_FINAL) != 0;
public static boolean isFinal(int accessFlags) {
return (accessFlags & ACC_FINAL) != 0;
}

/**
* check for synchronized flag
* @param access_flags access flags
* @param accessFlags access flags
* @return true if there the synchronized flag is set
*/
public static boolean isSynchronized(int access_flags) {
return (access_flags & ACC_SYNCHRONIZED) != 0;
public static boolean isSynchronized(int accessFlags) {
return (accessFlags & ACC_SYNCHRONIZED) != 0;
}

/**
* return the method access flag as java modifiers
* @param access_flags access flags
* @param accessFlags access flags
* @return the access flags as modifier strings
*/
public static String getMethodAccess(int access_flags) {
public static String getMethodAccess(int accessFlags) {
StringBuffer sb = new StringBuffer();
if (isPublic(access_flags)) {
if (isPublic(accessFlags)) {
sb.append("public ");
} else if (isPrivate(access_flags)) {
} else if (isPrivate(accessFlags)) {
sb.append("private ");
} else if (isProtected(access_flags)) {
} else if (isProtected(accessFlags)) {
sb.append("protected ");
}
if (isFinal(access_flags)) {
if (isFinal(accessFlags)) {
sb.append("final ");
}
if (isStatic(access_flags)) {
if (isStatic(accessFlags)) {
sb.append("static ");
}
if (isSynchronized(access_flags)) {
if (isSynchronized(accessFlags)) {
sb.append("synchronized ");
}
if (isNative(access_flags)) {
if (isNative(accessFlags)) {
sb.append("native ");
}
if (isAbstract(access_flags)) {
if (isAbstract(accessFlags)) {
sb.append("abstract ");
}
return sb.toString().trim();
@@ -316,28 +330,28 @@ public class Utils {

/**
* return the field access flag as java modifiers
* @param access_flags access flags
* @param accessFlags access flags
* @return the access flags as modifier strings
*/
public static String getFieldAccess(int access_flags) {
public static String getFieldAccess(int accessFlags) {
StringBuffer sb = new StringBuffer();
if (isPublic(access_flags)) {
if (isPublic(accessFlags)) {
sb.append("public ");
} else if (isPrivate(access_flags)) {
} else if (isPrivate(accessFlags)) {
sb.append("private ");
} else if (isProtected(access_flags)) {
} else if (isProtected(accessFlags)) {
sb.append("protected ");
}
if (isFinal(access_flags)) {
if (isFinal(accessFlags)) {
sb.append("final ");
}
if (isStatic(access_flags)) {
if (isStatic(accessFlags)) {
sb.append("static ");
}
if (isVolatile(access_flags)) {
if (isVolatile(accessFlags)) {
sb.append("volatile ");
}
if (isTransient(access_flags)) {
if (isTransient(accessFlags)) {
sb.append("transient ");
}
return sb.toString().trim();
@@ -345,31 +359,31 @@ public class Utils {

/**
* return the class access flag as java modifiers
* @param access_flags access flags
* @param accessFlags access flags
* @return the access flags as modifier strings
*/
public static String getClassAccess(int access_flags) {
public static String getClassAccess(int accessFlags) {
StringBuffer sb = new StringBuffer();
if (isPublic(access_flags)) {
if (isPublic(accessFlags)) {
sb.append("public ");
} else if (isProtected(access_flags)) {
} else if (isProtected(accessFlags)) {
sb.append("protected ");
} else if (isPrivate(access_flags)) {
} else if (isPrivate(accessFlags)) {
sb.append("private ");
}
if (isFinal(access_flags)) {
if (isFinal(accessFlags)) {
sb.append("final ");
}
if (isSuper(access_flags)) {
if (isSuper(accessFlags)) {
sb.append("/*super*/ ");
}
if (isInterface(access_flags)) {
if (isInterface(accessFlags)) {
sb.append("interface ");
}
if (isAbstract(access_flags)) {
if (isAbstract(accessFlags)) {
sb.append("abstract ");
}
if (isClass(access_flags)) {
if (isClass(accessFlags)) {
sb.append("class ");
}
return sb.toString().trim();


+ 12
- 2
src/main/org/apache/tools/ant/taskdefs/optional/sitraka/bytecode/attributes/AttributeInfo.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2001-2002,2004 The Apache Software Foundation
* Copyright 2001-2002,2004-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,26 +22,36 @@ package org.apache.tools.ant.taskdefs.optional.sitraka.bytecode.attributes;
*/
public interface AttributeInfo {

/** The source file attribute */
String SOURCE_FILE = "SourceFile";

/** The constant value attribute */
String CONSTANT_VALUE = "ConstantValue";

/** The code attribute */
String CODE = "Code";

/** The exceptions attribute */
String EXCEPTIONS = "Exceptions";

/** The line number table attribute */
String LINE_NUMBER_TABLE = "LineNumberTable";

/** The local variable table attribute */
String LOCAL_VARIABLE_TABLE = "LocalVariableTable";

/** The inner classes attribute */
String INNER_CLASSES = "InnerClasses";

/** The source dir attribute */
String SOURCE_DIR = "SourceDir";

/** The synthetic attribute */
String SYNTHETIC = "Synthetic";

/** The deprecated attribute */
String DEPRECATED = "Deprecated";

/** The unknown attribute */
String UNKNOWN = "Unknown";

}

Loading…
Cancel
Save