# com.bea.ide.lang.java.element
JavaMethod Class

public class JavaMethod
extends `JavaMember`

JavaMethod is a DefaultSourceElement derivation that represents a java method declaration.

Objects of this type may have children of type `JavaArgument```, or `JavaComment``` if there is a javadoc comment block preceding the method declaration in the source code.

The properties available on an object of this type may be found by looking at the `getDefaultPropertyDescriptors``` method.

All java parse tree objects are instantiated as part of parse tree construction by the `JavaBuilder``` class.

Hierarchy
  `Object`
  `DefaultElement`
  `DefaultTreeElement`
  `DefaultDocumentElement`
  `DefaultSourceElement`
  `JavaElement`
  `JavaModifierSupport`
  `JavaMember`
  `JavaMethod`

All Implemented Interfaces
  `IDocumentElement`, `IElement`, `ISourceElement`, `IStructureFeature.IStructureNode`, `ITreeElement`

Direct Known Subclasses
  `ControlMethod`

## Nested Class Summary

Nested classes from com.bea.ide.sourceeditor.element`.`DefaultSourceElement``
``DefaultSourceElement.CompilerPropertyDescriptor`, `DefaultSourceElement.DefaultAuthorElement`, `DefaultSourceElement.StaticCompilerPropertyDescriptor`, `DefaultSourceElement.StickyRange``

## Field Summary

Fields from com.bea.ide.lang.java.element`.`JavaMember``
``PROP_THROWS``

Fields from com.bea.ide.lang.java.element`.`JavaModifierSupport``
``PROP_ABSTRACT`, `PROP_ACCESS`, `PROP_FINAL`, `PROP_NATIVE`, `PROP_STATIC`, `PROP_STRICTFP`, `PROP_SYNCHRONIZED`, `PROP_TRANSIENT`, `PROP_TYPE`, `PROP_VOLATILE``

Fields from com.bea.ide.sourceeditor.element`.`DefaultSourceElement``
``_range`, `PROP_NAME`, `PROP_VALUE``

Fields from com.bea.ide.element`.`DefaultTreeElement``
``_parent`, `_vChildren``

Fields from interface com.bea.ide.sourceeditor.element`.`ISourceElement``
``STATUS_IN_TREE`, `STATUS_NOT_IN_TREE`, `STATUS_REMOVED_FROM_TREE``

## Constructor Summary

JavaMethod() Creates a new object containing a null cookie.
JavaMethod(`Object` compilerCookie) Creates a new object containing the specified cookie.

## Method Summary

`public `String`` | `argsToString`() Returns an end-user-readable string of comma-delimited arguments for this method.
`protected `IStructureFeature.StructureCode`[]` | `getAdditionalRangeProperties`()
`public `DefaultSourceElement.CompilerPropertyDescriptor`[]` | `getDefaultPropertyDescriptors`() Objects of this type define the following properties: `JavaMethod.PROP_TYPE```: The return type for this method.
`public `String`` | `getMethodBody`() Returns the text of the body of this method.
`public `Range`` | `getMethodBodyRange`() Returns the range of text occupied by the body of this method.
`protected `Set`` | `getRangePrefetchProperties`() Returns a Set of IStructureFeature.StructureCode objects.
`public `String`[]` | `getThrownExceptions`() Gets the set of exceptions thrown by this JavaMethod
`public `String`` | `getType`() Gets the return type of this JavaMethod
`public `IStructureFeature.StructureCode`` | `getTypeCode`() This method returns a code used by the compiler to identify the type of this element.
`public boolean` | `setMethodBody`(`String` strBody) Replaces the body of this JavaMethod with the specified text.
`public boolean` | `setMethodBody`(`String` strBody, boolean blockForResult) Replaces the body of this JavaMethod with the specified text.
`public void` | `setThrownExceptions`(`String`[] exceptions) Sets the types of exceptions thrown by this JavaMethod
`public void` | `setType`(`String` newString) Sets the return type of this JavaMethod
`public `String`` | `toString`() Returns a nicely formatted string containing this method's name and arguments.
`public `Object`` | `visit`(`JavaVisitor` v, `Object` arg) Provides `JavaVisitor``` support for this element type.

Methods from `com.bea.ide.lang.java.element.`JavaMember``
``getAccess`, `getName`, `setAccess`, `setName`,`

Methods from `com.bea.ide.lang.java.element.`JavaModifierSupport``
``getAbstract`, `getDefaultPropertyDescriptors`, `getFinal`, `getNative`, `getStatic`, `getStrictFloatingPoint`, `getSynchronized`, `getTransient`, `getVolatile`, `mergePropertyDescriptors`, `setAbstract`, `setFinal`, `setNative`, `setStatic`, `setStrictFloatingPoint`, `setSynchronized`, `setTransient`, `setVolatile``

Methods from `com.bea.ide.sourceeditor.element.`DefaultSourceElement``
``addChild`, `createAuthorNode`, `debugDump`, `equals`, `getChildrenByClass`, `getClassLoader`, `getCookie`, `getDefaultPropertyDescriptors`, `getDiagnostics`, `getGroup`, `getInstanceName`, `getProperty`, `getPropertyCode`, `getPropertyDescriptors`, `getPropertySourceRange`, `getPropertySourceRanges`, `getPropertySourceText`, `getPropertySourceText`, `getRange`, `getRange`, `getStatus`, `initializeRange`, `initializeRange`, `insertChild`, `isAuthorProperty`, `markRemovedFromTree`, `mergeElements`, `mergeFrom`, `propertyModified`, `removeChild`, `removeChild`, `replaceChild`, `requestAddChild`, `requestAddChild`, `requestRemoveChild`, `requestSetProperty`, `setProperty`, `setStatus``

Methods from `com.bea.ide.document.`DefaultDocumentElement``
``addChild`, `getDocument`, `setDocument``

Methods from `com.bea.ide.element.`DefaultTreeElement``
``addChild`, `children`, `getChild`, `getChildCount`, `getParent`, `removeChild``

Methods from `com.bea.ide.element.`DefaultElement``
``getProperty`, `getPropertyDescriptors`, `setProperty``

Methods from class `java.lang.`Object``
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods from interface `com.bea.ide.document.`IDocumentElement``
``getDocument``

Methods from interface `com.bea.ide.element.`IElement``
``getProperty`, `getPropertyDescriptors`, `setProperty``

Methods from interface `com.bea.ide.sourceeditor.element.`ISourceElement``
``createAuthorNode`, `getCookie`, `getDiagnostics`, `getPropertyCode`, `getRange`, `getStatus`, `mergeFrom`, `requestAddChild`, `requestAddChild`, `requestRemoveChild`, `requestSetProperty``

Methods from interface `com.bea.compiler.feature.`IStructureFeature.IStructureNode``
`getCookie, getTypeCode`

Methods from interface `com.bea.ide.element.`ITreeElement``
``children`, `getChild`, `getChildCount`, `getParent``

## Constructor Detail

### JavaMethod

    public JavaMethod()

  Creates a new object containing a null cookie. This constructor should be used by callers constructing objects that are not part of an active parse tree, such as those to be added via two-way edit.

### JavaMethod

    public JavaMethod(Object compilerCookie)

  Creates a new object containing the specified cookie. This constructor should only be called by `ILanguageBuilder``` implementations.

## Method Detail

### argsToString() Method

    public String argsToString()

Returns an end-user-readable string of comma-delimited arguments for this method.

### getAdditionalRangeProperties() Method

    protected IStructureFeature.StructureCode[] getAdditionalRangeProperties()

### getDefaultPropertyDescriptors() Method

    public DefaultSourceElement.CompilerPropertyDescriptor[] getDefaultPropertyDescriptors()

Objects of this type define the following properties:
`JavaMethod.PROP_TYPE```: The return type for this method.
`JavaMethod.PROP_THROWS```: The 'throws' clause for this method.

Additionally, all DefaultSourceElement derivations also inherit all properties returned by `getDefaultPropertyDescriptors` from all super classes.

Overrides
  `JavaMember.getDefaultPropertyDescriptors()`

### getMethodBody() Method

    public String getMethodBody()

Returns the text of the body of this method.

### getMethodBodyRange() Method

    public Range getMethodBodyRange()

Returns the range of text occupied by the body of this method. It is extremely dangerous to cache this information in any way, since range information changes with every end-user keystroke in the source code.

### getRangePrefetchProperties() Method

    protected Set getRangePrefetchProperties()

Description copied from `DefaultSourceElement.getRangePrefetchProperties()`
Returns a Set of IStructureFeature.StructureCode objects. This set defines those properties that will contain range information in the parse tree.

Overrides
  `DefaultSourceElement.getRangePrefetchProperties()`

### getThrownExceptions() Method

    public String[] getThrownExceptions()

Gets the set of exceptions thrown by this JavaMethod

### getType() Method

    public String getType()

Gets the return type of this JavaMethod

### getTypeCode() Method

    public IStructureFeature.StructureCode getTypeCode()

This method returns a code used by the compiler to identify the type of this element. This method should not be called directly, since the return value isn't useful outside of the compiler.

Overrides
  `DefaultSourceElement.getTypeCode()`

#### Returns

A compiler structure code identifying the type of this element.

### setMethodBody(String) Method

    public boolean setMethodBody(String strBody)

Replaces the body of this JavaMethod with the specified text.

#### Parameters

strBody
  the new body text for this method

#### Returns

boolean indicating success or failure.

### setMethodBody(String, boolean) Method

    public boolean setMethodBody(String strBody,
                                 boolean blockForResult)

Replaces the body of this JavaMethod with the specified text.

#### Parameters

strBody
  the new body text for this method

#### Returns

boolean indicating success or failure.

### setThrownExceptions(String[]) Method

    public void setThrownExceptions(String[] exceptions)

Sets the types of exceptions thrown by this JavaMethod

### setType(String) Method

    public void setType(String newString)

Sets the return type of this JavaMethod

### toString() Method

    public String toString()

Returns a nicely formatted string containing this method's name and arguments.

Overrides
  `JavaMember.toString()`

### visit(JavaVisitor, Object) Method

    public Object visit(JavaVisitor v,
                        Object arg)

Provides `JavaVisitor``` support for this element type.

Overrides
  `JavaElement.visit(JavaVisitor, Object)`

#### Parameters

v
  The visitor

arg
  An argument to the visit, to be interpreted by the visitor.

#### Returns

Object returned by the visitor.