|
||||||||||
| 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(Class<?> c)
Get a new InterfaceImplementor to implement the passed in interface. |
|
| Method Summary | |
|---|---|
protected boolean |
buildConstructors()
If true, build the default constructors. |
protected String |
getDocLink(Constructor<?> con)
Get the relative javadoc signature for this Constructor. |
protected String |
getDocLink(Method method)
Get the relative javadoc signature for this method. |
protected Class<?> |
getInterface()
Get the interface we're implementing. |
String |
getOutClassName()
Get the name of the class we'll be generating |
String |
getOutPackageName()
Get the name of the package containing class we'll be generating |
protected String |
getSignature(Method method)
Get the method signature. |
protected String |
getSignature(Method method,
boolean needExceptions)
Get a String representing this method signature. |
protected Class<?> |
getSuperclass()
Get the parent class of the generated class. |
protected String |
implement(Method method)
Implement the given method. |
static void |
main(String[] args)
|
String |
makeSource()
Generate the source code for the class this object represents. |
protected String |
preConstructors()
Anything that should appear before the automatically generated constructors. |
protected String |
preMethods()
Anything that should appear before the automatically generated methods. |
void |
setOutputClass(String to)
Set the name of the output class. |
void |
setSuperClass(Class<?> c)
Set an optional superclass that defines some of the methods for the implementation. |
void |
writeSourceToFile(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(Class<?> c)
c - The interface to implement.
NullPointerException - if the passed in class is null
IllegalArgumentException - if the passed in class is not
an interface| Method Detail |
|---|
protected Class<?> getInterface()
protected Class<?> getSuperclass()
public String getOutClassName()
public String getOutPackageName()
public void setOutputClass(String to)
public void setSuperClass(Class<?> c)
c - Superclass
NullPointerException - if the passed in class is null
IllegalArgumentException - if the passed in class isn't
valid for this operation.protected String getSignature(Method method)
method - method needing the signature
protected String getSignature(Method method,
boolean needExceptions)
method - the name of the methodneedExceptions - true if exceptions are needed as part of the
signature stringprotected String getDocLink(Method method)
protected String getDocLink(Constructor<?> con)
protected String implement(Method method)
method - the method to be implemented.
protected String preConstructors()
protected String preMethods()
public String makeSource()
protected boolean buildConstructors()
public void writeSourceToFile(String outdir)
throws IOException
outdir - the base directory to write the file
IOException - if there's a problem writing the file
public static void main(String[] args)
throws Exception
Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||