class.html
来自「API資料大全」· HTML 代码 · 共 1,325 行 · 第 1/5 页
HTML
1,325 行
<DT><B>Returns:</B><DD>the array of <code>Class</code> objects representing the public members of this class<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - if access to the information is denied.<DT><B>Since: </B><DD>JDK1.1</DD><DT><B>See Also: </B><DD><A HREF="../../java/lang/SecurityManager.html#checkMemberAccess(java.lang.Class, int)"><CODE>SecurityManager.checkMemberAccess(Class, int)</CODE></A>, <A HREF="../../java/lang/SecurityManager.html#checkPackageAccess(java.lang.String)"><CODE>SecurityManager.checkPackageAccess(String)</CODE></A></DL></DD></DL><HR><A NAME="getFields()"><!-- --></A><H3>getFields</H3><PRE>public <A HREF="../../java/lang/reflect/Field.html">Field</A>[] <B>getFields</B>() throws <A HREF="../../java/lang/SecurityException.html">SecurityException</A></PRE><DL><DD>Returns an array containing <code>Field</code> objects reflecting all the accessible public fields of the class or interface represented by this <code>Class</code> object. The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if the class or interface has no accessible public fields, or if it represents an array class, a primitive type, or void. <p> Specifically, if this <code>Class</code> object represents a class, this method returns the public fields of this class and of all its superclasses. If this <code>Class</code> object represents an interface, this method returns the fields of this interface and of all its superinterfaces. <p>If there is a security manager, this method first calls the security manager's <code>checkMemberAccess</code> method with <code>this</code> and <code>Member.PUBLIC</code> as its arguments. If the class is in a package, then this method also calls the security manager's <code>checkPackageAccess</code> method with the package name as its argument. Either of these calls could result in a SecurityException. <p> The implicit length field for array classs is not reflected by this method. User code should use the methods of class <code>Array</code> to manipulate arrays. <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.3.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the array of <code>Field</code> objects representing the public fields<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - if access to the information is denied.<DT><B>Since: </B><DD>JDK1.1</DD><DT><B>See Also: </B><DD><A HREF="../../java/lang/reflect/Field.html"><CODE>Field</CODE></A>, <A HREF="../../java/lang/SecurityManager.html#checkMemberAccess(java.lang.Class, int)"><CODE>SecurityManager.checkMemberAccess(Class, int)</CODE></A>, <A HREF="../../java/lang/SecurityManager.html#checkPackageAccess(java.lang.String)"><CODE>SecurityManager.checkPackageAccess(String)</CODE></A></DL></DD></DL><HR><A NAME="getMethods()"><!-- --></A><H3>getMethods</H3><PRE>public <A HREF="../../java/lang/reflect/Method.html">Method</A>[] <B>getMethods</B>() throws <A HREF="../../java/lang/SecurityException.html">SecurityException</A></PRE><DL><DD>Returns an array containing <code>Method</code> objects reflecting all the public <em>member</em> methods of the class or interface represented by this <code>Class</code> object, including those declared by the class or interface and and those inherited from superclasses and superinterfaces. The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if this <code>Class</code> object represents a class or interface that has no public member methods, or if this <code>Class</code> object represents an array class, primitive type, or void. <p>If there is a security manager, this method first calls the security manager's <code>checkMemberAccess</code> method with <code>this</code> and <code>Member.PUBLIC</code> as its arguments. If the class is in a package, then this method also calls the security manager's <code>checkPackageAccess</code> method with the package name as its argument. Either of these calls could result in a SecurityException. <p> The class initialization method <code><clinit></code> is not included in the returned array. If the class declares multiple public member methods with the same parameter types, they are all included in the returned array. <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.4.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the array of <code>Method</code> objects representing the public methods of this class<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - if access to the information is denied.<DT><B>Since: </B><DD>JDK1.1</DD><DT><B>See Also: </B><DD><A HREF="../../java/lang/reflect/Method.html"><CODE>Method</CODE></A>, <A HREF="../../java/lang/SecurityManager.html#checkMemberAccess(java.lang.Class, int)"><CODE>SecurityManager.checkMemberAccess(Class, int)</CODE></A>, <A HREF="../../java/lang/SecurityManager.html#checkPackageAccess(java.lang.String)"><CODE>SecurityManager.checkPackageAccess(String)</CODE></A></DL></DD></DL><HR><A NAME="getConstructors()"><!-- --></A><H3>getConstructors</H3><PRE>public <A HREF="../../java/lang/reflect/Constructor.html">Constructor</A>[] <B>getConstructors</B>() throws <A HREF="../../java/lang/SecurityException.html">SecurityException</A></PRE><DL><DD>Returns an array containing <code>Constructor</code> objects reflecting all the public constructors of the class represented by this <code>Class</code> object. An array of length 0 is returned if the class has no public constructors, or if the class is an array class, or if the class reflects a primitive type or void. <p>If there is a security manager, this method first calls the security manager's <code>checkMemberAccess</code> method with <code>this</code> and <code>Member.PUBLIC</code> as its arguments. If the class is in a package, then this method also calls the security manager's <code>checkPackageAccess</code> method with the package name as its argument. Either of these calls could result in a SecurityException.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the array containing <code>Method</code> objects for all the declared public constructors of this class matches the specified <code>parameterTypes</code><DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - if access to the information is denied.<DT><B>Since: </B><DD>JDK1.1</DD><DT><B>See Also: </B><DD><A HREF="../../java/lang/reflect/Constructor.html"><CODE>Constructor</CODE></A>, <A HREF="../../java/lang/SecurityManager.html#checkMemberAccess(java.lang.Class, int)"><CODE>SecurityManager.checkMemberAccess(Class, int)</CODE></A>, <A HREF="../../java/lang/SecurityManager.html#checkPackageAccess(java.lang.String)"><CODE>SecurityManager.checkPackageAccess(String)</CODE></A></DL></DD></DL><HR><A NAME="getField(java.lang.String)"><!-- --></A><H3>getField</H3><PRE>public <A HREF="../../java/lang/reflect/Field.html">Field</A> <B>getField</B>(<A HREF="../../java/lang/String.html">String</A> name) throws <A HREF="../../java/lang/NoSuchFieldException.html">NoSuchFieldException</A>, <A HREF="../../java/lang/SecurityException.html">SecurityException</A></PRE><DL><DD>Returns a <code>Field</code> object that reflects the specified public member field of the class or interface represented by this <code>Class</code> object. The <code>name</code> parameter is a <code>String</code> specifying the simple name of the desired field. <p>If there is a security manager, this method first calls the security manager's <code>checkMemberAccess</code> method with <code>this</code> and <code>Member.PUBLIC</code> as its arguments. If the class is in a package, then this method also calls the security manager's <code>checkPackageAccess</code> method with the package name as its argument. Either of these calls could result in a SecurityException. <p> The field to be reflected is determined by the algorithm that follows. Let C be the class represented by this object: <OL> <LI> If C declares a public field with the name specified, that is the field to be reflected.</LI> <LI> If no field was found in step 1 above, this algorithm is applied recursively to each direct superinterface of C. The direct superinterfaces are searched in the order they were declared.</LI> <LI> If no field was found in steps 1 and 2 above, and C has a superclass S, then this algorithm is invoked recursively upon S. If C has no superclass, then a <code>NoSuchFieldException</code> is thrown.</LI> </OL> <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.3.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>name</CODE> - the field name<DT><B>Returns:</B><DD>the <code>Field</code> object of this class specified by <code>name</code><DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/NoSuchFieldException.html">NoSuchFieldException</A></CODE> - if a field with the specified name is not found.<DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - if access to the information is denied.<DT><B>Since: </B><DD>JDK1.1</DD><DT><B>See Also: </B><DD><A HREF="../../java/lang/reflect/Field.html"><CODE>Field</CODE></A>, <A HREF="../../java/lang/SecurityManager.html#checkMemberAccess(java.lang.Class, int)"><CODE>SecurityManager.checkMemberAccess(Class, int)</CODE></A>, <A HREF="../../java/lang/SecurityManager.html#checkPackageAccess(java.lang.String)"><CODE>SecurityManager.checkPackageAccess(String)</CODE></A></DL></DD></DL><HR><A NAME="getMethod(java.lang.String, java.lang.Class[])"><!-- --></A><H3>getMethod</H3><PRE>public <A HREF="../../java/lang/reflect/Method.html">Method</A> <B>getMethod</B>(<A HREF="../../java/lang/String.html">String</A> name, <A HREF="../../java/lang/Class.html">Class</A>[] parameterTypes) throws <A HREF="../../java/lang/NoSuchMethodException.html">NoSuchMethodException</A>, <A HREF="../../java/lang/SecurityException.html">SecurityException</A></PRE><DL><DD>Returns a <code>Method</code> object that reflects the specified public member method of the class or interface represented by this <code>Class</code> object. The <code>name</code> parameter is a <code>String</code> specifying the simple name the desired method. The <code>parameterTypes</code> parameter is an array of <code>Class</code> objects that identify the method's formal parameter types, in declared order. If <code>parameterTypes</code> is <code>null</code>, it is treated as if it were an empty array. <p>If there is a security manager, this method first calls the security manager's <code>checkMemberAccess</code> method with <code>this</code> and <code>Member.PUBLIC</code> as its arguments. If the class is in a package, then this method also calls the security manager's <code>checkPackageAccess</code> method with the package name as its argument. Either of these calls could result in a SecurityException. <p> If the <code>name</code> is "<init>"or "<clinit>" a <code>NoSuchMethodException</code> is raised. Otherwise, the method to be reflected is determined by the algorithm that follows. Let C be the class represented by this object: <OL> <LI> C is searched for any <I>matching methods</I>. If no matching method is found, the algorithm of step 1 is invoked recursively on the superclass of C.</LI> <LI> If no method was found in step 1 above, the superinterfaces of C are searched for a matching method. If any such method is found, it is reflected.</LI> </OL> To find a matching method in a class C: If C declares exactly one public method with the specified name and exactly the same formal parameter types, that is the method reflected. If more than one such method is found in C, and one of these methods has a return type that is more specific than any of the others, that method is reflected; otherwise one of the methods is chosen arbitrarily. <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.4.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>name</CODE> - the name of the method<DD><CODE>parameterTypes</CODE> - the list of parameters<DT><B>Returns:</B><DD>the <code>Method</code> object that matches the specified <code>name</code> and <code>parameterTypes</code><DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/NoSuchMethodException.html">NoSuchMethodException</A></CODE> - if a matching method is not found or if then name is "<init>"or "<clinit>".<DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - if access to the information is denied.<DT><B>Since: </B><DD>JDK1.1</DD><DT><B>See Also: </B><DD><A HREF="../../java/lang/reflect/Method.html"><CODE>Method</CODE></A>, <A HREF="../../java/lang/SecurityManager.html#checkMemberAccess(java.lang.Class, int)"><CODE>SecurityManager.checkMemberAccess(Class, int)</CODE></A>, <A HREF="../../java/lang/SecurityManager.html#checkPackageAccess(java.lang.String)"><CODE>SecurityManager.checkPackageAccess(String)</CODE></A></DL></DD></DL><HR><A NAME="getConstructor(java.lang.Class[])"><!-- --></A><H3>getConstructor</H3><PRE>public <A HREF="../../java/lang/reflect/Constructor.html">Constructor</A> <B>getConstructor</B>(<A HREF="../../java/lang/Class.html">Class</A>[] parameterTypes) throws <A HREF="../../java/lang/NoSuchMethodException.html">NoSuchMethodException</A>, <A HREF="../../java/lang/SecurityException.html">SecurityException</A></PRE><DL><DD>Returns a <code>Constructor</code> object that reflects the specified public constructor of the class represented by this <code>Class</code> object. The <code>parameterTypes</code> parameter is an array of <code>Class</code> objects that identify the constructor's formal parameter types, in declared order. <p> The constructor to reflect is the public constructor of the class represented by this <code>Class</code> object whose formal parameter types match those specified by <code>parameterTypes</code>. <p>If there is a security manager, this method first calls the security manager's <code>checkMemberAccess</code> method with <code>this</code> and <code>Member.PUBLIC</code> as its arguments. If the class is in a package, then this method also calls the security manager's <code>checkPackageAccess</code> method with the package name as its argument. Either of these calls could result in a SecurityException.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>parameterTypes</CODE> - the parameter array<DT><B>Returns:</B><DD>the <code>Method</code> object of the public constructor that matches the specified <code>parameterTypes</code><DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/NoSuchMethodException.html">NoSuchMethodException</A></CODE> - if a matching method is not found.<DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - if access to the information is denied.<DT><B>Since: </B><DD>JDK1.1</DD><DT><B>See Also: </B><DD><A HREF="../../java/lang/reflect/Constructor.html"><CODE>Constructor</CODE></A>, <A HREF="../../java/lang/SecurityManager.html#checkMemberAccess(java.lang.Class, int)"><CODE>SecurityManager.checkMemberAccess(Class, int)</CODE></A>, <A HREF="../../java/lang/SecurityManager.html#che
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?