|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.spy.SpyObject
net.spy.util.InterfaceImplementor
public class InterfaceImplementor
Extend existing classes with missing methods required to implement a specified interface. Think Java Interfaces are a poor replacement for the lack of multiple inheritence? SO DO I! That's why this class exists.
Using InterfaceImplementor, you can write code that's portable among different API specs. You simply implement what you need out of an interface, and InterfaceImplementor writes a class that extends from the class you wrote, and fills in all the blanks for you.
Here's the way you use it:
java net.spy.util.InterfaceImplementor -interface java.sql.ResultSet -superclass test.TestSet -outputclass test.TestSetImpl
| Constructor Summary | |
|---|---|
InterfaceImplementor(java.lang.Class c)
Get a new InterfaceImplementor to implement the passed in interface. |
|
| Method Summary | |
|---|---|
protected boolean |
buildConstructors()
If true, build the default constructors. |
protected java.lang.String |
getDocLink(java.lang.reflect.Constructor con)
Get the relative javadoc signature for this Constructor. |
protected java.lang.String |
getDocLink(java.lang.reflect.Method method)
Get the relative javadoc signature for this method. |
protected java.lang.Class |
getInterface()
Get the interface we're implementing. |
java.lang.String |
getOutClassName()
Get the name of the class we'll be generating |
java.lang.String |
getOutPackageName()
Get the name of the package containing class we'll be generating |
protected java.lang.String |
getSignature(java.lang.reflect.Method method)
Get the method signature. |
protected java.lang.String |
getSignature(java.lang.reflect.Method method,
boolean needExceptions)
Get a String representing this method signature. |
protected java.lang.Class |
getSuperclass()
Get the parent class of the generated class. |
protected java.lang.String |
implement(java.lang.reflect.Method method)
Implement the given method. |
static void |
main(java.lang.String[] args)
|
java.lang.String |
makeSource()
Generate the source code for the class this object represents. |
protected java.lang.String |
preConstructors()
Anything that should appear before the automatically generated constructors. |
protected java.lang.String |
preMethods()
Anything that should appear before the automatically generated methods. |
void |
setOutputClass(java.lang.String to)
Set the name of the output class. |
void |
setSuperClass(java.lang.Class c)
Set an optional superclass that defines some of the methods for the implementation. |
void |
writeSourceToFile(java.lang.String outdir)
Write this implementation out to a given file. |
| Methods inherited from class net.spy.SpyObject |
|---|
getLogger |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public InterfaceImplementor(java.lang.Class c)
c - The interface to implement.
java.lang.NullPointerException - if the passed in class is null
java.lang.IllegalArgumentException - if the passed in class is not
an interface| Method Detail |
|---|
protected java.lang.Class getInterface()
protected java.lang.Class getSuperclass()
public java.lang.String getOutClassName()
public java.lang.String getOutPackageName()
public void setOutputClass(java.lang.String to)
public void setSuperClass(java.lang.Class c)
c - Superclass
java.lang.NullPointerException - if the passed in class is null
java.lang.IllegalArgumentException - if the passed in class isn't
valid for this operation.protected java.lang.String getSignature(java.lang.reflect.Method method)
method - method needing the signature
protected java.lang.String getSignature(java.lang.reflect.Method method,
boolean needExceptions)
method - the name of the methodneedExceptions - true if exceptions are needed as part of the
signature stringprotected java.lang.String getDocLink(java.lang.reflect.Method method)
protected java.lang.String getDocLink(java.lang.reflect.Constructor con)
protected java.lang.String implement(java.lang.reflect.Method method)
method - the method to be implemented.
protected java.lang.String preConstructors()
protected java.lang.String preMethods()
public java.lang.String makeSource()
protected boolean buildConstructors()
public void writeSourceToFile(java.lang.String outdir)
throws java.io.IOException
outdir - the base directory to write the file
java.io.IOException - if there's a problem writing the file
public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||