Class JInterface
java.lang.Object
org.exolab.javasource.JType
org.exolab.javasource.JStructure
org.exolab.javasource.JInterface
- All Implemented Interfaces:
JAnnotatedElement
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
-
Field Summary
Fields inherited from class JType
BOOLEAN, BYTE, CHAR, DOUBLE, FLOAT, INT, LONG, SHORTModifier and TypeFieldDescriptionstatic final JPrimitiveTypeJType for a boolean (Boolean).static final JPrimitiveTypeJType instance for a byte (Byte).static final JPrimitiveTypeJType instance for a char (Char).static final JPrimitiveTypeJType instance for a double (Double).static final JPrimitiveTypeJType instance for a float (Float).static final JPrimitiveTypeJType instance for a int (Integer).static final JPrimitiveTypeJType instance for a long (Long).static final JPrimitiveTypeJType instance for a short (Short). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the given JField to this Jinterface.voidAdds the given import to this JStructure.voidAdds the given JMember to this Jinterface.voidaddMethod(JMethodSignature jMethodSig) Adds the given JMethodSignature to this Jinterface.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 Jinterface.getMethod(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.voidprint(JSourceWriter jsw) Deprecated.Please use the Velocity-template based approach instead.voidprint(JSourceWriter jsw, boolean classOnly) Deprecated.Please use the Velocity-template based approach instead.Methods inherited from class 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, toStringModifier and TypeMethodDescriptionfinal voidaddAnnotation(JAnnotation annotation) Adds a JAnnotation to this source element.protected final voidaddImport(JAnnotation annotation) Adds appropriate import for this JAnnotation.protected final voidaddImport(JAnnotation[] annotations) Adds appropriate imports for each JAnnotation in the given Array.protected final voidaddImportInternal(String className) Adds the given import to this JStructure.final voidaddInterface(String interfaceName) Adds the given interface to the list of interfaces this JStructure inherits method declarations from, and either implements (JClass) or extends (JInterface).protected final JAnnotatedElementHelperReturns the object managing the annotations for this JStructure.final JAnnotationgetAnnotation(JAnnotationType annotationType) Retrieves a JAnnotation for the given JAnnotationType, returns null if no annotation has been set.final JAnnotation[]Returns a list of JAnnotation's already set on this source element.final StringgetFilename(String destDir) Returns the name of the file that this JStructure would be printed to, given a call toJStructure.print(String, String).final JCommentReturns the JComment header to display at the top of the source file for this JStructure, or null if no header was set.final intReturns the amount of imports.final Enumeration<String> Returns an Enumeration of imported package and class names for this JStructure.final intReturn the count of the number of Interfaces that have been added to this JStructure.final Enumeration<String> Returns an Enumeration of interface names that this JStructure inherits from.final JDocCommentReturns the JavaDoc comment for this JStructure.final JModifiersReturns the JModifiers, which allows the qualifiers to be changed.final StringReturns the name of the package that this JStructure is a member of.final booleanReturns true if this source element has any annotations.final booleanReturns true if the given classname exists in the imports of this JStructure.final booleanisAnnotationPresent(JAnnotationType annotationType) Returns true if a JAnnotation exists for the given JAnnotationType.final voidPrints the source code for this JStructure to the destination directory.final voidprintHeader(JSourceWriter jsw) A utility method that prints the header to the given JSourceWriter.protected final voidA utility method that prints the imports to the given JSourceWriter.final voidA utility method that prints the packageDeclaration to the given JSourceWriter.final JAnnotationremoveAnnotation(JAnnotationType annotationType) Removes the JAnnotation from this source element for the given JAnnotationType.final booleanremoveImport(String className) Remove the import of the given class name from this JStucture, returning true if the import was found and removed.final booleanremoveInterface(String interfaceName) Removes the given interface from the list of interfaces thisJStructurehas.final voidSets the header comment for this JStructure.final StringtoString()
Returns the String representation of this JType.Methods inherited from class JType
getLocalName, getName, isArray, isPrimitive, setNameModifier and TypeMethodDescriptionfinal StringReturns the unqualified Java type name (i.e.final StringgetName()Returns the qualified Java type name.final booleanisArray()Returns true if this type represents an Array.final booleanReturns true if this type represents a Java primitive type.protected voidSets the qualified name of this type.
-
Constructor Details
-
JInterface
Creates a new JInterface with the given name.- Parameters:
name- The name of the JInterface.
-
-
Method Details
-
addImport
Adds the given import to this JStructure. Note: You cannot import from the "default package," so imports with no package are ignored.- Specified by:
addImportin classJStructure- Parameters:
className- Name of the class to import.
-
addMember
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:
addMemberin classJStructure- Parameters:
jMember- The JMember to add to this JStructure.
-
getFields
Returns an array of all the JFields of this Jinterface.- Specified by:
getFieldsin classJStructure- Returns:
- An array of all the JFields of this Jinterface.
-
getField
Returns the field with the given name, or null if no field was found with the given name.- Specified by:
getFieldin 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
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:
addFieldin classJStructure- Parameters:
jField- The JField to add.
-
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.
-
addMethod
Adds the given JMethodSignature to this Jinterface.- Parameters:
jMethodSig- The JMethodSignature to add.
-
print
Deprecated.Please use the Velocity-template based approach instead.Prints the source code for this JStructure to the given JSourceWriter.- Specified by:
printin classJStructure- Parameters:
jsw- The JSourceWriter to print to.- See Also:
-
print
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:
-