Class 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 Details

    • JInterface

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

    • addImport

      public void addImport(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 class JStructure
      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 class JStructure
      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 class JStructure
      Returns:
      An array of all the JFields of this Jinterface.
    • getField

      public JField getField(String name)
      Returns the field with the given name, or null if no field was found with the given name.
      Specified by:
      getField in class 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.
    • 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 class JStructure
      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(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 class JStructure
      Parameters:
      jsw - The JSourceWriter to print to.
      See Also:
      • invalid @see
        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:
      • invalid @see
        SourceGenerator#setJClassPrinterType(String)