站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 2.0.5 API 文档英文版

MethodParameter (Spring Framework API 2.0) - Spring Framework 2.0.5 API 文档英文版

The Spring Framework

org.springframework.core
Class MethodParameter

java.lang.Object
  extended by org.springframework.core.MethodParameter

public class MethodParameter
extends Object

Helper class that encapsulates the specification of a method parameter, i.e. a Method or Constructor plus a parameter index and a nested type index for a declared generic type. Useful as a specification object to pass along.

Used by GenericCollectionTypeResolver, BeanWrapperImpl and AbstractBeanFactory.

Note that this class does not depend on JDK 1.5 API artifacts, in order to remain compatible with JDK 1.3/1.4. Concrete generic type resolution via JDK 1.5 API happens in GenericCollectionTypeResolver only.

Since:
2.0
Author:
Juergen Hoeller, Rob Harrop
See Also:
GenericCollectionTypeResolver

Constructor Summary
MethodParameter(Constructor constructor, int parameterIndex)
          Create a new MethodParameter for the given constructor, with nesting level 1.
MethodParameter(Constructor constructor, int parameterIndex, int nestingLevel)
          Create a new MethodParameter for the given constructor.
MethodParameter(Method method, int parameterIndex)
          Create a new MethodParameter for the given method, with nesting level 1.
MethodParameter(Method method, int parameterIndex, int nestingLevel)
          Create a new MethodParameter for the given method.
 
Method Summary
 void decreaseNestingLevel()
          Decrease this parameter's nesting level.
static MethodParameter forMethodOrConstructor(Object methodOrConstructor, int parameterIndex)
          Create a new MethodParameter for the given method or constructor.
 Constructor getConstructor()
          Return the Constructor held, if any.
 Method getMethod()
          Return the Method held, if any.
 int getNestingLevel()
          Return the nesting level of the target type (typically 1; e.g. in case of a List of Lists, 1 would indicate the nested List, whereas 2 would indicate the element of the nested List).
 int getParameterIndex()
          Return the index of the method/constructor parameter.
 Integer getTypeIndexForCurrentLevel()
          Return the type index for the current nesting level.
 Integer getTypeIndexForLevel(int nestingLevel)
          Return the type index for the specified nesting level.
 void increaseNestingLevel()
          Increase this parameter's nesting level.
 void setTypeIndexForCurrentLevel(int typeIndex)
          Set the type index for the current nesting level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MethodParameter

public MethodParameter(Method method,
                       int parameterIndex)
Create a new MethodParameter for the given method, with nesting level 1.

Parameters:
method - the Method to specify a parameter for
parameterIndex - the index of the parameter

MethodParameter

public MethodParameter(Method method,
                       int parameterIndex,
                       int nestingLevel)
Create a new MethodParameter for the given method.

Parameters:
method - the Method to specify a parameter for
parameterIndex - the index of the parameter (-1 for the method return type; 0 for the first method parameter, 1 for the second method parameter, etc)
nestingLevel - the nesting level of the target type (typically 1; e.g. in case of a List of Lists, 1 would indicate the nested List, whereas 2 would indicate the element of the nested List)

MethodParameter

public MethodParameter(Constructor constructor,
                       int parameterIndex)
Create a new MethodParameter for the given constructor, with nesting level 1.

Parameters:
constructor - the Constructor to specify a parameter for
parameterIndex - the index of the parameter

MethodParameter

public MethodParameter(Constructor constructor,
                       int parameterIndex,
                       int nestingLevel)
Create a new MethodParameter for the given constructor.

Parameters:
constructor - the Constructor to specify a parameter for
parameterIndex - the index of the parameter
nestingLevel - the nesting level of the target type (typically 1; e.g. in case of a List of Lists, 1 would indicate the nested List, whereas 2 would indicate the element of the nested List)
Method Detail

getMethod

public Method getMethod()
Return the Method held, if any.

Note: Either Method or Constructor is available.

Returns:
the Method, or null if none

getConstructor

public Constructor getConstructor()
Return the Constructor held, if any.

Note: Either Method or Constructor is available.

Returns:
the Constructor, or null if none

getParameterIndex

public int getParameterIndex()
Return the index of the method/constructor parameter.

Returns:
the parameter index (never negative)

increaseNestingLevel

public void increaseNestingLevel()
Increase this parameter's nesting level.

See Also:
getNestingLevel()

decreaseNestingLevel

public void decreaseNestingLevel()
Decrease this parameter's nesting level.

See Also:
getNestingLevel()

getNestingLevel

public int getNestingLevel()
Return the nesting level of the target type (typically 1; e.g. in case of a List of Lists, 1 would indicate the nested List, whereas 2 would indicate the element of the nested List).


setTypeIndexForCurrentLevel

public void setTypeIndexForCurrentLevel(int typeIndex)
Set the type index for the current nesting level.

Parameters:
typeIndex - the corresponding type index (or null for the default type index)
See Also:
getNestingLevel()

getTypeIndexForCurrentLevel

public Integer getTypeIndexForCurrentLevel()
Return the type index for the current nesting level.

Returns:
the corresponding type index, or null if none specified (indicating the default type index)
See Also:
getNestingLevel()

getTypeIndexForLevel

public Integer getTypeIndexForLevel(int nestingLevel)
Return the type index for the specified nesting level.

Parameters:
nestingLevel - the nesting level to check
Returns:
the corresponding type index, or null if none specified (indicating the default type index)

forMethodOrConstructor

public static MethodParameter forMethodOrConstructor(Object methodOrConstructor,
                                                     int parameterIndex)
Create a new MethodParameter for the given method or constructor.

This is a convenience constructor for scenarios where a Method or Constructor reference is treated in a generic fashion.

Parameters:
methodOrConstructor - the Method or Constructor to specify a parameter for
parameterIndex - the index of the parameter
Returns:
the corresponding MethodParameter instance

The Spring Framework

Copyright © 2002-2007 The Spring Framework.