Class JInterface
java.lang.Object
org.codehaus.modello.plugin.java.javasource.JType
org.codehaus.modello.plugin.java.javasource.JStructure
org.codehaus.modello.plugin.java.javasource.JInterface
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 modelled after the Java Reflection API
as much as possible to reduce the learning curve.
- Version:
- $Revision$ $Date$
- Author:
- Martin Skopp, Keith Visco
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the given JField to this JStructure.void
addMember
(org.codehaus.modello.plugin.java.javasource.JMember jMember) Adds the given JMember to this JStructure.void
addMethod
(JMethodSignature jMethodSig) Adds the given JMethodSignature to this JClassvoid
addSourceCode
(String sourceCode) Returns the field with the given name, or null if no field was found with the given name.JField[]
Returns an array of all the JFields of this JStructuregetMethod
(int index) Returns the JMethodSignature at the given index.Returns the JMethodSignature with the given name, and occuring at or after the given starting index.Returns an array of all the JMethodSignatures of this JInterface.void
print
(JSourceWriter jsw) Prints the source code for this JInterface to the given JSourceWritervoid
print
(JSourceWriter jsw, boolean classOnly) Prints the source code for this JInterface to the given JSourceWriterMethods inherited from class org.codehaus.modello.plugin.java.javasource.JStructure
addImport, addInterface, addInterface, appendAnnotation, getAnnotations, getFilename, getHeader, getImports, getInterfaceCount, getInterfaces, getJDocComment, getModifiers, getName, getPackageFromClassName, getPackageName, hasImport, isAbstract, isValidClassName, print, print, printHeader, printImportDeclarations, printlnWithPrefix, printPackageDeclaration, removeImport, setAnnotations, setHeader
Methods inherited from class org.codehaus.modello.plugin.java.javasource.JType
changePackage, createArray, getComponentType, getLocalName, getName, isArray, isPrimitive, toString
-
Constructor Details
-
JInterface
Creates a new JInterface with the given name.- Parameters:
name
- the name of the JInterface.- Throws:
IllegalArgumentException
- when the given name is not a valid Class name.
-
-
Method Details
-
addField
Adds the given JField to this JStructure.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- Throws:
IllegalArgumentException
- when the given JField has a name of an existing JField
-
addMember
public void addMember(org.codehaus.modello.plugin.java.javasource.JMember jMember) throws IllegalArgumentException Adds the given JMember to this JStructure.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.- Throws:
IllegalArgumentException
- when the given JMember has the same name of an existing JField or JMethod respectively.
-
addMethod
Adds the given JMethodSignature to this JClass- Parameters:
jMethodSig
- the JMethodSignature to add.- Throws:
IllegalArgumentException
- when the given JMethodSignature conflicts with an existing method signature.
-
getField
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.
-
getFields
Returns an array of all the JFields of this JStructure- Specified by:
getFields
in classJStructure
- Returns:
- an array of all the JFields of this JStructure
-
getMethods
Returns an array of all the JMethodSignatures of this JInterface.- Returns:
- an array of all the JMethodSignatures of this JInterface.
-
getMethod
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
Returns the JMethodSignature at the given index.- Parameters:
index
- the index of the JMethodSignature to return.- Returns:
- the JMethodSignature at the given index.
-
print
Prints the source code for this JInterface to the given JSourceWriter- Specified by:
print
in classJStructure
- Parameters:
jsw
- the JSourceWriter to print to. [May not be null]
-
print
Prints the source code for this JInterface to the given JSourceWriter- Parameters:
jsw
- the JSourceWriter to print to. [May not be null]classOnly
- whether the header, package and imports should be printed too
-
addSourceCode
-