类java.lang.InstantiationException源码实例Demo

下面列出了怎么用java.lang.InstantiationException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: kardio   文件: RegionStatusDaoImpl.java
/**
 * Loads the given messages to environment table
 */
public void loadMessages(String environmentName, String messageType, String message) throws InstantiationException {
    final int envId = environmentDao.getEnironmentIdFromName(environmentName);
    String updateQuery = null;
    if (messageType.equalsIgnoreCase(Constants.MESSAGE_TYPE_APP)) {
        updateQuery = HQLConstants.UPDATE_APP_MESSAGE;
    } else if (messageType.equalsIgnoreCase(Constants.MESSAGE_TYPE_INFRA)) {
        updateQuery = HQLConstants.UPDATE_INFRA_MESSAGE;
    } else if (messageType.equalsIgnoreCase(Constants.MESSAGE_TYPE_GENERAL)) {
        updateQuery = HQLConstants.UPDATE_GENERAL_MESSAGE;
    } else if (messageType.equalsIgnoreCase(Constants.MESSAGE_TYPE_COUNTER)) {
        updateQuery = HQLConstants.UPDATE_COUNTER_MESSAGE;
    }
    else {
        throw new IllegalArgumentException("Invalid value for Message Type : " + messageType);
    }
    Session session = sessionFactory.openSession();
    Transaction tx = session.beginTransaction();
    Query query = session.createQuery(updateQuery).setInteger("envId", envId).setString("message", message);
    query.executeUpdate();
    tx.commit();
    session.close();
}
 
源代码2 项目: pluotsorbet   文件: constructor.java
/**
 * Runs the test using the specified harness.
 *
 * @param harness  the test harness (<code>null</code> not permitted).
 */
public void test(TestHarness harness)
{
    InstantiationException object1 = new InstantiationException();
    harness.check(object1 != null);
    harness.check(object1.toString(), "java.lang.InstantiationException");

    InstantiationException object2 = new InstantiationException("nothing happens");
    harness.check(object2 != null);
    harness.check(object2.toString(), "java.lang.InstantiationException: nothing happens");

    InstantiationException object3 = new InstantiationException(null);
    harness.check(object3 != null);
    harness.check(object3.toString(), "java.lang.InstantiationException");

}
 
源代码3 项目: pluotsorbet   文件: TryCatch.java
/**
 * Runs the test using the specified harness.
 *
 * @param harness  the test harness (<code>null</code> not permitted).
 */
public void test(TestHarness harness)
{
    // flag that is set when exception is caught
    boolean caught = false;
    try {
        throw new InstantiationException("InstantiationException");
    }
    catch (InstantiationException e) {
        // correct exception was caught
        caught = true;
    }
    harness.check(caught);
}
 
 类所在包
 类方法
 同包方法