org.exolab.javasource

Class JEnumConstant

public class JEnumConstant extends JAnnotatedElementHelper implements JMember

Class describes the definition of a enum constant

Author: Andrew Fawcett

Constructor Summary
JEnumConstant(String name)
Constructs a JEnumConstant with a given name
JEnumConstant(String name, String[] arguments)
Constructs a JEnumConstant with a given name
Method Summary
voidaddMethod(JMethod jMethod)
Adds the given JMethod to this JClass
voidaddMethod(JMethod jMethod, boolean importReturnType)
Adds the given JMethod to this JClass
voidaddMethods(JMethod[] jMethods)
Adds the given array of JMethods to this JClass
String[]getArguments()
Returns the arguments used by this constant
JDocCommentgetComment()
Returns the comment describing this member.
JMethodgetMethod(String name, int startIndex)
Returns the first occurance of the method with the given name, starting from the specified index.
JMethodgetMethod(int index)
Returns the JMethod located at the specified index
JMethod[]getMethods()
Returns an array of all the JMethods of this JClass
JModifiersgetModifiers()
Returns the modifiers for this JEnumConstant
StringgetName()
Returns the name of this JEnumConstant
static voidmain(String[] args)
Test drive
voidprint(JSourceWriter jsw)
Outputs the enum constant
voidsetArguments(String[] args)
Sets the arguments specified by this constant
voidsetComment(JDocComment comment)
Sets the comment describing this member.
voidsetComment(String comment)
Sets the comment describing this member.
voidsetName(String name)
Sets the name of this JEnumConstant

Constructor Detail

JEnumConstant

public JEnumConstant(String name)
Constructs a JEnumConstant with a given name

Parameters: name

JEnumConstant

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

Parameters: name arguments

Method Detail

addMethod

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

Parameters: jMethod, the JMethod to add

Throws: IllegalArgumentException when the given JMethod has the same name of an existing JMethod.

addMethod

public void addMethod(JMethod jMethod, boolean importReturnType)
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: IllegalArgumentException when the given JMethod has the same name of an existing JMethod.

addMethods

public void addMethods(JMethod[] jMethods)
Adds the given array of JMethods to this JClass

Parameters: jMethods, the JMethod[] to add

Throws: IllegalArgumentException when any of the given JMethods has the same name of an existing JMethod.

getArguments

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

Returns:

getComment

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

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

getMethod

public JMethod getMethod(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

getMethods

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

Returns: an array of all the JMethods of this JClass

getModifiers

public JModifiers getModifiers()
Returns the modifiers for this JEnumConstant

Returns: the modifiers for this JEnumConstant

getName

public String getName()
Returns the name of this JEnumConstant

Returns: the name of this JEnumConstant

main

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

Parameters: args

print

public void print(JSourceWriter jsw)
Outputs the enum constant

Parameters: jsw

setArguments

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

Parameters: args

setComment

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

Parameters: comment the JDocComment for this member

setComment

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

Parameters: comment the JDocComment for this member

setName

public void setName(String name)
Sets the name of this JEnumConstant

Parameters: name the name of this JEnumConstant

Throws: IllegalArgumentException when the name is not a valid Java member name

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