當前位置: 首頁>>代碼示例>>Java>>正文


Java InvocationTargetException.toString方法代碼示例

本文整理匯總了Java中java.lang.reflect.InvocationTargetException.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java InvocationTargetException.toString方法的具體用法?Java InvocationTargetException.toString怎麽用?Java InvocationTargetException.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.lang.reflect.InvocationTargetException的用法示例。


在下文中一共展示了InvocationTargetException.toString方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: compare

import java.lang.reflect.InvocationTargetException; //導入方法依賴的package包/類
/**
 * Compare two JavaBeans by their shared property.
 * If {@link #getProperty} is null then the actual objects will be compared.
 *
 * @param  o1 Object The first bean to get data from to compare against
 * @param  o2 Object The second bean to get data from to compare
 * @return int negative or positive based on order
 */
public int compare( final T o1, final T o2 ) {

    if ( property == null ) {
        // compare the actual objects
        return internalCompare( o1, o2 );
    }

    try {
        final Object value1 = PropertyUtils.getProperty( o1, property );
        final Object value2 = PropertyUtils.getProperty( o2, property );
        return internalCompare( value1, value2 );
    }
    catch ( final IllegalAccessException iae ) {
        throw new RuntimeException( "IllegalAccessException: " + iae.toString() );
    }
    catch ( final InvocationTargetException ite ) {
        throw new RuntimeException( "InvocationTargetException: " + ite.toString() );
    }
    catch ( final NoSuchMethodException nsme ) {
        throw new RuntimeException( "NoSuchMethodException: " + nsme.toString() );
    }
}
 
開發者ID:yippeesoft,項目名稱:NotifyTools,代碼行數:31,代碼來源:BeanComparator.java

示例2: getSolver

import java.lang.reflect.InvocationTargetException; //導入方法依賴的package包/類
public Solver getSolver(SolverManager solverManager){
if (solver == null){
    try{
	Class classRef = Class.forName(className);
	Class[] argTypes = {SolverManager.class};
	Method newInstanceMethod = classRef.getMethod("newInstance", argTypes);
	Object[] args = {solverManager};
	solver = (Solver)newInstanceMethod.invoke(null, args);
    } catch (ClassNotFoundException cnfe){
	throw new InternalError(cnfe.toString());
    } catch (IllegalAccessException iae){
	throw new InternalError(iae.toString());
    } catch (NoSuchMethodException nsme){
	throw new InternalError("Method newInstance(SolverManager) is missing in class " + className);
    } catch (InvocationTargetException ite){
    	ite.printStackTrace();
	throw new InternalError(ite.toString());
    }
}
return solver;
   }
 
開發者ID:wwu-pi,項目名稱:tap17-muggl-javaee,代碼行數:22,代碼來源:SolverInfo.java


注:本文中的java.lang.reflect.InvocationTargetException.toString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。