org.eclipse.emf.codegen.merge.java.facade.ast
Class ASTJMethod

java.lang.Object
  extended by org.eclipse.emf.codegen.merge.java.facade.AbstractJNode
      extended by org.eclipse.emf.codegen.merge.java.facade.ast.ASTJNode<T>
          extended by org.eclipse.emf.codegen.merge.java.facade.ast.ASTJMember<org.eclipse.jdt.core.dom.MethodDeclaration>
              extended by org.eclipse.emf.codegen.merge.java.facade.ast.ASTJMethod
All Implemented Interfaces:
JMember, JMethod, JNode

public class ASTJMethod
extends ASTJMember<org.eclipse.jdt.core.dom.MethodDeclaration>
implements JMethod

Wraps MethodDeclaration object.

Since:
2.2.0

Field Summary
protected  java.util.List<java.lang.String> addedExceptions
          List of added exceptions by calling addException(String).
protected  java.lang.String body
           
protected  java.lang.String[] exceptions
          Array of cached exceptions.
protected  java.lang.String[] parameterNames
           
protected  java.lang.String[] parameters
           
protected  java.lang.String returnType
           
protected  java.lang.String[] typeParameters
           
 
Fields inherited from class org.eclipse.emf.codegen.merge.java.facade.ast.ASTJMember
comment
 
Fields inherited from class org.eclipse.emf.codegen.merge.java.facade.ast.ASTJNode
isCommentedOut, name, rewriter, UNITIALIZED_STRING
 
Fields inherited from class org.eclipse.emf.codegen.merge.java.facade.AbstractJNode
EMPTY_STRING_ARRAY, qualifiedName
 
Constructor Summary
ASTJMethod(org.eclipse.jdt.core.dom.MethodDeclaration methodDeclaration)
           
 
Method Summary
 void addException(java.lang.String exceptionType)
          Adds the given exception to the end of the list of exceptions this method is declared to throw.
protected  java.lang.String computeQualifiedName()
           
 void dispose()
           
 java.lang.String getBody()
          Returns the body of this method.
 java.lang.String[] getExceptions()
          Returns the type signatures of the exceptions this method throws, in the order declared in the source.
 java.lang.String[] getFullParameterTypes()
          Returns all the types of formal parameters of the original method declaration.
 java.lang.String getName()
          Returns the name of this node.
 java.lang.String[] getParameterNames()
          Returns parameter names.
 java.lang.String[] getParameters()
          Returned parameters will not include new names set by setParameterNames(String[]).
 java.lang.String[] getParameterTypes()
          Returns type erasure of all the types of formal parameters of the original method declaration.
 java.lang.String getReturnType()
          Returns the return type name, or null.
 java.lang.String[] getTypeParameters()
          Returns the formal type parameters for this method.
 boolean isConstructor()
          Returns whether this method is a constructor.
 void setBody(java.lang.String body)
          Sets the body of this method.
 void setExceptions(java.lang.String[] exceptionTypes)
          Sets the names of the exception types this method throws, in the order in which they are declared in the source.
 void setName(java.lang.String name)
          Sets the name of this node.
 void setParameterNames(java.lang.String[] names)
          Sets parameter names.
 void setParameters(java.lang.String[] parameters)
          Sets the parameters in this method in the order they are to be declared.
 void setReturnType(java.lang.String type)
          Sets the return type name.
 void setTypeParameters(java.lang.String[] typeParameters)
          Sets the formal type parameters for this method.
 
Methods inherited from class org.eclipse.emf.codegen.merge.java.facade.ast.ASTJMember
addChild, getAnnotationList, getChildren, getComment, getFlags, insertLastAnnotation, insertSibling, remove, setComment, setFlags
 
Methods inherited from class org.eclipse.emf.codegen.merge.java.facade.ast.ASTJNode
addValueToListProperty, addValueToListProperty, ancestorInserted, ancestorToBeRemoved, childToBeChanged, combineArrayAndList, commentOut, convertASTNodeListToStringArray, disableTrackAndReplace, enableTrackAndReplace, getASTNode, getContents, getFacadeHelper, getParent, getRemovedASTNode, getRewriter, getWrappedObject, insert, insertFirst, insertLast, isDisposed, nodeToBeMoved, nodeToBeRemoved, remove, removeNodeFromListProperty, removeTrackAndReplace, setASTNode, setFacadeHelper, setListNodeProperty, setNodeProperty, setNodeProperty, setParent, setRemovedASTNode, setRewriter, setTrackedNodeProperty, setWrappedObject, trackAndReplace
 
Methods inherited from class org.eclipse.emf.codegen.merge.java.facade.AbstractJNode
computeQualifiedName, computeQualifiedName, computeQualifiedName, getName, getQualifiedName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.emf.codegen.merge.java.facade.JMember
getComment, setComment
 
Methods inherited from interface org.eclipse.emf.codegen.merge.java.facade.JNode
getChildren, getContents, getFlags, getParent, getQualifiedName, setFlags
 

Field Detail

returnType

protected java.lang.String returnType

typeParameters

protected java.lang.String[] typeParameters

parameterNames

protected java.lang.String[] parameterNames

parameters

protected java.lang.String[] parameters

exceptions

protected java.lang.String[] exceptions
Array of cached exceptions. Current exceptions is a combination of this array and addedExceptions.


addedExceptions

protected java.util.List<java.lang.String> addedExceptions
List of added exceptions by calling addException(String). This list does not include existing exceptions, nor exceptions set by setExceptions(String[])


body

protected java.lang.String body
Constructor Detail

ASTJMethod

public ASTJMethod(org.eclipse.jdt.core.dom.MethodDeclaration methodDeclaration)
Parameters:
methodDeclaration -
Method Detail

dispose

public void dispose()
Overrides:
dispose in class ASTJMember<org.eclipse.jdt.core.dom.MethodDeclaration>

isConstructor

public boolean isConstructor()
Description copied from interface: JMethod
Returns whether this method is a constructor.

Specified by:
isConstructor in interface JMethod
Returns:
true for constructors, and false for methods

getName

public java.lang.String getName()
Description copied from interface: JNode
Returns the name of this node.

Specified by:
getName in interface JNode
Returns:
the name, or null if it has no name

setName

public void setName(java.lang.String name)
Description copied from interface: JNode
Sets the name of this node. If the name is used to match the nodes to be merged, it is highly recommended not to use this method.

Specified by:
setName in interface JNode
See Also:
JNode.getQualifiedName()

getReturnType

public java.lang.String getReturnType()
Description copied from interface: JMethod
Returns the return type name, or null. Returns null for constructors. The syntax for return type name corresponds to ReturnType in MethodDeclaration (JLS2 8.4). Names are returned as they appear in the source code; for example: "File", "java.io.File", "int[]", or "void".

Specified by:
getReturnType in interface JMethod
Returns:
the return type

setReturnType

public void setReturnType(java.lang.String type)
Description copied from interface: JMethod
Sets the return type name. This has no effect on constructors. The syntax for return type name corresponds to ReturnType in MethodDeclaration (JLS2 8.4). Type names are specified as they appear in the source code; for example: "File", "java.io.File", "int[]", or "void".

Specified by:
setReturnType in interface JMethod
Parameters:
type - the return type

getTypeParameters

public java.lang.String[] getTypeParameters()
Description copied from interface: JMethod
Returns the formal type parameters for this method. Returns an empty array if this method has no formal type parameters.

Formal type parameters are as they appear in the source code; for example: "X extends List<String> & Serializable".

Specified by:
getTypeParameters in interface JMethod
Returns:
the formal type parameters of this method, in the order declared in the source, or an empty array if no type parameters are declared

setTypeParameters

public void setTypeParameters(java.lang.String[] typeParameters)
Description copied from interface: JMethod
Sets the formal type parameters for this method.

Specified by:
setTypeParameters in interface JMethod
Parameters:
typeParameters - in the order declared in the source, or an empty array if no type parameters are declared

getParameterNames

public java.lang.String[] getParameterNames()
Returns parameter names.

Note that if parameters have been changed by setParameters(String[]) method, this method will not parse parameters, and will not return the new parameter names. This method will return either parameter names set by setParameterNames(String[]) method or original parameter names.

Specified by:
getParameterNames in interface JMethod
Returns:
the list of parameter names, or an empty array if no parameters are declared
See Also:
JMethod.getParameterNames()

getParameterTypes

public java.lang.String[] getParameterTypes()
Returns type erasure of all the types of formal parameters of the original method declaration.

This method is used to create a method signature, and match methods by signature.

Note that this implementation does not expand types into fully qualified names, nor does it replace type parameters defined for a class or a method.

Specified by:
getParameterTypes in interface JMethod
Returns:
the list of the erased types of the parameters, or an empty array if no parameters are declared
See Also:
ASTFacadeHelper.getTypeErasure(org.eclipse.jdt.core.dom.Type), JMethod.getParameterTypes()

getFullParameterTypes

public java.lang.String[] getFullParameterTypes()
Returns all the types of formal parameters of the original method declaration. Note that this implementation does not expand types into fully qualified names, nor does it replace type parameters defined for a class or a method.

Specified by:
getFullParameterTypes in interface JMethod
Returns:
the list of the full types of the parameters, or an empty array if no parameters are declared
See Also:
JMethod.getFullParameterTypes()

setParameterNames

public void setParameterNames(java.lang.String[] names)
Sets parameter names. New parameter names will not be returned by getParameters(), but will be returned by getParameterNames().

Specified by:
setParameterNames in interface JMethod
Parameters:
names - the list of parameter names
See Also:
getParameterNames(), getParameters(), JMethod.setParameterNames(java.lang.String[])

getExceptions

public java.lang.String[] getExceptions()
Description copied from interface: JMethod
Returns the type signatures of the exceptions this method throws, in the order declared in the source. Returns an empty array if this method throws no exceptions.

For example, a source method declaring "throws IOException", would return the array {"QIOException;"}.

The type signatures may be either unresolved (for source types) or resolved (for binary types), and either basic (for basic types) or rich (for parameterized types).

Specified by:
getExceptions in interface JMethod
Returns:
the list of the exceptions, or an empty array if no exceptions are declared

setExceptions

public void setExceptions(java.lang.String[] exceptionTypes)
Description copied from interface: JMethod
Sets the names of the exception types this method throws, in the order in which they are declared in the source. An empty array indicates this method declares no exception types. The syntax for an exception type name is defined by Method Throws (JLS2 8.4.4). Type names must be specified as they would appear in source code. For example: "IOException" or "java.io.IOException".

Specified by:
setExceptions in interface JMethod
Parameters:
exceptionTypes - the list of exception types

addException

public void addException(java.lang.String exceptionType)
Description copied from interface: JMethod
Adds the given exception to the end of the list of exceptions this method is declared to throw. The syntax for an exception type name is defined by Method Throws (JLS2 8.4.4). Type names must be specified as they would appear in source code. For example: "IOException" or "java.io.IOException". This is a convenience method for setExceptions.

Specified by:
addException in interface JMethod
Parameters:
exceptionType - the exception type
See Also:
JMethod.setExceptions(String[])

getBody

public java.lang.String getBody()
Description copied from interface: JMethod
Returns the body of this method. The method body includes all code following the method declaration, including the enclosing braces.

Specified by:
getBody in interface JMethod
Returns:
the body, or null if the method has no body (for example, for an abstract or native method)

setBody

public void setBody(java.lang.String body)
Description copied from interface: JMethod
Sets the body of this method. The method body includes all code following the method declaration, including the enclosing braces. No formatting or syntax checking is performed on the body.

Specified by:
setBody in interface JMethod
Parameters:
body - the body, or null indicating the method has no body (for example, for an abstract or native method)

computeQualifiedName

protected java.lang.String computeQualifiedName()
Overrides:
computeQualifiedName in class AbstractJNode

getParameters

public java.lang.String[] getParameters()
Returned parameters will not include new names set by setParameterNames(String[]).

Specified by:
getParameters in interface JMethod
Returns:
the list of parameters, or or an empty array if no parameters are declared
See Also:
JMethod.getParameters()

setParameters

public void setParameters(java.lang.String[] parameters)
Description copied from interface: JMethod
Sets the parameters in this method in the order they are to be declared. The syntax for the parameters is defined by Formal Parameters (JLS2 and JLS3 8.4.1). Types and parameter names must be specified as they would appear in source code. For example: "File file", "java.io.File file", or "int[][] n[]", or final @Annotation int[]... n.

Specified by:
setParameters in interface JMethod
Parameters:
parameters - the list of parameters, or or an empty array if no parameters are declared

Copyright 2001-2006 IBM Corporation and others.
All Rights Reserved.