List of usage examples for java.lang RuntimeException RuntimeException
public RuntimeException(Throwable cause)
From source file:Main.java
private static Parcelable.Creator getCreator(Field field) throws IllegalAccessException { try {/*w ww . jav a 2 s. c o m*/ return (Parcelable.Creator) field.getType().getDeclaredField("CREATOR").get(null); } catch (NoSuchFieldException e) { throw new RuntimeException(field.getType() + " is an Parcelable without CREATOR"); } }
From source file:Main.java
/** * Hides the irritating declared exception. *///from w ww. ja va 2 s . co m public static String encode(String value) { try { return URLEncoder.encode(value, "utf-8"); } catch (UnsupportedEncodingException ex) { throw new RuntimeException(ex); } }
From source file:Main.java
public static void checkGlError(String op) { int error;/* ww w. java 2s. co m*/ while ((error = glGetError()) != GL_NO_ERROR) { Log.e("ES20_ERROR", op + ": glError " + error); throw new RuntimeException(op + ": glError " + error); } }
From source file:Main.java
public static String getVersionName(Context ctx) { try {// w w w . j a v a 2 s .co m PackageInfo packInfo = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0); return packInfo.versionName; } catch (Throwable t) { throw new RuntimeException(t); } }
From source file:Main.java
/** * Returns a string containing len times comma separated ? placeholders. * i.e. ?, ?, ?, ? for len = 4/* ww w . j a va 2 s . c o m*/ * * @param len * @return */ public static String makePlaceholders(int len) { if (len < 1) { // It will lead to an invalid query anyway .. throw new RuntimeException("No placeholders"); } else { StringBuilder sb = new StringBuilder(len * 2 - 1); sb.append("?"); for (int i = 1; i < len; i++) { sb.append(",?"); } return sb.toString(); } }
From source file:Main.java
public static <T> void fill(List<T> list, int start, int end, Class<T> clazz) { for (int i = start; i <= end; i++) { try {/*from w w w. j a va 2 s . co m*/ list.set(i, clazz != null ? clazz.newInstance() : null); } catch (InstantiationException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } }
From source file:Main.java
public static void wait(double durationInSeconds) { try {/*from w w w . ja v a 2 s . com*/ Thread.sleep((int) (durationInSeconds * 1000)); } catch (InterruptedException e) { throw new RuntimeException(e); } }
From source file:Main.java
public static void shutdownAndWait(ExecutorService threadPool, long timeout, TimeUnit unit) { threadPool.shutdown();//from ww w .ja v a2 s .c o m try { threadPool.awaitTermination(timeout, unit); } catch (InterruptedException e) { throw new RuntimeException(e); } }
From source file:Main.java
public static int[] parseTime(String timeString) { String[] splitTimeString = timeString.split(":"); int hour = Integer.parseInt(splitTimeString[0]); int minute = Integer.parseInt(splitTimeString[1]); if (hour < 0 || hour > 23) { throw new RuntimeException("Failed to parse time: Hours was '" + hour + "' and must be between 00 and 23. Time format is HH-mm (ex: '23:49')"); } else if (minute < 0 || minute > 59) { throw new RuntimeException("Failed to parse time: Minutes was '" + minute + "' and must be between 00 and 59. Time format is HH-mm (ex: '23:49')"); } else {//from ww w . j a v a2 s. c o m int[] time = { hour, minute }; return time; } }
From source file:Main.java
public static void texImage2D(int target, int level, int internalformat, android.graphics.Bitmap bitmap, int type, int border) { throw new RuntimeException("Stub!"); }