Package org.exolab.javasource
Class JInterface
- java.lang.Object
-
- org.exolab.javasource.JType
-
- org.exolab.javasource.JStructure
-
- org.exolab.javasource.JInterface
-
- All Implemented Interfaces:
JAnnotatedElement
public final class JInterface extends JStructure
A representation of the Java Source code for a Java Interface. This is a useful utility when creating in memory source code. The code in this package was modeled after the Java Reflection API as much as possible to reduce the learning curve.- Version:
- $Revision: 8329 $ $Date: 2005-02-26 17:30:28 -0700 (Sat, 26 Feb 2005) $
- Author:
- Martin Skopp, Keith Visco
-
-
Constructor Summary
Constructors Constructor Description JInterface(java.lang.String name)
Creates a new JInterface with the given name.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addField(JField jField)
Adds the given JField to this Jinterface.void
addImport(java.lang.String className)
Adds the given import to this JStructure.void
addMember(JMember jMember)
Adds the given JMember to this Jinterface.void
addMethod(JMethodSignature jMethodSig)
Adds the given JMethodSignature to this Jinterface.JField
getField(java.lang.String name)
Returns the field with the given name, or null if no field was found with the given name.JField[]
getFields()
Returns an array of all the JFields of this Jinterface.JMethodSignature
getMethod(int index)
Returns the JMethodSignature at the given index.JMethodSignature
getMethod(java.lang.String name, int startIndex)
Returns the JMethodSignature with the given name and occuring at or after the given starting index.JMethodSignature[]
getMethods()
Returns an array of all the JMethodSignatures of this JInterface.void
print(JSourceWriter jsw)
Deprecated.Please use the Velocity-template based approach instead.void
print(JSourceWriter jsw, boolean classOnly)
Deprecated.Please use the Velocity-template based approach instead.-
Methods inherited from class org.exolab.javasource.JStructure
addAnnotation, addImport, addImport, addImportInternal, addInterface, getAnnotatedElementHelper, getAnnotation, getAnnotations, getFilename, getHeader, getImportCount, getImports, getInterfaceCount, getInterfaces, getJDocComment, getModifiers, getPackageName, hasAnnotations, hasImport, isAnnotationPresent, print, printHeader, printImportDeclarations, printPackageDeclaration, removeAnnotation, removeImport, removeInterface, setHeader, toString
-
Methods inherited from class org.exolab.javasource.JType
getLocalName, getName, isArray, isPrimitive, setName
-
-
-
-
Method Detail
-
addImport
public void addImport(java.lang.String className)
Adds the given import to this JStructure. Note: You cannot import from the "default package," so imports with no package are ignored.- Specified by:
addImport
in classJStructure
- Parameters:
className
- Name of the class to import.
-
addMember
public void addMember(JMember jMember)
Adds the given JMember to this Jinterface.This method is implemented by subclasses and should only accept the proper types for the subclass otherwise an IllegalArgumentException will be thrown.
- Specified by:
addMember
in classJStructure
- Parameters:
jMember
- The JMember to add to this JStructure.
-
getFields
public JField[] getFields()
Returns an array of all the JFields of this Jinterface.- Specified by:
getFields
in classJStructure
- Returns:
- An array of all the JFields of this Jinterface.
-
getField
public JField getField(java.lang.String name)
Returns the field with the given name, or null if no field was found with the given name.- Specified by:
getField
in classJStructure
- Parameters:
name
- The name of the field to return.- Returns:
- The field with the given name, or null if no field was found with the given name.
-
addField
public void addField(JField jField)
Adds the given JField to this Jinterface.This method is implemented by subclasses and should only accept the proper fields for the subclass otherwise an IllegalArgumentException will be thrown. For example a JInterface will only accept static fields.
- Specified by:
addField
in classJStructure
- Parameters:
jField
- The JField to add.
-
getMethods
public JMethodSignature[] getMethods()
Returns an array of all the JMethodSignatures of this JInterface.- Returns:
- An array of all the JMethodSignatures of this JInterface.
-
getMethod
public JMethodSignature getMethod(java.lang.String name, int startIndex)
Returns the JMethodSignature with the given name and occuring at or after the given starting index.- Parameters:
name
- The name of the JMethodSignature to return.startIndex
- The starting index to begin searching from.- Returns:
- The JMethodSignature, or null if not found.
-
getMethod
public JMethodSignature getMethod(int index)
Returns the JMethodSignature at the given index.- Parameters:
index
- The index of the JMethodSignature to return.- Returns:
- The JMethodSignature at the given index.
-
addMethod
public void addMethod(JMethodSignature jMethodSig)
Adds the given JMethodSignature to this Jinterface.- Parameters:
jMethodSig
- The JMethodSignature to add.
-
print
public void print(JSourceWriter jsw)
Deprecated.Please use the Velocity-template based approach instead.Prints the source code for this JStructure to the given JSourceWriter.- Specified by:
print
in classJStructure
- Parameters:
jsw
- The JSourceWriter to print to.- See Also:
SourceGenerator#setJClassPrinterType(String)
-
print
public void print(JSourceWriter jsw, boolean classOnly)
Deprecated.Please use the Velocity-template based approach instead.Prints the source code for this JInterface to the given JSourceWriter.- Parameters:
jsw
- The JSourceWriter to print to. Must not be null.classOnly
- If true, generates the class body without the class header, package declaration, or imports.- See Also:
SourceGenerator#setJClassPrinterType(String)
-
-