SkeletonMaker
v1.3 Copyright © 2000,2001,2002 dr. Cristiano Sadun

Go here to go to the 'download' paragraph.

Version 1.3 changes

Version 1.2 changes

Version 1.1 changes

Purpose

This tool creates compilable implementations of java interfaces, abstract classes or plain classes (*) - that is:

(*) only if constructor-generation is enabled by -genCon.

Therefore, each generated class is a "null" or "mock" implementation of the interface, that can be immediatly compiled, allowing you to complete the overall implementation incrementally.

Also, implementations of abstract classes can be generated - in which case the generated class will extend the given abstract class, overriding any abstract method with the same "null" implementation as above.

For example, if you have an interface:

package my.package;

import java.io.File;
import java.io.IOException;

public interface MyInterface {
    public void openFile(File f) throws IOException;
}
you compile it, and by running the tool you will obtain the following source code:
package my.package;

import java.io.File;
import java.io.IOException;

/**
 * An implementation of my.package.MyInterface.
 */
public class MyInterfaceImpl implements MyInterface {

    /**
     * Implementation of openFile() from my.package.MyInterface
     * @param File f
     * @exception IOException
     */
    public void openFile(File f) throws IOException {
        throw new RuntimeException("Not implemented yet");
    }
}

The tool is meant as a time-saver, worth to use if you're implementing several interfaces, possibly each with several methods and you don't have their source code or you do but cut&paste is unfeasible. A typical case (read: the reason I wrote this tool :-) is implementing a JDBC driver.

Usage and notes

The executable distribution is made up by a single executable jar file skelm.jar, which you may run by the usual java -jar skelm.jar (or set up a small shell script/batch file if you like: examples are skelm and skelm.bat).

The main interface to the generator is command-line:

Usage: (options marked with (*) are mandatory)

-directory      sets up the destination directory
        (aliases:-dir, -d)
-version        Adds a @version javadoc tag to the generated class' comment
        (aliases:-ver)
-verbose        set verbose mode
        (aliases:-v)
-extdir the directory in which to look for additional classes/jars (defaults to
/ext)
        (aliases:-e)
-overwrite      do not ask confirmation when overwriting existing source code
        (aliases:-owr)
-author Adds an @author javadoc tag to the generated class' comment
        (aliases:-a)
-printOnly      causes the generated code to be print but not saved
        (aliases:-po)
-genCon Adds constructors matching the base class ones. Can be applied also to non-abstract/interface classes
        (aliases:-gbc, -gbase)
-interfaces(*)  interfaces whose implementation skeleton must be generated
        (aliases:-i)

The most relevant (and only mandatory) option is -interfaces with which you specify the interface(s) or abstract class(es) for which a corresponding implementation/concrete class has to be generated. For example, if you have the package root of my.package in your current directory, and the compiled MyInterface interface in my/package/MyInterface.class, running

      java -jar skelm.jar -i my.package.MyInterface
will generate the source code for my.package.MyInterfaceImpl in my/package/MyInterfaceImpl.java (directories are created as needed).

You can specify as many interfaces as you want:

      java -jar skelm.jar -i my.package.MyInterface my.package.MyInterface2
will generate two distinct classes source code (MyInterface.java and MyInterface1.java). If the specified name isn't found, the tool will report that it can't be loaded; if it does not match an interface/abstract class, an Error will be thrown.

-genCon is a version 1.2 feature which enables the automatic generation of constructors matching the constructors in the base class. This option allows to specify non-abstract or non-interface classes with the -i option.

For example, running java -jar skelm.jar -i java.lang.Exception -genCon -po will produce (with JRE1.3 libraries)

/**
 * Subclass of class java.lang.Exception
 */
public class ExceptionImpl extends java.lang.Exception {

  /**
   * Constructor matching {@link java.lang.Exception#java.lang.Exception(java.lang.String) java.lang.Exception()}
   * from {@link java.lang.Exception Exception}
   * @param s1
   */
  public ExceptionImpl(String s1) {
    super(s1);
  }

  /**
   * Constructor matching {@link java.lang.Exception#java.lang.Exception() java.lang.Exception()}
   * from {@link java.lang.Exception Exception}
   */
  public ExceptionImpl() {

  }

}

-extdir is a version 1.1 feature that allows you to specify where to look for additional classes or jar packages when resolving classes for generation. Skelm relies on the standard Java mechanism to look up classes (for example, if you have jars in the standard extensions directory it will find them), but by default looks also in the ./ext directory, or in the directory specified by -extdir.

The classloader used by skelm is automatically collecting any jar in any specified directory(ies), so you don't need to specify jars one by one.

So, if the interfaces you want to create implementations of are in a package foo.jar in /fooapp/lib to have skelm find them you have four ways:

The -printOnly allows you to see the result without actually generating the file; the -directory option allows you to specify a different directory for the package root where to create the .java than the current directory - for example

      java -jar skelm.jar -d ../java/impl -i my.package.MyInterface
will generate the java code MyInterface.java in the directory ../java/impl/my/package.

The options -author and -version simply add the @author and @version javadoc tags to the class comment. They both need one single parameter - the text for the tag. Note that you might have to use quotes if the text includes spaces:

      java -jar skelm.jar -author "Cris Sadun" -i my.package.MyInterface

Also, for the moment, the generated class can implement only one interface. It's not difficult to allow for multiple interfaces, but I haven't come around to do it yet.

Downloading

Please use sourceforge to download the latest version.


Copyright © 2000,2001 dr. Cristiano Sadun