jaxx.compiler
Class JavaMethod

java.lang.Object
  extended by jaxx.compiler.JavaMethod
All Implemented Interfaces:
java.lang.Comparable<JavaMethod>

public class JavaMethod
extends java.lang.Object
implements java.lang.Comparable<JavaMethod>

Represents a method in a Java source file being generated for output. JavaMethods are created and added to a JavaFile, which can then output Java source code. In addition to normal methods, a JavaMethod can represent a constructor -- constructors should be named after their containing classes and have a return type of null.


Nested Class Summary
static class JavaMethod.MethodOrder
           
 
Field Summary
static java.util.Comparator<JavaMethod> COMPARATOR
           
 
Constructor Summary
JavaMethod(int modifiers, java.lang.String returnType, java.lang.String name, JavaArgument[] arguments, java.lang.String[] exceptions, java.lang.String bodyCode)
          Constructs a new JavaMethod containing the specified body code.
 
Method Summary
 void appendBodyCode(java.lang.String extraCode, java.lang.String lineSeparator)
          Appends additional code to the method's body.
 int compareTo(JavaMethod o)
           
 JavaArgument[] getArguments()
          Returns a list of the method's arguments.
 java.lang.String getBodyCode()
          Returns the Java source code for the method's body.
 java.lang.String[] getExceptions()
          Returns a list of exceptions the method can throw.
static java.util.EnumSet<JavaMethod.MethodOrder> getMethodOrderScope(java.util.EnumSet<JavaMethod.MethodOrder> allConstants, int scope)
           
 int getModifiers()
          Returns a bit mask describing the modifier keywords which should appear as part of this method's declaration.
 java.lang.String getName()
          Returns the method's name.
 java.lang.String getReturnType()
          Returns the method's return type, as it would be represented in Java source code.
static java.util.EnumMap<JavaMethod.MethodOrder,java.util.List<JavaMethod>> getSortedMethods(java.util.List<JavaMethod> methods)
           
static JavaMethod newMethod(int modifiers, java.lang.String returnType, java.lang.String name, java.lang.String initializer, JavaArgument... arguments)
           
static JavaMethod newMethod(int modifiers, java.lang.String returnType, java.lang.String name, java.lang.String initializer, java.lang.String[] exceptions, JavaArgument... arguments)
           
 java.lang.String toString(java.lang.String lineSeparator)
          Returns the Java source code for this method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPARATOR

public static final java.util.Comparator<JavaMethod> COMPARATOR
Constructor Detail

JavaMethod

public JavaMethod(int modifiers,
                  java.lang.String returnType,
                  java.lang.String name,
                  JavaArgument[] arguments,
                  java.lang.String[] exceptions,
                  java.lang.String bodyCode)
Constructs a new JavaMethod containing the specified body code. The modifiers parameter is a bit mask of the constants from Modifier, and the returnType and exceptions of the method should be represented as they would appear in Java source code (null for a constructor). The method body is initially empty.

Parameters:
modifiers - the modifier keywords that should appear as part of the method's declaration
returnType - the return type of the method as it would appear in Java source code
name - the method's name
arguments - the method's arguments
exceptions - a list of exceptions the methods can throw, as they would be represented in Java source code
bodyCode - Java source code which should appear in the method body
Method Detail

getModifiers

public int getModifiers()
Returns a bit mask describing the modifier keywords which should appear as part of this method's declaration. See java.lang.reflect.Modifier for more information on decoding this field.

Returns:
the modifier bit mask

getReturnType

public java.lang.String getReturnType()
Returns the method's return type, as it would be represented in Java source code.

Returns:
the method's return type

getName

public java.lang.String getName()
Returns the method's name.

Returns:
the method's name

getArguments

public JavaArgument[] getArguments()
Returns a list of the method's arguments.

Returns:
the method's arguments

getExceptions

public java.lang.String[] getExceptions()
Returns a list of exceptions the method can throw.

Returns:
the method's exceptions

getBodyCode

public java.lang.String getBodyCode()
Returns the Java source code for the method's body.

Returns:
the method's body code

appendBodyCode

public void appendBodyCode(java.lang.String extraCode,
                           java.lang.String lineSeparator)
Appends additional code to the method's body.

Parameters:
extraCode - Java source code to append to the method's body
lineSeparator - line separator

toString

public java.lang.String toString(java.lang.String lineSeparator)
Returns the Java source code for this method.

Parameters:
lineSeparator - line separator
Returns:
the Java source code for this method

compareTo

public int compareTo(JavaMethod o)
Specified by:
compareTo in interface java.lang.Comparable<JavaMethod>

newMethod

public static JavaMethod newMethod(int modifiers,
                                   java.lang.String returnType,
                                   java.lang.String name,
                                   java.lang.String initializer,
                                   java.lang.String[] exceptions,
                                   JavaArgument... arguments)

newMethod

public static JavaMethod newMethod(int modifiers,
                                   java.lang.String returnType,
                                   java.lang.String name,
                                   java.lang.String initializer,
                                   JavaArgument... arguments)

getSortedMethods

public static java.util.EnumMap<JavaMethod.MethodOrder,java.util.List<JavaMethod>> getSortedMethods(java.util.List<JavaMethod> methods)

getMethodOrderScope

public static java.util.EnumSet<JavaMethod.MethodOrder> getMethodOrderScope(java.util.EnumSet<JavaMethod.MethodOrder> allConstants,
                                                                            int scope)


Copyright © 2008-2009 CodeLutin. All Rights Reserved.