JavaTM 2 Platform
Standard Ed. 6

类 java.lang.reflect.Method
的使用

使用 Method 的软件包
java.beans 包含与开发 beans 有关的类,即基于 JavaBeansTM 架构的组件。 
java.lang 提供利用 Java 编程语言进行程序设计的基础类。 
java.lang.annotation 为 Java 编程语言注释设施提供库支持。 
java.lang.reflect 提供类和接口,以获得关于类和对象的反射信息。 
java.rmi.server 提供支持服务器端 RMI 的类和接口。 
javax.management 提供 Java Management Extensions 的核心类。 
javax.management.modelmbean 提供了 ModelMBean 类的定义。 
javax.management.openmbean 提供开放数据类型和 Open MBean 描述符类。 
 

java.beansMethod 的使用
 

返回 Methodjava.beans 中的方法
 Method EventSetDescriptor.getAddListenerMethod()
          获得用来添加事件侦听器的方法。
 Method EventSetDescriptor.getGetListenerMethod()
          获得用来访问已注册事件侦听器的方法。
 Method IndexedPropertyDescriptor.getIndexedReadMethod()
          获得应该用于读取索引属性值的方法。
 Method IndexedPropertyDescriptor.getIndexedWriteMethod()
          获得应该用于写入索引属性值的方法。
 Method[] EventSetDescriptor.getListenerMethods()
          获得目标侦听器接口的方法。
 Method MethodDescriptor.getMethod()
          获得此 MethodDescriptor 封装的方法。
 Method PropertyDescriptor.getReadMethod()
          获得应该用于读取属性值的方法。
 Method EventSetDescriptor.getRemoveListenerMethod()
          获得用来移除事件侦听器的方法。
 Method PropertyDescriptor.getWriteMethod()
          获得应该用于写入属性值的方法。
 

参数类型为 Methodjava.beans 中的方法
 Object EventHandler.invoke(Object proxy, Method method, Object[] arguments)
          从事件中提取适当属性值,并将其传递到与此 EventHandler 相关联的动作。
 void IndexedPropertyDescriptor.setIndexedReadMethod(Method readMethod)
          设置应该用于读取索引属性值的方法。
 void IndexedPropertyDescriptor.setIndexedWriteMethod(Method writeMethod)
          设置应该用于写入索引属性值的方法。
 void PropertyDescriptor.setReadMethod(Method readMethod)
          设置应该用于读取属性值的方法。
 void PropertyDescriptor.setWriteMethod(Method writeMethod)
          设置应该用于写入属性值的方法。
 

参数类型为 Methodjava.beans 中的构造方法
EventSetDescriptor(String eventSetName, Class<?> listenerType, Method[] listenerMethods, Method addListenerMethod, Method removeListenerMethod)
          使用 java.lang.reflect.Methodjava.lang.Class 对象从头开始创建 EventSetDescriptor
EventSetDescriptor(String eventSetName, Class<?> listenerType, Method[] listenerMethods, Method addListenerMethod, Method removeListenerMethod)
          使用 java.lang.reflect.Methodjava.lang.Class 对象从头开始创建 EventSetDescriptor
EventSetDescriptor(String eventSetName, Class<?> listenerType, Method[] listenerMethods, Method addListenerMethod, Method removeListenerMethod, Method getListenerMethod)
          此构造方法使用 java.lang.reflect.Method 和 java.lang.Class 对象从头开始创建 EventSetDescriptor。
EventSetDescriptor(String eventSetName, Class<?> listenerType, Method[] listenerMethods, Method addListenerMethod, Method removeListenerMethod, Method getListenerMethod)
          此构造方法使用 java.lang.reflect.Method 和 java.lang.Class 对象从头开始创建 EventSetDescriptor。
EventSetDescriptor(String eventSetName, Class<?> listenerType, MethodDescriptor[] listenerMethodDescriptors, Method addListenerMethod, Method removeListenerMethod)
          使用 java.lang.reflect.MethodDescriptorjava.lang.Class 对象从头开始创建 EventSetDescriptor
IndexedPropertyDescriptor(String propertyName, Method readMethod, Method writeMethod, Method indexedReadMethod, Method indexedWriteMethod)
          此构造方法带有某一简单属性的名称,以及用来读取和写入属性的 Method 对象。
MethodDescriptor(Method method)
          根据 Method 构造一个 MethodDescriptor
MethodDescriptor(Method method, ParameterDescriptor[] parameterDescriptors)
          根据为每个方法参数提供描述性信息的 Method 构造一个 MethodDescriptor
PropertyDescriptor(String propertyName, Method readMethod, Method writeMethod)
          此构造方法带有某一简单属性的名称,以及用来读取和写入属性的 Method 对象。
 

java.langMethod 的使用
 

返回 Methodjava.lang 中的方法
 Method Class.getDeclaredMethod(String name, Class<?>... parameterTypes)
          返回一个 Method 对象,该对象反映此 Class 对象所表示的类或接口的指定已声明方法。
 Method[] Class.getDeclaredMethods()
          返回 Method 对象的一个数组,这些对象反映此 Class 对象表示的类或接口声明的所有方法,包括公共、保护、默认(包)访问和私有方法,但不包括继承的方法。
 Method Class.getEnclosingMethod()
          如果此 Class 对象表示某一方法中的一个本地或匿名类,则返回 Method 对象,它表示底层类的立即封闭方法。
 Method Class.getMethod(String name, Class<?>... parameterTypes)
          返回一个 Method 对象,它反映此 Class 对象所表示的类或接口的指定公共成员方法。
 Method[] Class.getMethods()
          返回一个包含某些 Method 对象的数组,这些对象反映此 Class 对象所表示的类或接口(包括那些由该类或接口声明的以及从超类和超接口继承的那些的类或接口)的公共 member 方法。
 

java.lang.annotationMethod 的使用
 

返回 Methodjava.lang.annotation 中的方法
 Method AnnotationTypeMismatchException.element()
          返回类型不正确的元素的 Method 对象。
 

参数类型为 Methodjava.lang.annotation 中的构造方法
AnnotationTypeMismatchException(Method element, String foundType)
          构造针对指定的注释类型元素和找到的数据类型的 AnnotationTypeMismatchException。
 

java.lang.reflectMethod 的使用
 

参数类型为 Methodjava.lang.reflect 中的方法
 Object InvocationHandler.invoke(Object proxy, Method method, Object[] args)
          在代理实例上处理方法调用并返回结果。
 

java.rmi.serverMethod 的使用
 

参数类型为 Methodjava.rmi.server 中的方法
 Object RemoteObjectInvocationHandler.invoke(Object proxy, Method method, Object[] args)
          处理在封装的代理实例 proxy 上进行的方法调用并返回结果。
 Object RemoteRef.invoke(Remote obj, Method method, Object[] params, long opnum)
          调用某个方法。
 

javax.managementMethod 的使用
 

参数类型为 Methodjavax.management 中的方法
 Object MBeanServerInvocationHandler.invoke(Object proxy, Method method, Object[] args)
           
 

参数类型为 Methodjavax.management 中的构造方法
MBeanAttributeInfo(String name, String description, Method getter, Method setter)
          此构造方法带有简单属性的名称,以及读取和写入属性的 Method 对象。
MBeanOperationInfo(String description, Method method)
          构造一个 MBeanOperationInfo 对象。
 

javax.management.modelmbeanMethod 的使用
 

参数类型为 Methodjavax.management.modelmbean 中的构造方法
ModelMBeanAttributeInfo(String name, String description, Method getter, Method setter)
          构造具有默认描述符的 ModelMBeanAttributeInfo 对象。
ModelMBeanAttributeInfo(String name, String description, Method getter, Method setter, Descriptor descriptor)
          构造 ModelMBeanAttributeInfo 对象。
ModelMBeanOperationInfo(String description, Method operationMethod)
          构造带有默认描述符的 ModelMBeanOperationInfo 对象。
ModelMBeanOperationInfo(String description, Method operationMethod, Descriptor descriptor)
          构造 ModelMBeanOperationInfo 对象。
 

javax.management.openmbeanMethod 的使用
 

参数类型为 Methodjavax.management.openmbean 中的方法
 Object CompositeDataInvocationHandler.invoke(Object proxy, Method method, Object[] args)
           
 


JavaTM 2 Platform
Standard Ed. 6

提交错误或意见

版权所有 2008 Sun Microsystems, Inc. 保留所有权利。请遵守GNU General Public License, version 2 only