List of usage examples for java.lang IllegalStateException IllegalStateException
public IllegalStateException(String message, Throwable cause)
From source file:Main.java
public static <T> T getView(Object object, Class<T> t) { try {//from w w w.j a va 2s .co m return (T) object; } catch (ClassCastException e) { throw new IllegalStateException(object.getClass().getSimpleName() + t.getSimpleName() + " does not implement contract interface", e); } }
From source file:Main.java
public static RuntimeException launderThrowable(Throwable t) { if (t instanceof RuntimeException) { return (RuntimeException) t; } else if (t instanceof Error) { throw (Error) t; } else {//from www .j ava 2s . c om throw new IllegalStateException("Not unchecked", t); } }
From source file:Main.java
public static void invokeAndWait(Runnable r) { if (SwingUtilities.isEventDispatchThread()) { r.run();/*from ww w.j a v a2 s . com*/ return; } try { SwingUtilities.invokeAndWait(r); } catch (Exception e) { throw new IllegalStateException("Unable to invoke/wait for task", e); } }
From source file:Main.java
public static RuntimeException peelException(Throwable e) { if (e instanceof RuntimeException) { return (RuntimeException) e; } else if (e instanceof Error) { throw (Error) e; } else {/*from w w w. ja v a2 s. c o m*/ throw new IllegalStateException("Peel failed: ", e); } }
From source file:Main.java
public static Document parse(InputStream is) { try {//from w ww.j av a 2 s .c om return getDocumentBuilderFactory().newDocumentBuilder().parse(is); } catch (Exception e) { throw new IllegalStateException("Could not parse steam into Document", e); } }
From source file:Main.java
public static Document convertFileToDom(File xmlFile) { Document document;/*from w w w. ja v a2 s . c o m*/ try { document = DOCUMENT_BUILDER_FACTORY.newDocumentBuilder().parse(xmlFile); } catch (Exception e) { throw new IllegalStateException("Incoming file is not valid xml", e); } return document; }
From source file:Main.java
public static <T> T fromExposeJson(@NonNull String content, @NonNull Class<T> clazz) throws IllegalStateException { try {//from w ww.j ava2s.c o m return sExposeGson.fromJson(content, clazz); } catch (JsonSyntaxException e) { throw new IllegalStateException(JSON_PARSE_ERROR + content, e); } }
From source file:Main.java
public static Object evaluateXPath(final XPathExpression expr, final Object rootNode, final QName returnType) { try {// w w w.j a va 2 s. c o m return expr.evaluate(rootNode, returnType); } catch (XPathExpressionException e) { throw new IllegalStateException("Error while evaluating xpath expression " + expr, e); } }
From source file:edu.cornell.mannlib.vitro.webapp.application.ApplicationUtils.java
public static Application instance() { try {//from www . j av a 2 s .co m instance.getClass(); return instance; } catch (NullPointerException e) { log.error("Called for Application before it was available", e); throw new IllegalStateException("Called for Application before it was available", e); } }
From source file:Main.java
/** * Creates an empty node list. Creates an empty document then selects nodes * using a random UUID to ensure an empty result. * * @return an empty Node list/*from w ww. j a v a 2s. c o m*/ */ public static NodeList createEmptyNodeList() { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder builder; try { builder = dbf.newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new IllegalStateException("Problem creating document", e); } Document document = builder.newDocument(); assert document != null; final NodeList emptyNodesList = document.getElementsByTagName(UUID.randomUUID().toString()); return emptyNodesList; }