/** * Throws out a {@link UnexpectedException} with message specified. * * @param msg * the message format pattern. * @param args * the message format arguments */ public static UnexpectedException unexpected(String msg, Object... args) { throw new UnexpectedException(msg, args); }
/** * Throws out a {@link UnexpectedException} with cause specified. * * @param cause * the cause of the unexpected exception. */ public static UnexpectedException unexpected(Throwable cause) { throw new UnexpectedException(cause); }
/** * Throws out a {@link UnexpectedException} with message specified. * * @param msg * the message format pattern. * @param args * the message format arguments */ public static UnexpectedException unexpected(String msg, Object... args) { throw new UnexpectedException(msg, args); }
public static void unexpectedIf(boolean tester) { if (tester) { throw new UnexpectedException(); } }
public static void unexpectedIf(boolean tester) { if (tester) { throw new UnexpectedException(); } }
/** * Throws out a {@link UnexpectedException} with message and cause specified. * * @param cause * the cause of the unexpected exception. * @param msg * the error message format pattern. * @param args * the error message format arguments. */ public static UnexpectedException unexpected(Throwable cause, String msg, Object... args) { throw new UnexpectedException(cause, msg, args); }
/** * Throws out a {@link UnexpectedException} with cause specified. * * @param cause * the cause of the unexpected exception. */ public static UnexpectedException unexpected(Throwable cause) { throw new UnexpectedException(cause); }
/** * Throws out a {@link UnexpectedException} with message and cause specified. * * @param cause * the cause of the unexpected exception. * @param msg * the error message format pattern. * @param args * the error message format arguments. */ public static UnexpectedException unexpected(Throwable cause, String msg, Object... args) { throw new UnexpectedException(cause, msg, args); }
/** * Build an hexadecimal MD5 hash for a String * * @param value The String to hash * @return An hexadecimal Hash */ public static String hexMD5(String value) { try { MessageDigest messageDigest = MessageDigest.getInstance("MD5"); messageDigest.reset(); messageDigest.update(value.getBytes("utf-8")); byte[] digest = messageDigest.digest(); return byteToHexString(digest); } catch (Exception ex) { throw new UnexpectedException(ex); } }
@Override public Map<String, String[]> parse(ActionContext context) { H.Request req = context.req(); InputStream is = req.inputStream(); try { Map<String, String[]> params = new HashMap<String, String[]>(); ByteArrayOutputStream os = new ByteArrayOutputStream(); int b; while ((b = is.read()) != -1) { os.write(b); } byte[] data = os.toByteArray(); params.put(ActionContext.REQ_BODY, data.length == 0 ? null : new String[] {new String(data, req.characterEncoding())}); return params; } catch (Exception e) { throw new UnexpectedException(e); } } }
private <T extends VarDef> void _register(T var, Map<String, T> map, boolean fromApp) { if (map.containsKey(var.name())) { throw new UnexpectedException("Implicit variable[%s] has already been registered", var.name()); } map.put(var.name(), var); if (fromApp) { appDefined.put(var.name(), var); } }
private <T extends VarDef> void _register(T var, Map<String, T> map, boolean fromApp) { if (map.containsKey(var.name())) { throw new UnexpectedException("Implicit variable[%s] has already been registered", var.name()); } map.put(var.name(), var); if (fromApp) { appDefined.put(var.name(), var); } }
private Verifier tryLoadVerifier(String name) { Class<?> c = tryLoadClass(name); if (null != c) { if (Verifier.class.isAssignableFrom(c)) { return (Verifier) (null != app ? app.getInstance(c) : $.newInstance(c)); } else { throw new UnexpectedException("Class not supported: " + name); } } return null; }
public void resolveParent(RequestTemplateManager manager) { if (resolved) { return; } if (null == parent) { parent = "global"; } RequestSpec parentSpec = manager.getTemplate(parent); if (null != parentSpec && this != parentSpec) { parentSpec.resolveParent(manager); extendsParent(parentSpec); } else if (!"global".equals(parent)) { throw new UnexpectedException("parent request template not found: " + parent); } resolved = true; }
private static void startNetworkLayer(NetworkBootupThread nbt) { if (network.isDestroyed()) { return; } LOGGER.debug("starting network layer ..."); try { nbt.join(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new UnexpectedException(e); } if (null != nbt.exception) { throw nbt.exception; } network.start(); }
private Class<?> loadModelType(String type) { if (type.contains(".") || $.isPrimitiveType(type)) { return classForName(type); } for (String pkg : modelPackages) { String patched = S.concat(pkg, type); try { return classForName(patched); } catch (Exception e) { // ignore } } throw new UnexpectedException("Cannot load type: %s", type); }
private Class<?> loadModelType(String type) { if (type.contains(".") || $.isPrimitiveType(type)) { return classForName(type); } for (String pkg : modelPackages) { String patched = S.concat(pkg, type); try { return classForName(patched); } catch (Exception e) { // ignore } } throw new UnexpectedException("Cannot load type: %s", type); }
private Class<?> loadModelType(String type) { if (type.contains(".") || $.isPrimitiveType(type)) { return $.classForName(type, classLoader); } for (String pkg : modelPackages) { String patched = S.concat(pkg, type); try { return $.classForName(patched, classLoader); } catch (Exception e) { // ignore } } throw new UnexpectedException("Cannot load type: %s", type); }
void register(View view) { E.NPE(view); if (registered(view)) { throw new UnexpectedException("View[%s] already registered", view.name()); } viewList.add(view); }
void register(View view) { E.NPE(view); if (registered(view)) { throw new UnexpectedException("View[%s] already registered", view.name()); } viewList.add(view); }