org.exolab.javasource

Class JInterface

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 modelled after the Java Reflection API as much as possible to reduce the learning curve.
Version:
$Revision: 6324 $ $Date: 2005-02-26 17:30:28 -0700 (Sat, 26 Feb 2005) $
Authors:
Martin Skopp
Keith Visco

Field Summary

Fields inherited from class org.exolab.javasource.JType

BOOLEAN, BYTE, CHAR, DOUBLE, FLOAT, INT, LONG, SHORT

Constructor Summary

JInterface(String name)
Creates a new JInterface with the given name..

Method Summary

void
addField(JField jField)
Adds the given JField to this Jinterface.
void
addMember(JMember jMember)
Adds the given JMember to this Jinterface.
void
addMethod(JMethodSignature jMethodSig)
Adds the given JMethodSignature to this Jinterface.
JField
getField(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(String name, int startIndex)
Returns the JMethodSignature with the given name and occuring at or after the given starting index.
JMethodSignature
getMethod(int index)
Returns the JMethodSignature at the given index.
JMethodSignature[]
getMethods()
Returns an array of all the JMethodSignatures of this JInterface.
void
print(JSourceWriter jsw)
Prints the source code for this JInterface to the given JSourceWriter.
void
print(JSourceWriter jsw, boolean classOnly)
Prints the source code for this JInterface to the given JSourceWriter.

Methods inherited from class org.exolab.javasource.JStructure

addAnnotation, addField, addImport, addImport, addImport, addInterface, addInterface, addMember, getAnnotatedElementHelper, getAnnotation, getAnnotations, getField, getFields, getFilename, getHeader, getImports, getInterfaceCount, getInterfaces, getJDocComment, getModifiers, getName, getPackageFromClassName, getPackageName, hasAnnotations, hasImport, isAnnotationPresent, isValidClassName, print, print, print, printHeader, printImportDeclarations, printPackageDeclaration, printlnWithPrefix, removeAnnotation, removeImport, setHeader, setPackageName

Methods inherited from class org.exolab.javasource.JType

changePackage, getLocalName, getName, getWrapperName, isArray, isPrimitive, toString

Constructor Details

JInterface

public JInterface(String name)
Creates a new JInterface with the given name..
Parameters:
name - the name of the JInterface.

Method Details

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.

Overrides:
addField in interface JStructure
Parameters:
jField - the JField to add

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.

Overrides:
addMember in interface JStructure
Parameters:
jMember - the JMember to add to this JStructure.

addMethod

public void addMethod(JMethodSignature jMethodSig)
Adds the given JMethodSignature to this Jinterface.
Parameters:
jMethodSig - the JMethodSignature to add.

getField

public JField getField(String name)
Returns the field with the given name, or null if no field was found with the given name.
Overrides:
getField in interface JStructure
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

public JField[] getFields()
Returns an array of all the JFields of this Jinterface.
Overrides:
getFields in interface JStructure
Returns:
an array of all the JFields of this Jinterface.

getMethod

public JMethodSignature getMethod(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.

getMethods

public JMethodSignature[] getMethods()
Returns an array of all the JMethodSignatures of this JInterface.
Returns:
an array of all the JMethodSignatures of this JInterface.

print

public void print(JSourceWriter jsw)
Prints the source code for this JInterface to the given JSourceWriter.
Overrides:
print in interface JStructure
Parameters:
jsw - the JSourceWriter to print to. Must not be null.

print

public void print(JSourceWriter jsw,
                  boolean classOnly)
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.

Intalio Inc. (C) 1999-2006. All rights reserved http://www.intalio.com