Files
pj2/doc/edu/rit/util/Instance.html
2016-04-27 01:07:35 -04:00

596 lines
43 KiB
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_51) on Wed Apr 06 13:11:11 EDT 2016 -->
<title>Instance (Parallel Java 2 Library Documentation)</title>
<meta name="date" content="2016-04-06">
<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="Instance (Parallel Java 2 Library Documentation)";
}
//-->
</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="class-use/Instance.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../index-files/index-1.html">Index</a></li>
<li><a href="../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../edu/rit/util/IdentityPair.html" title="class in edu.rit.util"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../edu/rit/util/IntAction.html" title="interface in edu.rit.util"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?edu/rit/util/Instance.html" target="_top">Frames</a></li>
<li><a href="Instance.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">edu.rit.util</div>
<h2 title="Class Instance" class="title">Class Instance</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li>
<li>
<ul class="inheritance">
<li>edu.rit.util.Instance</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public class <span class="strong">Instance</span>
extends <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></pre>
<div class="block">Class Instance provides static methods for creating instances of classes.</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 <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Constructor.html?is-external=true" title="class or interface in java.lang.reflect">Constructor</a>&lt;?&gt;</code></td>
<td class="colLast"><code><strong><a href="../../../edu/rit/util/Instance.html#getDefaultConstructor(java.lang.Class)">getDefaultConstructor</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html?is-external=true" title="class or interface in java.lang">Class</a>&lt;?&gt;&nbsp;c)</code>
<div class="block">Get the given class's default constructor.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Constructor.html?is-external=true" title="class or interface in java.lang.reflect">Constructor</a>&lt;?&gt;</code></td>
<td class="colLast"><code><strong><a href="../../../edu/rit/util/Instance.html#getDefaultConstructor(java.lang.Class, boolean)">getDefaultConstructor</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html?is-external=true" title="class or interface in java.lang">Class</a>&lt;?&gt;&nbsp;c,
boolean&nbsp;disableAccessChecks)</code>
<div class="block">Get the given class's default constructor.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static &lt;T&gt;&nbsp;T</code></td>
<td class="colLast"><code><strong><a href="../../../edu/rit/util/Instance.html#newDefaultInstance(java.lang.Class)">newDefaultInstance</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html?is-external=true" title="class or interface in java.lang">Class</a>&lt;T&gt;&nbsp;c)</code>
<div class="block">Create a new instance of the given class using the class's default
constructor.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static &lt;T&gt;&nbsp;T</code></td>
<td class="colLast"><code><strong><a href="../../../edu/rit/util/Instance.html#newDefaultInstance(java.lang.Class, boolean)">newDefaultInstance</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html?is-external=true" title="class or interface in java.lang">Class</a>&lt;T&gt;&nbsp;c,
boolean&nbsp;disableAccessChecks)</code>
<div class="block">Create a new instance of the given class using the class's default
constructor.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></code></td>
<td class="colLast"><code><strong><a href="../../../edu/rit/util/Instance.html#newDefaultInstance(java.lang.String)">newDefaultInstance</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;className)</code>
<div class="block">Create a new instance of the class with the given name using the class's
default constructor.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></code></td>
<td class="colLast"><code><strong><a href="../../../edu/rit/util/Instance.html#newDefaultInstance(java.lang.String, boolean)">newDefaultInstance</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;className,
boolean&nbsp;disableAccessChecks)</code>
<div class="block">Create a new instance of the class with the given name using the class's
default constructor.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></code></td>
<td class="colLast"><code><strong><a href="../../../edu/rit/util/Instance.html#newInstance(java.lang.String)">newInstance</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;s)</code>
<div class="block">Create a new instance of a class as specified by the given string.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></code></td>
<td class="colLast"><code><strong><a href="../../../edu/rit/util/Instance.html#newInstance(java.lang.String, boolean)">newInstance</a></strong>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;s,
boolean&nbsp;disableAccessChecks)</code>
<div class="block">Create a new instance of a class as specified by the given string.</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.<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3>
<code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</a></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.String)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>newInstance</h4>
<pre>public static&nbsp;<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>&nbsp;newInstance(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;s)
throws <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/ClassNotFoundException.html?is-external=true" title="class or interface in java.lang">ClassNotFoundException</a>,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NoSuchMethodException.html?is-external=true" title="class or interface in java.lang">NoSuchMethodException</a>,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/InstantiationException.html?is-external=true" title="class or interface in java.lang">InstantiationException</a>,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalAccessException.html?is-external=true" title="class or interface in java.lang">IllegalAccessException</a>,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/InvocationTargetException.html?is-external=true" title="class or interface in java.lang.reflect">InvocationTargetException</a></pre>
<div class="block">Create a new instance of a class as specified by the given string.
Calling this method is equivalent to calling
<TT>newInstance(s,false)</TT>. See the <a href="../../../edu/rit/util/Instance.html#newInstance(java.lang.String, boolean)"><code>newInstance(String,boolean)</code></a> method for
further information.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>s</code> - Constructor expression string.</dd>
<dt><span class="strong">Returns:</span></dt><dd>New instance.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - (unchecked exception) Thrown if <TT>s</TT> does not obey the required
syntax.</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/ClassNotFoundException.html?is-external=true" title="class or interface in java.lang">ClassNotFoundException</a></code> - Thrown if the given class cannot be found.</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NoSuchMethodException.html?is-external=true" title="class or interface in java.lang">NoSuchMethodException</a></code> - Thrown if a suitable constructor cannot be found in the given class.</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/InstantiationException.html?is-external=true" title="class or interface in java.lang">InstantiationException</a></code> - Thrown if an instance cannot be created because the given class is an
interface or an abstract class.</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalAccessException.html?is-external=true" title="class or interface in java.lang">IllegalAccessException</a></code> - Thrown if an instance cannot be created because the calling method
does not have access to the given constructor.</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/InvocationTargetException.html?is-external=true" title="class or interface in java.lang.reflect">InvocationTargetException</a></code> - Thrown if the given constructor throws an exception.</dd></dl>
</li>
</ul>
<a name="newInstance(java.lang.String, boolean)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>newInstance</h4>
<pre>public static&nbsp;<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>&nbsp;newInstance(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;s,
boolean&nbsp;disableAccessChecks)
throws <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/ClassNotFoundException.html?is-external=true" title="class or interface in java.lang">ClassNotFoundException</a>,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NoSuchMethodException.html?is-external=true" title="class or interface in java.lang">NoSuchMethodException</a>,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/InstantiationException.html?is-external=true" title="class or interface in java.lang">InstantiationException</a>,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalAccessException.html?is-external=true" title="class or interface in java.lang">IllegalAccessException</a>,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/InvocationTargetException.html?is-external=true" title="class or interface in java.lang.reflect">InvocationTargetException</a></pre>
<div class="block">Create a new instance of a class as specified by the given string. The
string must consist of a fully-qualified class name, a left parenthesis,
zero or more comma-separated arguments, and a right parenthesis. No
whitespace is allowed.
<P>
The <TT>newInstance()</TT> method deduces the data type and value of each
argument provided in the constructor expression according to the
following patterns:
<UL>
<P><LI>
Optional <TT>+</TT> or <TT>-</TT>; <TT>0b</TT> or <TT>0B</TT>; one or
more digits <TT>0</TT> through <TT>1</TT> &mdash; binary (base-2) value
of type <TT>int</TT>.
<P><LI>
Optional <TT>+</TT> or <TT>-</TT>; <TT>0x</TT> or <TT>0X</TT>; one or
more digits <TT>0</TT> through <TT>9</TT>, <TT>a</TT> through <TT>f</TT>,
or <TT>A</TT> through <TT>F</TT> &mdash; hexadecimal (base-16) value of
type <TT>int</TT>.
<P><LI>
Optional <TT>+</TT> or <TT>-</TT>; <TT>0</TT>; zero or more digits
<TT>0</TT> through <TT>7</TT> &mdash; octal (base-8) value of type
<TT>int</TT>.
<P><LI>
Optional <TT>+</TT> or <TT>-</TT>; a digit <TT>1</TT> through <TT>9</TT>;
zero or more digits <TT>0</TT> through <TT>9</TT> &mdash; decimal value
of type <TT>int</TT>.
<P><LI>
Optional <TT>+</TT> or <TT>-</TT>; <TT>0b</TT> or <TT>0B</TT>; one or
more digits <TT>0</TT> through <TT>1</TT>; <TT>l</TT> or <TT>L</TT>
&mdash; binary (base-2) value of type <TT>long</TT>.
<P><LI>
Optional <TT>+</TT> or <TT>-</TT>; <TT>0x</TT> or <TT>0X</TT>; one or
more digits <TT>0</TT> through <TT>9</TT>, <TT>a</TT> through <TT>f</TT>,
or <TT>A</TT> through <TT>F</TT>; <TT>l</TT> or <TT>L</TT> &mdash;
hexadecimal (base-16) value of type <TT>long</TT>.
<P><LI>
Optional <TT>+</TT> or <TT>-</TT>; <TT>0</TT>; zero or more digits
<TT>0</TT> through <TT>7</TT>; <TT>l</TT> or <TT>L</TT> &mdash; octal
(base-8) value of type <TT>long</TT>.
<P><LI>
Optional <TT>+</TT> or <TT>-</TT>; a digit <TT>1</TT> through <TT>9</TT>;
zero or more digits <TT>0</TT> through <TT>9</TT>; <TT>l</TT> or
<TT>L</TT> &mdash; decimal value of type <TT>long</TT>.
<P><LI>
Otherwise &mdash; type String.
</UL>
<P>
If a decimal argument is outside the range of type <TT>int</TT> or type
<TT>long</TT>, the deduced value is not specified. If a binary, octal, or
hexadecimal argument is larger than 32 bits for type <TT>int</TT> or 64
bits for type <TT>long</TT>, the deduced value is not specified.
<P>
The <TT>newInstance()</TT> method attempts to find a constructor for the
given class as follows, where <I>N</I> is the number of provided
arguments:
<UL>
<P><LI>
If <I>N</I> = 0, use a no-argument constructor.
<P><LI>
Else if there is a constructor with <I>N</I> arguments whose types match
those provided, use that constructor.
<P><LI>
Else if all provided arguments are of type <TT>int</TT> and there is a
constructor with one argument of type <TT>int[]</TT>, use that
constructor.
<P><LI>
Else if all provided arguments are of type <TT>long</TT> and there is a
constructor with one argument of type <TT>long[]</TT>, use that
constructor.
<P><LI>
Else if there is a constructor with <I>N</I> arguments of type
<TT>String</TT>, use that constructor; all provided arguments are passed
as strings.
<P><LI>
Else if there is a constructor with one argument of type
<TT>String[]</TT>, use that constructor; all provided arguments are
passed as strings.
<P><LI>
Else throw a NoSuchMethodException.
</UL>
<P>
The <TT>newInstance()</TT> method invokes the chosen constructor, passing
in the provided argument values, and returns a reference to the
newly-created instance.
<P>
If the <TT>disableAccessChecks</TT> argument is true, access checks are
suppressed when constructing the instance. This means the object's class
and/or the class's pertinent constructor need not be public, and a new
instance will still be constructed. However, this also requires that
either (a) a security manager is not installed, or (b) the security
manager allows ReflectPermission("suppressAccessChecks"). See the
<TT>java.lang.reflect.Constructor.setAccessible()</TT> method for further
information.
<P>
<I>Note:</I> To find the given class, the calling thread's context class
loader is used.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>s</code> - Constructor expression string.</dd><dd><code>disableAccessChecks</code> - True to disable access checks, false to
perform access checks.</dd>
<dt><span class="strong">Returns:</span></dt><dd>New instance.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - (unchecked exception) Thrown if <TT>s</TT> does not obey the required
syntax.</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/ClassNotFoundException.html?is-external=true" title="class or interface in java.lang">ClassNotFoundException</a></code> - Thrown if the given class cannot be found.</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NoSuchMethodException.html?is-external=true" title="class or interface in java.lang">NoSuchMethodException</a></code> - Thrown if a suitable constructor cannot be found in the given class.</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/InstantiationException.html?is-external=true" title="class or interface in java.lang">InstantiationException</a></code> - Thrown if an instance cannot be created because the given class is an
interface or an abstract class.</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalAccessException.html?is-external=true" title="class or interface in java.lang">IllegalAccessException</a></code> - Thrown if an instance cannot be created because the calling method
does not have access to the class or constructor.</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/InvocationTargetException.html?is-external=true" title="class or interface in java.lang.reflect">InvocationTargetException</a></code> - Thrown if the constructor throws an exception.</dd></dl>
</li>
</ul>
<a name="newDefaultInstance(java.lang.String)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>newDefaultInstance</h4>
<pre>public static&nbsp;<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>&nbsp;newDefaultInstance(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;className)
throws <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/ClassNotFoundException.html?is-external=true" title="class or interface in java.lang">ClassNotFoundException</a>,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NoSuchMethodException.html?is-external=true" title="class or interface in java.lang">NoSuchMethodException</a>,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/InstantiationException.html?is-external=true" title="class or interface in java.lang">InstantiationException</a>,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalAccessException.html?is-external=true" title="class or interface in java.lang">IllegalAccessException</a>,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/InvocationTargetException.html?is-external=true" title="class or interface in java.lang.reflect">InvocationTargetException</a></pre>
<div class="block">Create a new instance of the class with the given name using the class's
default constructor. Calling this method is equivalent to calling
<TT>newDefaultInstance(className,false)</TT>. See the <a href="../../../edu/rit/util/Instance.html#newDefaultInstance(java.lang.String, boolean)"><code>newDefaultInstance(String,boolean)</code></a>
method for further information.
<P>
<I>Note:</I> To find the class with the given name, the calling thread's
context class loader is used.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>className</code> - Class name.</dd>
<dt><span class="strong">Returns:</span></dt><dd>New instance.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/ClassNotFoundException.html?is-external=true" title="class or interface in java.lang">ClassNotFoundException</a></code> - Thrown if the class with the given name cannot be found.</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NoSuchMethodException.html?is-external=true" title="class or interface in java.lang">NoSuchMethodException</a></code> - Thrown if the given class does not have a default constructor.</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/InstantiationException.html?is-external=true" title="class or interface in java.lang">InstantiationException</a></code> - Thrown if an instance cannot be created because the given class is an
interface or an abstract class.</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalAccessException.html?is-external=true" title="class or interface in java.lang">IllegalAccessException</a></code> - Thrown if an instance cannot be created because the calling method
does not have access to the class or constructor.</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/InvocationTargetException.html?is-external=true" title="class or interface in java.lang.reflect">InvocationTargetException</a></code> - Thrown if the constructor throws an exception.</dd></dl>
</li>
</ul>
<a name="newDefaultInstance(java.lang.String, boolean)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>newDefaultInstance</h4>
<pre>public static&nbsp;<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>&nbsp;newDefaultInstance(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;className,
boolean&nbsp;disableAccessChecks)
throws <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/ClassNotFoundException.html?is-external=true" title="class or interface in java.lang">ClassNotFoundException</a>,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NoSuchMethodException.html?is-external=true" title="class or interface in java.lang">NoSuchMethodException</a>,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/InstantiationException.html?is-external=true" title="class or interface in java.lang">InstantiationException</a>,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalAccessException.html?is-external=true" title="class or interface in java.lang">IllegalAccessException</a>,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/InvocationTargetException.html?is-external=true" title="class or interface in java.lang.reflect">InvocationTargetException</a></pre>
<div class="block">Create a new instance of the class with the given name using the class's
default constructor.
<P>
If the <TT>disableAccessChecks</TT> argument is true, access checks are
suppressed when constructing the new instance. This means the object's
class and/or the class's default constructor need not be public, and a
new instance will still be constructed. However, this also requires that
either (a) a security manager is not installed, or (b) the security
manager allows ReflectPermission("suppressAccessChecks"). See the
<TT>java.lang.reflect.Constructor.setAccessible()</TT> method for further
information.
<P>
<I>Note:</I> To find the class with the given name, the calling thread's
context class loader is used.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>className</code> - Class name.</dd><dd><code>disableAccessChecks</code> - True to disable access checks, false to perform access checks.</dd>
<dt><span class="strong">Returns:</span></dt><dd>New instance.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/ClassNotFoundException.html?is-external=true" title="class or interface in java.lang">ClassNotFoundException</a></code> - Thrown if the class with the given name cannot be found.</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NoSuchMethodException.html?is-external=true" title="class or interface in java.lang">NoSuchMethodException</a></code> - Thrown if the given class does not have a default constructor.</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/InstantiationException.html?is-external=true" title="class or interface in java.lang">InstantiationException</a></code> - Thrown if an instance cannot be created because the given class is an
interface or an abstract class.</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalAccessException.html?is-external=true" title="class or interface in java.lang">IllegalAccessException</a></code> - Thrown if an instance cannot be created because the calling method
does not have access to the class or constructor.</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/InvocationTargetException.html?is-external=true" title="class or interface in java.lang.reflect">InvocationTargetException</a></code> - Thrown if the constructor throws an exception.</dd></dl>
</li>
</ul>
<a name="newDefaultInstance(java.lang.Class)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>newDefaultInstance</h4>
<pre>public static&nbsp;&lt;T&gt;&nbsp;T&nbsp;newDefaultInstance(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html?is-external=true" title="class or interface in java.lang">Class</a>&lt;T&gt;&nbsp;c)
throws <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NoSuchMethodException.html?is-external=true" title="class or interface in java.lang">NoSuchMethodException</a>,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/InstantiationException.html?is-external=true" title="class or interface in java.lang">InstantiationException</a>,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalAccessException.html?is-external=true" title="class or interface in java.lang">IllegalAccessException</a>,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/InvocationTargetException.html?is-external=true" title="class or interface in java.lang.reflect">InvocationTargetException</a></pre>
<div class="block">Create a new instance of the given class using the class's default
constructor. Calling this method is equivalent to calling
<TT>newDefaultInstance(c,false)</TT>. See the <a href="../../../edu/rit/util/Instance.html#newDefaultInstance(java.lang.Class, boolean)"><code>newDefaultInstance(Class,boolean)</code></a>
method for further information.</div>
<dl><dt><span class="strong">Type Parameters:</span></dt><dd><code>T</code> - Class's data type.</dd><dt><span class="strong">Parameters:</span></dt><dd><code>c</code> - Class.</dd>
<dt><span class="strong">Returns:</span></dt><dd>New instance.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NoSuchMethodException.html?is-external=true" title="class or interface in java.lang">NoSuchMethodException</a></code> - Thrown if the given class does not have a default constructor.</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/InstantiationException.html?is-external=true" title="class or interface in java.lang">InstantiationException</a></code> - Thrown if an instance cannot be created because the given class is an
interface or an abstract class.</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalAccessException.html?is-external=true" title="class or interface in java.lang">IllegalAccessException</a></code> - Thrown if an instance cannot be created because the calling method
does not have access to the class or constructor.</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/InvocationTargetException.html?is-external=true" title="class or interface in java.lang.reflect">InvocationTargetException</a></code> - Thrown if the constructor throws an exception.</dd></dl>
</li>
</ul>
<a name="newDefaultInstance(java.lang.Class, boolean)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>newDefaultInstance</h4>
<pre>public static&nbsp;&lt;T&gt;&nbsp;T&nbsp;newDefaultInstance(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html?is-external=true" title="class or interface in java.lang">Class</a>&lt;T&gt;&nbsp;c,
boolean&nbsp;disableAccessChecks)
throws <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NoSuchMethodException.html?is-external=true" title="class or interface in java.lang">NoSuchMethodException</a>,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/InstantiationException.html?is-external=true" title="class or interface in java.lang">InstantiationException</a>,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalAccessException.html?is-external=true" title="class or interface in java.lang">IllegalAccessException</a>,
<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/InvocationTargetException.html?is-external=true" title="class or interface in java.lang.reflect">InvocationTargetException</a></pre>
<div class="block">Create a new instance of the given class using the class's default
constructor.
<P>
If the <TT>disableAccessChecks</TT> argument is true, access checks are
suppressed when constructing the new instance. This means the object's
class and/or the class's default constructor need not be public, and a
new instance will still be constructed. However, this also requires that
either (a) a security manager is not installed, or (b) the security
manager allows ReflectPermission("suppressAccessChecks"). See the
<TT>java.lang.reflect.Constructor.setAccessible()</TT> method for further
information.</div>
<dl><dt><span class="strong">Type Parameters:</span></dt><dd><code>T</code> - Class's data type.</dd><dt><span class="strong">Parameters:</span></dt><dd><code>c</code> - Class.</dd><dd><code>disableAccessChecks</code> - True to disable access checks, false to perform access checks.</dd>
<dt><span class="strong">Returns:</span></dt><dd>New instance.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NoSuchMethodException.html?is-external=true" title="class or interface in java.lang">NoSuchMethodException</a></code> - Thrown if the given class does not have a default constructor.</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/InstantiationException.html?is-external=true" title="class or interface in java.lang">InstantiationException</a></code> - Thrown if an instance cannot be created because the given class is an
interface or an abstract class.</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalAccessException.html?is-external=true" title="class or interface in java.lang">IllegalAccessException</a></code> - Thrown if an instance cannot be created because the calling method
does not have access to the class or constructor.</dd>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/InvocationTargetException.html?is-external=true" title="class or interface in java.lang.reflect">InvocationTargetException</a></code> - Thrown if the constructor throws an exception.</dd></dl>
</li>
</ul>
<a name="getDefaultConstructor(java.lang.Class)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getDefaultConstructor</h4>
<pre>public static&nbsp;<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Constructor.html?is-external=true" title="class or interface in java.lang.reflect">Constructor</a>&lt;?&gt;&nbsp;getDefaultConstructor(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html?is-external=true" title="class or interface in java.lang">Class</a>&lt;?&gt;&nbsp;c)
throws <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NoSuchMethodException.html?is-external=true" title="class or interface in java.lang">NoSuchMethodException</a></pre>
<div class="block">Get the given class's default constructor. Calling this method is
equivalent to calling <TT>getDefaultConstructor(c,false)</TT>. See the
<a href="../../../edu/rit/util/Instance.html#getDefaultConstructor(java.lang.Class, boolean)"><code>getDefaultConstructor(Class,boolean)</code></a> method for further information.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>c</code> - Class.</dd>
<dt><span class="strong">Returns:</span></dt><dd>Default (no-argument) constructor for the class.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NoSuchMethodException.html?is-external=true" title="class or interface in java.lang">NoSuchMethodException</a></code> - Thrown if the class does not have a default constructor.</dd></dl>
</li>
</ul>
<a name="getDefaultConstructor(java.lang.Class, boolean)">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>getDefaultConstructor</h4>
<pre>public static&nbsp;<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Constructor.html?is-external=true" title="class or interface in java.lang.reflect">Constructor</a>&lt;?&gt;&nbsp;getDefaultConstructor(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html?is-external=true" title="class or interface in java.lang">Class</a>&lt;?&gt;&nbsp;c,
boolean&nbsp;disableAccessChecks)
throws <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NoSuchMethodException.html?is-external=true" title="class or interface in java.lang">NoSuchMethodException</a></pre>
<div class="block">Get the given class's default constructor.
<P>
If the <TT>disableAccessChecks</TT> argument is true, access checks are
suppressed when constructing an instance using the returned constructor.
This means the object's class and/or the class's default constructor need
not be public, and a new instance will still be constructed. However,
this also requires that either (a) a security manager is not installed,
or (b) the security manager allows
ReflectPermission("suppressAccessChecks"). See the
<TT>java.lang.reflect.Constructor.setAccessible()</TT> method for further
information.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>c</code> - Class.</dd><dd><code>disableAccessChecks</code> - True to disable access checks, false to
perform access checks.</dd>
<dt><span class="strong">Returns:</span></dt><dd>Default (no-argument) constructor for the class.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/NoSuchMethodException.html?is-external=true" title="class or interface in java.lang">NoSuchMethodException</a></code> - Thrown if the class does not have a default constructor.</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="class-use/Instance.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../index-files/index-1.html">Index</a></li>
<li><a href="../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../edu/rit/util/IdentityPair.html" title="class in edu.rit.util"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../edu/rit/util/IntAction.html" title="interface in edu.rit.util"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?edu/rit/util/Instance.html" target="_top">Frames</a></li>
<li><a href="Instance.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 ======= -->
<p class="legalCopy"><small><FONT SIZE="-2">Copyright &copy; 2013&ndash;2016 by Alan Kaminsky. All rights reserved. Send comments to ark</FONT><FONT SIZE="1" COLOR="#FFFFFF">&shy;</FONT><FONT SIZE="-2">&#64;</FONT><FONT SIZE="1" COLOR="#FFFFFF">&shy;</FONT><FONT SIZE="-2">cs.rit.edu.</FONT></small></p>
</body>
</html>