Example usage for java.lang RuntimeException RuntimeException

List of usage examples for java.lang RuntimeException RuntimeException

Introduction

In this page you can find the example usage for java.lang RuntimeException RuntimeException.

Prototype

public RuntimeException(Throwable cause) 

Source Link

Document

Constructs a new runtime exception with the specified cause and a detail message of (cause==null ?

Usage

From source file:Main.java

public static void dumpCursor(android.database.Cursor cursor, java.lang.StringBuilder sb) {
    throw new RuntimeException("Stub!");
}

From source file:Main.java

@SuppressWarnings("unchecked")
public static <T> T getFieldValue(Object object, Field field) {
    setAccessibleIfNeeded(field);//from w w w  .jav  a2s.c o m
    try {
        return (T) field.get(object);
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:Main.java

public static String getVersionName(Context context) {
    try {//from  ww  w . j a v  a2 s .com
        return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
    } catch (NameNotFoundException e) {
        e.printStackTrace();
        throw new RuntimeException("get versionCode Exception(RuntimeException)");
    }
}

From source file:Main.java

public static <T> T single(Collection<T> cl, boolean force, Object msg) {
    String amsg = msg == null ? "" : "," + msg.toString();
    if (cl.isEmpty()) {
        if (force) {
            throw new RuntimeException("force:" + cl + amsg);
        } else {//from  w  w w.  j  a v  a  2 s  . co m
            return null;
        }
    } else if (cl.size() > 1) {
        throw new RuntimeException("tomuch:" + cl + amsg);
    } else {
        return cl.iterator().next();
    }
}

From source file:Main.java

static MessageDigest getDigest(String algorithm) {
    try {//from   w ww  .  jav  a 2  s .  c om
        return MessageDigest.getInstance(algorithm);
    } catch (NoSuchAlgorithmException e) {
        throw new RuntimeException(e.getMessage());
    }
}

From source file:Main.java

public static Document OpenDom(String sfilepath) {
    Document newdoc = null;/*w ww  .  java2s.  c o m*/
    try {
        newdoc = getDocumentBuilder().parse(new File(sfilepath));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return newdoc;
}

From source file:Main.java

public static PackageInfo packageInfoFromContext(final Context context) {
    try {/*from  w w  w  .j  a v a2 s  . c o m*/
        return context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
    } catch (final PackageManager.NameNotFoundException x) {
        throw new RuntimeException(x);
    }
}

From source file:Main.java

public static java.util.Formatter formatDateRange(android.content.Context context,
        java.util.Formatter formatter, long startMillis, long endMillis, int flags) {
    throw new RuntimeException("Stub!");
}

From source file:Main.java

public static void dumpCurrentRow(android.database.Cursor cursor, java.lang.StringBuilder sb) {
    throw new RuntimeException("Stub!");
}

From source file:Main.java

/**
 * @param domainsAtt/*from w ww.j  a v  a2  s  .  co  m*/
 * @param i
 * @param propsAtts
 * @return
 */
private static int parsePropsDomain(String domainsAtt, int p, List<String> propsAtts) {
    if (p >= domainsAtt.length()) {
        throw new RuntimeException(
                "Unexpected end of string, expected '(' in domains attribute value \"" + domainsAtt + "\"");
    }
    char c = domainsAtt.charAt(p++);
    if (c != '(') {
        throw new RuntimeException("Expected '(' following 'a', found '" + c + "' at position " + p
                + " in domains attribute value \"" + domainsAtt + "\"");
    }
    StringBuilder buf = new StringBuilder();
    boolean done = false;
    while (!done && p < domainsAtt.length()) {
        c = domainsAtt.charAt(p);
        switch (c) {
        case ')':
            p++;
            done = true;
            break;
        default:
            buf.append(c);
            p++;
        }
    }
    if (!done) {
        throw new RuntimeException(
                "Unexpected end of string, expected ')' in domains attribute value \"" + domainsAtt + "\"");
    }
    String[] tokens = buf.toString().trim().split(" ");
    if (tokens.length < 2) {
        throw new RuntimeException("Expected two tokens in attribute domain declaration, found " + tokens.length
                + " in domains attribute value \"" + domainsAtt + "\"");
    }
    if ("props".equals(tokens[0])) {
        propsAtts.add(tokens[tokens.length - 1]);
    }
    return p;
}