Caught NoClassDefFound Error when DiscoverClass is not present, eliminating
runtime dependency on [discovery], [logging]. Removed factory method taking string class name (use of Class.ForName()). git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@141365 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
78a6df915a
commit
a4bde1dc48
|
@ -34,29 +34,13 @@ import org.apache.commons.math.stat.univariate.summary.SumOfSquares;
|
||||||
/**
|
/**
|
||||||
* Abstract factory class for univariate statistical summaries.
|
* Abstract factory class for univariate statistical summaries.
|
||||||
*
|
*
|
||||||
* @version $Revision: 1.8 $ $Date: 2004/06/23 16:26:16 $
|
* @version $Revision: 1.9 $ $Date: 2004/07/10 16:04:47 $
|
||||||
*/
|
*/
|
||||||
public abstract class DescriptiveStatistics implements StatisticalSummary, Serializable {
|
public abstract class DescriptiveStatistics implements StatisticalSummary, Serializable {
|
||||||
|
|
||||||
/** Serialization UID */
|
/** Serialization UID */
|
||||||
static final long serialVersionUID = 5188298269533339922L;
|
static final long serialVersionUID = 5188298269533339922L;
|
||||||
|
|
||||||
/**
|
|
||||||
* Create an instance of a <code>DescriptiveStatistics</code>
|
|
||||||
* @param cls the type of <code>DescriptiveStatistics</code> object to
|
|
||||||
* create.
|
|
||||||
* @return a new factory.
|
|
||||||
* @throws InstantiationException is thrown if the object can not be
|
|
||||||
* created.
|
|
||||||
* @throws IllegalAccessException is thrown if the type's default
|
|
||||||
* constructor is not accessible.
|
|
||||||
* @throws ClassNotFoundException if the named
|
|
||||||
* <code>DescriptiveStatistics</code> type can not be found.
|
|
||||||
*/
|
|
||||||
public static DescriptiveStatistics newInstance(String cls) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
|
|
||||||
return newInstance(Class.forName(cls));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an instance of a <code>DescriptiveStatistics</code>
|
* Create an instance of a <code>DescriptiveStatistics</code>
|
||||||
* @param cls the type of <code>DescriptiveStatistics</code> object to
|
* @param cls the type of <code>DescriptiveStatistics</code> object to
|
||||||
|
@ -82,9 +66,8 @@ public abstract class DescriptiveStatistics implements StatisticalSummary, Seria
|
||||||
factory = (DescriptiveStatistics) dc.newInstance(
|
factory = (DescriptiveStatistics) dc.newInstance(
|
||||||
DescriptiveStatistics.class,
|
DescriptiveStatistics.class,
|
||||||
"org.apache.commons.math.stat.univariate.DescriptiveStatisticsImpl");
|
"org.apache.commons.math.stat.univariate.DescriptiveStatisticsImpl");
|
||||||
} catch(Exception ex) {
|
} catch(Throwable t) {
|
||||||
ex.printStackTrace();
|
return new DescriptiveStatisticsImpl();
|
||||||
// ignore as default implementation will be used.
|
|
||||||
}
|
}
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,28 +23,12 @@ import org.apache.commons.math.util.MathUtils;
|
||||||
/**
|
/**
|
||||||
* Abstract factory class for univariate statistical summaries.
|
* Abstract factory class for univariate statistical summaries.
|
||||||
*
|
*
|
||||||
* @version $Revision: 1.9 $ $Date: 2004/06/23 16:26:16 $
|
* @version $Revision: 1.10 $ $Date: 2004/07/10 16:04:47 $
|
||||||
*/
|
*/
|
||||||
public abstract class SummaryStatistics implements StatisticalSummary, Serializable {
|
public abstract class SummaryStatistics implements StatisticalSummary, Serializable {
|
||||||
|
|
||||||
/** Serialization UID */
|
/** Serialization UID */
|
||||||
static final long serialVersionUID = -6400596334135654825L;
|
static final long serialVersionUID = -6400596334135654825L;
|
||||||
|
|
||||||
/**
|
|
||||||
* Create an instance of a <code>SummaryStatistics</code>
|
|
||||||
* @param cls the type of <code>SummaryStatistics</code> object to
|
|
||||||
* create.
|
|
||||||
* @return a new factory.
|
|
||||||
* @throws InstantiationException is thrown if the object can not be
|
|
||||||
* created.
|
|
||||||
* @throws IllegalAccessException is thrown if the type's default
|
|
||||||
* constructor is not accessible.
|
|
||||||
* @throws ClassNotFoundException if the named
|
|
||||||
* <code>SummaryStatistics</code> type can not be found.
|
|
||||||
*/
|
|
||||||
public static SummaryStatistics newInstance(String cls) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
|
|
||||||
return newInstance(Class.forName(cls));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an instance of a <code>DescriptiveStatistics</code>
|
* Create an instance of a <code>DescriptiveStatistics</code>
|
||||||
|
@ -62,19 +46,19 @@ public abstract class SummaryStatistics implements StatisticalSummary, Serializa
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an instance of a <code>DescriptiveStatistics</code>
|
* Create an instance of a <code>DescriptiveStatistics</code>
|
||||||
* @return a new factory.
|
* @return a new SummaryStatistics instance.
|
||||||
*/
|
*/
|
||||||
public static SummaryStatistics newInstance() {
|
public static SummaryStatistics newInstance() {
|
||||||
SummaryStatistics factory = null;
|
SummaryStatistics instance = null;
|
||||||
try {
|
try {
|
||||||
DiscoverClass dc = new DiscoverClass();
|
DiscoverClass dc = new DiscoverClass();
|
||||||
factory = (SummaryStatistics) dc.newInstance(
|
instance = (SummaryStatistics) dc.newInstance(
|
||||||
SummaryStatistics.class,
|
SummaryStatistics.class,
|
||||||
"org.apache.commons.math.stat.univariate.SummaryStatisticsImpl");
|
"org.apache.commons.math.stat.univariate.SummaryStatisticsImpl");
|
||||||
} catch(Exception ex) {
|
} catch(Throwable t) {
|
||||||
// ignore as default implementation will be used.
|
return new SummaryStatisticsImpl();
|
||||||
}
|
}
|
||||||
return factory;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue