Edit C:\apache-ant-1.8.0\docs\manual\api\org\apache\tools\ant\util\ReflectUtil.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--NewPage--> <HTML> <HEAD> <!-- Generated by javadoc (build 1.5.0_22) on Mon Feb 01 19:35:59 EST 2010 --> <TITLE> ReflectUtil (Apache Ant API) </TITLE> <META NAME="keywords" CONTENT="org.apache.tools.ant.util.ReflectUtil class"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style"> <SCRIPT type="text/javascript"> function windowTitle() { parent.document.title="ReflectUtil (Apache Ant API)"; } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <!-- ========= START OF TOP NAVBAR ======= --> <A NAME="navbar_top"><!-- --></A> <A HREF="#skip-navbar_top" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../org/apache/tools/ant/util/ReaderInputStream.html" title="class in org.apache.tools.ant.util"><B>PREV CLASS</B></A> <A HREF="../../../../../org/apache/tools/ant/util/ReflectWrapper.html" title="class in org.apache.tools.ant.util"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../index.html?org/apache/tools/ant/util/ReflectUtil.html" target="_top"><B>FRAMES</B></A> <A HREF="ReflectUtil.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> <TR> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_top"></A> <!-- ========= END OF TOP NAVBAR ========= --> <HR> <!-- ======== START OF CLASS DATA ======== --> <H2> <FONT SIZE="-1"> org.apache.tools.ant.util</FONT> <BR> Class ReflectUtil</H2> <PRE> java.lang.Object <IMG SRC="../../../../../resources/inherit.gif" ALT="extended by "><B>org.apache.tools.ant.util.ReflectUtil</B> </PRE> <HR> <DL> <DT><PRE>public class <B>ReflectUtil</B><DT>extends java.lang.Object</DL> </PRE> <P> Utility class to handle reflection on java objects. The class contains static methods to call reflection methods, catch any exceptions, converting them to BuildExceptions. <P> <P> <HR> <P> <!-- ========== METHOD SUMMARY =========== --> <A NAME="method_summary"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> <B>Method Summary</B></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static java.lang.Object</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/tools/ant/util/ReflectUtil.html#getField(java.lang.Object, java.lang.String)">getField</A></B>(java.lang.Object obj, java.lang.String fieldName)</CODE> <BR> Get the value of a field in an object.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static java.lang.Object</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/tools/ant/util/ReflectUtil.html#invoke(java.lang.Object, java.lang.String)">invoke</A></B>(java.lang.Object obj, java.lang.String methodName)</CODE> <BR> Call a method on the object with no parameters.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static java.lang.Object</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/tools/ant/util/ReflectUtil.html#invoke(java.lang.Object, java.lang.String, java.lang.Class, java.lang.Object)">invoke</A></B>(java.lang.Object obj, java.lang.String methodName, java.lang.Class argType, java.lang.Object arg)</CODE> <BR> Call a method on the object with one argument.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static java.lang.Object</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/tools/ant/util/ReflectUtil.html#invoke(java.lang.Object, java.lang.String, java.lang.Class, java.lang.Object, java.lang.Class, java.lang.Object)">invoke</A></B>(java.lang.Object obj, java.lang.String methodName, java.lang.Class argType1, java.lang.Object arg1, java.lang.Class argType2, java.lang.Object arg2)</CODE> <BR> Call a method on the object with two argument.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static java.lang.Object</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/tools/ant/util/ReflectUtil.html#invokeStatic(java.lang.Object, java.lang.String)">invokeStatic</A></B>(java.lang.Object obj, java.lang.String methodName)</CODE> <BR> Call a method on the object with no parameters.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static java.lang.Object</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/tools/ant/util/ReflectUtil.html#newInstance(java.lang.Class, java.lang.Class[], java.lang.Object[])">newInstance</A></B>(java.lang.Class ofClass, java.lang.Class[] argTypes, java.lang.Object[] args)</CODE> <BR> Create an instance of a class using the constructor matching the given arguments.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static boolean</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/tools/ant/util/ReflectUtil.html#respondsTo(java.lang.Object, java.lang.String)">respondsTo</A></B>(java.lang.Object o, java.lang.String methodName)</CODE> <BR> A method to test if an object responds to a given message (method call)</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/tools/ant/util/ReflectUtil.html#throwBuildException(java.lang.Exception)">throwBuildException</A></B>(java.lang.Exception t)</CODE> <BR> A method to convert an invocationTargetException to a buildexception and throw it.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <A HREF="../../../../../org/apache/tools/ant/BuildException.html" title="class in org.apache.tools.ant">BuildException</A></CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/tools/ant/util/ReflectUtil.html#toBuildException(java.lang.Exception)">toBuildException</A></B>(java.lang.Exception t)</CODE> <BR> A method to convert an invocationTargetException to a buildexception.</TD> </TR> </TABLE> <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> <TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD> </TR> </TABLE> <P> <!-- ============ METHOD DETAIL ========== --> <A NAME="method_detail"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> <B>Method Detail</B></FONT></TH> </TR> </TABLE> <A NAME="newInstance(java.lang.Class, java.lang.Class[], java.lang.Object[])"><!-- --></A><H3> newInstance</H3> <PRE> public static java.lang.Object <B>newInstance</B>(java.lang.Class ofClass, java.lang.Class[] argTypes, java.lang.Object[] args)</PRE> <DL> <DD>Create an instance of a class using the constructor matching the given arguments. <P> <DD><DL> <DT><B>Since:</B></DT> <DD>Ant 1.8.0</DD> </DL> </DD> </DL> <HR> <A NAME="invoke(java.lang.Object, java.lang.String)"><!-- --></A><H3> invoke</H3> <PRE> public static java.lang.Object <B>invoke</B>(java.lang.Object obj, java.lang.String methodName)</PRE> <DL> <DD>Call a method on the object with no parameters. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>obj</CODE> - the object to invoke the method on.<DD><CODE>methodName</CODE> - the name of the method to call <DT><B>Returns:</B><DD>the object returned by the method</DL> </DD> </DL> <HR> <A NAME="invokeStatic(java.lang.Object, java.lang.String)"><!-- --></A><H3> invokeStatic</H3> <PRE> public static java.lang.Object <B>invokeStatic</B>(java.lang.Object obj, java.lang.String methodName)</PRE> <DL> <DD>Call a method on the object with no parameters. Note: Unlike the invoke method above, this calls class or static methods, not instance methods. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>obj</CODE> - the object to invoke the method on.<DD><CODE>methodName</CODE> - the name of the method to call <DT><B>Returns:</B><DD>the object returned by the method</DL> </DD> </DL> <HR> <A NAME="invoke(java.lang.Object, java.lang.String, java.lang.Class, java.lang.Object)"><!-- --></A><H3> invoke</H3> <PRE> public static java.lang.Object <B>invoke</B>(java.lang.Object obj, java.lang.String methodName, java.lang.Class argType, java.lang.Object arg)</PRE> <DL> <DD>Call a method on the object with one argument. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>obj</CODE> - the object to invoke the method on.<DD><CODE>methodName</CODE> - the name of the method to call<DD><CODE>argType</CODE> - the type of argument.<DD><CODE>arg</CODE> - the value of the argument. <DT><B>Returns:</B><DD>the object returned by the method</DL> </DD> </DL> <HR> <A NAME="invoke(java.lang.Object, java.lang.String, java.lang.Class, java.lang.Object, java.lang.Class, java.lang.Object)"><!-- --></A><H3> invoke</H3> <PRE> public static java.lang.Object <B>invoke</B>(java.lang.Object obj, java.lang.String methodName, java.lang.Class argType1, java.lang.Object arg1, java.lang.Class argType2, java.lang.Object arg2)</PRE> <DL> <DD>Call a method on the object with two argument. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>obj</CODE> - the object to invoke the method on.<DD><CODE>methodName</CODE> - the name of the method to call<DD><CODE>argType1</CODE> - the type of the first argument.<DD><CODE>arg1</CODE> - the value of the first argument.<DD><CODE>argType2</CODE> - the type of the second argument.<DD><CODE>arg2</CODE> - the value of the second argument. <DT><B>Returns:</B><DD>the object returned by the method</DL> </DD> </DL> <HR> <A NAME="getField(java.lang.Object, java.lang.String)"><!-- --></A><H3> getField</H3> <PRE> public static java.lang.Object <B>getField</B>(java.lang.Object obj, java.lang.String fieldName) throws <A HREF="../../../../../org/apache/tools/ant/BuildException.html" title="class in org.apache.tools.ant">BuildException</A></PRE> <DL> <DD>Get the value of a field in an object. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>obj</CODE> - the object to look at.<DD><CODE>fieldName</CODE> - the name of the field in the object. <DT><B>Returns:</B><DD>the value of the field. <DT><B>Throws:</B> <DD><CODE><A HREF="../../../../../org/apache/tools/ant/BuildException.html" title="class in org.apache.tools.ant">BuildException</A></CODE> - if there is an error.</DL> </DD> </DL> <HR> <A NAME="throwBuildException(java.lang.Exception)"><!-- --></A><H3> throwBuildException</H3> <PRE> public static void <B>throwBuildException</B>(java.lang.Exception t) throws <A HREF="../../../../../org/apache/tools/ant/BuildException.html" title="class in org.apache.tools.ant">BuildException</A></PRE> <DL> <DD>A method to convert an invocationTargetException to a buildexception and throw it. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>t</CODE> - the invocation target exception. <DT><B>Throws:</B> <DD><CODE><A HREF="../../../../../org/apache/tools/ant/BuildException.html" title="class in org.apache.tools.ant">BuildException</A></CODE> - the converted exception.</DL> </DD> </DL> <HR> <A NAME="toBuildException(java.lang.Exception)"><!-- --></A><H3> toBuildException</H3> <PRE> public static <A HREF="../../../../../org/apache/tools/ant/BuildException.html" title="class in org.apache.tools.ant">BuildException</A> <B>toBuildException</B>(java.lang.Exception t)</PRE> <DL> <DD>A method to convert an invocationTargetException to a buildexception. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>t</CODE> - the invocation target exception. <DT><B>Returns:</B><DD>the converted exception.<DT><B>Since:</B></DT> <DD>ant 1.7.1</DD> </DL> </DD> </DL> <HR> <A NAME="respondsTo(java.lang.Object, java.lang.String)"><!-- --></A><H3> respondsTo</H3> <PRE> public static boolean <B>respondsTo</B>(java.lang.Object o, java.lang.String methodName) throws <A HREF="../../../../../org/apache/tools/ant/BuildException.html" title="class in org.apache.tools.ant">BuildException</A></PRE> <DL> <DD>A method to test if an object responds to a given message (method call) <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>o</CODE> - the object<DD><CODE>methodName</CODE> - the method to check for <DT><B>Returns:</B><DD>true if the object has the method. <DT><B>Throws:</B> <DD><CODE><A HREF="../../../../../org/apache/tools/ant/BuildException.html" title="class in org.apache.tools.ant">BuildException</A></CODE> - if there is a problem.</DL> </DD> </DL> <!-- ========= END OF CLASS DATA ========= --> <HR> <!-- ======= START OF BOTTOM NAVBAR ====== --> <A NAME="navbar_bottom"><!-- --></A> <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_bottom_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../org/apache/tools/ant/util/ReaderInputStream.html" title="class in org.apache.tools.ant.util"><B>PREV CLASS</B></A> <A HREF="../../../../../org/apache/tools/ant/util/ReflectWrapper.html" title="class in org.apache.tools.ant.util"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../index.html?org/apache/tools/ant/util/ReflectUtil.html" target="_top"><B>FRAMES</B></A> <A HREF="ReflectUtil.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> <TR> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_bottom"></A> <!-- ======== END OF BOTTOM NAVBAR ======= --> <HR> </BODY> </HTML>
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de