org.exolab.javasource
Class JEnumConstant

java.lang.Object
  extended by org.exolab.javasource.JAnnotatedElementHelper
      extended by org.exolab.javasource.JEnumConstant
All Implemented Interfaces:
JAnnotatedElement, JMember

public class JEnumConstant
extends JAnnotatedElementHelper
implements JMember

Class describes the definition of a enum constant

Author:
Andrew Fawcett

Constructor Summary
JEnumConstant(java.lang.String name)
          Constructs a JEnumConstant with a given name
JEnumConstant(java.lang.String name, java.lang.String[] arguments)
          Constructs a JEnumConstant with a given name
 
Method Summary
 void addMethod(JMethod jMethod)
          Adds the given JMethod to this JClass
 void addMethod(JMethod jMethod, boolean importReturnType)
          Adds the given JMethod to this JClass
 void addMethods(JMethod[] jMethods)
          Adds the given array of JMethods to this JClass
 java.lang.String[] getArguments()
          Returns the arguments used by this constant
 JDocComment getComment()
          Returns the comment describing this member.
 JMethod getMethod(int index)
          Returns the JMethod located at the specified index
 JMethod getMethod(java.lang.String name, int startIndex)
          Returns the first occurance of the method with the given name, starting from the specified index.
 JMethod[] getMethods()
          Returns an array of all the JMethods of this JClass
 JModifiers getModifiers()
          Returns the modifiers for this JEnumConstant
 java.lang.String getName()
          Returns the name of this JEnumConstant
static void main(java.lang.String[] args)
          Test drive
 void print(JSourceWriter jsw)
          Outputs the enum constant
 void setArguments(java.lang.String[] args)
          Sets the arguments specified by this constant
 void setComment(JDocComment comment)
          Sets the comment describing this member.
 void setComment(java.lang.String comment)
          Sets the comment describing this member.
 void setName(java.lang.String name)
          Sets the name of this JEnumConstant
 
Methods inherited from class org.exolab.javasource.JAnnotatedElementHelper
addAnnotation, getAnnotation, getAnnotations, hasAnnotations, isAnnotationPresent, printAnnotations, removeAnnotation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JEnumConstant

public JEnumConstant(java.lang.String name)
Constructs a JEnumConstant with a given name

Parameters:
name -

JEnumConstant

public JEnumConstant(java.lang.String name,
                     java.lang.String[] arguments)
Constructs a JEnumConstant with a given name

Parameters:
name -
arguments -
Method Detail

getModifiers

public JModifiers getModifiers()
Returns the modifiers for this JEnumConstant

Specified by:
getModifiers in interface JMember
Returns:
the modifiers for this JEnumConstant

setArguments

public void setArguments(java.lang.String[] args)
Sets the arguments specified by this constant

Parameters:
args -

getArguments

public java.lang.String[] getArguments()
Returns the arguments used by this constant

Returns:

addMethod

public void addMethod(JMethod jMethod)
Adds the given JMethod to this JClass

Parameters:
jMethod, - the JMethod to add
Throws:
java.lang.IllegalArgumentException - when the given JMethod has the same name of an existing JMethod.

addMethod

public void addMethod(JMethod jMethod,
                      boolean importReturnType)
               throws java.lang.IllegalArgumentException
Adds the given JMethod to this JClass

Parameters:
jMethod, - the JMethod to add
importReturnType - true if we add the importReturnType to the class import lists. It could be useful to set it to false when all types are fully qualified.
Throws:
java.lang.IllegalArgumentException - when the given JMethod has the same name of an existing JMethod.

addMethods

public void addMethods(JMethod[] jMethods)
                throws java.lang.IllegalArgumentException
Adds the given array of JMethods to this JClass

Parameters:
jMethods, - the JMethod[] to add
Throws:
java.lang.IllegalArgumentException - when any of the given JMethods has the same name of an existing JMethod.

getMethods

public JMethod[] getMethods()
Returns an array of all the JMethods of this JClass

Returns:
an array of all the JMethods of this JClass

getMethod

public JMethod getMethod(java.lang.String name,
                         int startIndex)
Returns the first occurance of the method with the given name, starting from the specified index.

Parameters:
name - the name of the method to look for
startIndex - the starting index to begin the search
Returns:
the method if found, otherwise null.

getMethod

public JMethod getMethod(int index)
Returns the JMethod located at the specified index

Parameters:
index - the index of the JMethod to return.
Returns:
the JMethod

setName

public void setName(java.lang.String name)
             throws java.lang.IllegalArgumentException
Sets the name of this JEnumConstant

Parameters:
name - the name of this JEnumConstant
Throws:
java.lang.IllegalArgumentException - when the name is not a valid Java member name

getName

public java.lang.String getName()
Returns the name of this JEnumConstant

Specified by:
getName in interface JMember
Returns:
the name of this JEnumConstant

setComment

public void setComment(JDocComment comment)
Sets the comment describing this member.

Parameters:
comment - the JDocComment for this member

setComment

public void setComment(java.lang.String comment)
Sets the comment describing this member.

Parameters:
comment - the JDocComment for this member

getComment

public JDocComment getComment()
Returns the comment describing this member.

Returns:
the comment describing this member, or null if no comment has been set.

print

public void print(JSourceWriter jsw)
Outputs the enum constant

Parameters:
jsw -

main

public static void main(java.lang.String[] args)
Test drive

Parameters:
args -


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