????

Your IP : 216.73.216.152


Current Path : /opt/ant/manual/api/org/apache/tools/ant/util/
Upload File :
Current File : //opt/ant/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 lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_03) on Tue May 22 06:24:55 CEST 2012 -->
<title>ReflectUtil (Apache Ant API)</title>
<meta name="date" content="2012-05-22">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
    if (location.href.indexOf('is-external=true') == -1) {
        parent.document.title="ReflectUtil (Apache Ant API)";
    }
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!--   -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!--   -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/tools/ant/util/ReaderInputStream.html" title="class in org.apache.tools.ant.util"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../../org/apache/tools/ant/util/ReflectWrapper.html" title="class in org.apache.tools.ant.util"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/tools/ant/util/ReflectUtil.html" target="_top">Frames</a></li>
<li><a href="ReflectUtil.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_top");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!--   -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.tools.ant.util</div>
<h2 title="Class ReflectUtil" class="title">Class ReflectUtil</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>org.apache.tools.ant.util.ReflectUtil</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public class <span class="strong">ReflectUtil</span>
extends java.lang.Object</pre>
<div class="block">Utility class to handle reflection on java objects.
 The class contains static methods to call reflection
 methods, catch any exceptions, converting them
 to BuildExceptions.</div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!--   -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.lang.Object</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/tools/ant/util/ReflectUtil.html#getField(java.lang.Object, java.lang.String)">getField</a></strong>(java.lang.Object&nbsp;obj,
        java.lang.String&nbsp;fieldName)</code>
<div class="block">Get the value of a field in an object.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static java.lang.Object</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/tools/ant/util/ReflectUtil.html#invoke(java.lang.Object, java.lang.String)">invoke</a></strong>(java.lang.Object&nbsp;obj,
      java.lang.String&nbsp;methodName)</code>
<div class="block">Call a method on the object with no parameters.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.lang.Object</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/tools/ant/util/ReflectUtil.html#invoke(java.lang.Object, java.lang.String, java.lang.Class, java.lang.Object)">invoke</a></strong>(java.lang.Object&nbsp;obj,
      java.lang.String&nbsp;methodName,
      java.lang.Class&nbsp;argType,
      java.lang.Object&nbsp;arg)</code>
<div class="block">Call a method on the object with one argument.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static java.lang.Object</code></td>
<td class="colLast"><code><strong><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></strong>(java.lang.Object&nbsp;obj,
      java.lang.String&nbsp;methodName,
      java.lang.Class&nbsp;argType1,
      java.lang.Object&nbsp;arg1,
      java.lang.Class&nbsp;argType2,
      java.lang.Object&nbsp;arg2)</code>
<div class="block">Call a method on the object with two argument.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.lang.Object</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/tools/ant/util/ReflectUtil.html#invokeStatic(java.lang.Object, java.lang.String)">invokeStatic</a></strong>(java.lang.Object&nbsp;obj,
            java.lang.String&nbsp;methodName)</code>
<div class="block">Call a method on the object with no parameters.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static java.lang.Object</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/tools/ant/util/ReflectUtil.html#newInstance(java.lang.Class, java.lang.Class[], java.lang.Object[])">newInstance</a></strong>(java.lang.Class&nbsp;ofClass,
           java.lang.Class[]&nbsp;argTypes,
           java.lang.Object[]&nbsp;args)</code>
<div class="block">Create an instance of a class using the constructor matching
 the given arguments.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static boolean</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/tools/ant/util/ReflectUtil.html#respondsTo(java.lang.Object, java.lang.String)">respondsTo</a></strong>(java.lang.Object&nbsp;o,
          java.lang.String&nbsp;methodName)</code>
<div class="block">A method to test if an object responds to a given
 message (method call)</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/tools/ant/util/ReflectUtil.html#throwBuildException(java.lang.Exception)">throwBuildException</a></strong>(java.lang.Exception&nbsp;t)</code>
<div class="block">A method to convert an invocationTargetException to
 a buildexception and throw it.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static <a href="../../../../../org/apache/tools/ant/BuildException.html" title="class in org.apache.tools.ant">BuildException</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/tools/ant/util/ReflectUtil.html#toBuildException(java.lang.Exception)">toBuildException</a></strong>(java.lang.Exception&nbsp;t)</code>
<div class="block">A method to convert an invocationTargetException to
 a buildexception.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
<!--   -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!--   -->
</a>
<h3>Method Detail</h3>
<a name="newInstance(java.lang.Class, java.lang.Class[], java.lang.Object[])">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>newInstance</h4>
<pre>public static&nbsp;java.lang.Object&nbsp;newInstance(java.lang.Class&nbsp;ofClass,
                           java.lang.Class[]&nbsp;argTypes,
                           java.lang.Object[]&nbsp;args)</pre>
<div class="block">Create an instance of a class using the constructor matching
 the given arguments.</div>
<dl><dt><span class="strong">Since:</span></dt>
  <dd>Ant 1.8.0</dd></dl>
</li>
</ul>
<a name="invoke(java.lang.Object, java.lang.String)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>invoke</h4>
<pre>public static&nbsp;java.lang.Object&nbsp;invoke(java.lang.Object&nbsp;obj,
                      java.lang.String&nbsp;methodName)</pre>
<div class="block">Call a method on the object with no parameters.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>obj</code> - the object to invoke the method on.</dd><dd><code>methodName</code> - the name of the method to call</dd>
<dt><span class="strong">Returns:</span></dt><dd>the object returned by the method</dd></dl>
</li>
</ul>
<a name="invokeStatic(java.lang.Object, java.lang.String)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>invokeStatic</h4>
<pre>public static&nbsp;java.lang.Object&nbsp;invokeStatic(java.lang.Object&nbsp;obj,
                            java.lang.String&nbsp;methodName)</pre>
<div class="block">Call a method on the object with no parameters.
 Note: Unlike the invoke method above, this
 calls class or static methods, not instance methods.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>obj</code> - the object to invoke the method on.</dd><dd><code>methodName</code> - the name of the method to call</dd>
<dt><span class="strong">Returns:</span></dt><dd>the object returned by the method</dd></dl>
</li>
</ul>
<a name="invoke(java.lang.Object, java.lang.String, java.lang.Class, java.lang.Object)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>invoke</h4>
<pre>public static&nbsp;java.lang.Object&nbsp;invoke(java.lang.Object&nbsp;obj,
                      java.lang.String&nbsp;methodName,
                      java.lang.Class&nbsp;argType,
                      java.lang.Object&nbsp;arg)</pre>
<div class="block">Call a method on the object with one argument.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>obj</code> - the object to invoke the method on.</dd><dd><code>methodName</code> - the name of the method to call</dd><dd><code>argType</code> - the type of argument.</dd><dd><code>arg</code> - the value of the argument.</dd>
<dt><span class="strong">Returns:</span></dt><dd>the object returned by the method</dd></dl>
</li>
</ul>
<a name="invoke(java.lang.Object, java.lang.String, java.lang.Class, java.lang.Object, java.lang.Class, java.lang.Object)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>invoke</h4>
<pre>public static&nbsp;java.lang.Object&nbsp;invoke(java.lang.Object&nbsp;obj,
                      java.lang.String&nbsp;methodName,
                      java.lang.Class&nbsp;argType1,
                      java.lang.Object&nbsp;arg1,
                      java.lang.Class&nbsp;argType2,
                      java.lang.Object&nbsp;arg2)</pre>
<div class="block">Call a method on the object with two argument.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>obj</code> - the object to invoke the method on.</dd><dd><code>methodName</code> - the name of the method to call</dd><dd><code>argType1</code> - the type of the first argument.</dd><dd><code>arg1</code> - the value of the first argument.</dd><dd><code>argType2</code> - the type of the second argument.</dd><dd><code>arg2</code> - the value of the second argument.</dd>
<dt><span class="strong">Returns:</span></dt><dd>the object returned by the method</dd></dl>
</li>
</ul>
<a name="getField(java.lang.Object, java.lang.String)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getField</h4>
<pre>public static&nbsp;java.lang.Object&nbsp;getField(java.lang.Object&nbsp;obj,
                        java.lang.String&nbsp;fieldName)
                                 throws <a href="../../../../../org/apache/tools/ant/BuildException.html" title="class in org.apache.tools.ant">BuildException</a></pre>
<div class="block">Get the value of a field in an object.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>obj</code> - the object to look at.</dd><dd><code>fieldName</code> - the name of the field in the object.</dd>
<dt><span class="strong">Returns:</span></dt><dd>the value of the field.</dd>
<dt><span class="strong">Throws:</span></dt>
<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.</dd></dl>
</li>
</ul>
<a name="throwBuildException(java.lang.Exception)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>throwBuildException</h4>
<pre>public static&nbsp;void&nbsp;throwBuildException(java.lang.Exception&nbsp;t)
                                throws <a href="../../../../../org/apache/tools/ant/BuildException.html" title="class in org.apache.tools.ant">BuildException</a></pre>
<div class="block">A method to convert an invocationTargetException to
 a buildexception and throw it.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>t</code> - the invocation target exception.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/tools/ant/BuildException.html" title="class in org.apache.tools.ant">BuildException</a></code> - the converted exception.</dd></dl>
</li>
</ul>
<a name="toBuildException(java.lang.Exception)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toBuildException</h4>
<pre>public static&nbsp;<a href="../../../../../org/apache/tools/ant/BuildException.html" title="class in org.apache.tools.ant">BuildException</a>&nbsp;toBuildException(java.lang.Exception&nbsp;t)</pre>
<div class="block">A method to convert an invocationTargetException to
 a buildexception.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>t</code> - the invocation target exception.</dd>
<dt><span class="strong">Returns:</span></dt><dd>the converted exception.</dd><dt><span class="strong">Since:</span></dt>
  <dd>ant 1.7.1</dd></dl>
</li>
</ul>
<a name="respondsTo(java.lang.Object, java.lang.String)">
<!--   -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>respondsTo</h4>
<pre>public static&nbsp;boolean&nbsp;respondsTo(java.lang.Object&nbsp;o,
                 java.lang.String&nbsp;methodName)
                          throws <a href="../../../../../org/apache/tools/ant/BuildException.html" title="class in org.apache.tools.ant">BuildException</a></pre>
<div class="block">A method to test if an object responds to a given
 message (method call)</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>o</code> - the object</dd><dd><code>methodName</code> - the method to check for</dd>
<dt><span class="strong">Returns:</span></dt><dd>true if the object has the method.</dd>
<dt><span class="strong">Throws:</span></dt>
<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.</dd></dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!--   -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!--   -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/tools/ant/util/ReaderInputStream.html" title="class in org.apache.tools.ant.util"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../../org/apache/tools/ant/util/ReflectWrapper.html" title="class in org.apache.tools.ant.util"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/tools/ant/util/ReflectUtil.html" target="_top">Frames</a></li>
<li><a href="ReflectUtil.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_bottom");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!--   -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>