List of usage examples for java.lang Exception Exception
public Exception(Throwable cause)
From source file:Main.java
private static void checkResponse(int[] response) throws Exception { if (response == null) throw new Exception("Null response."); if (response.length < 2) throw new Exception("Invalid response length, should always be 2 or more."); if (response[response.length - 2] != 144 || response[response.length - 1] != 0) throw new Exception("Card returned error codes (SW1SW2 = " + response[response.length - 2] + " " + response[response.length - 1] + ")."); }
From source file:Main.java
public static boolean CoversFYStart(Calendar one, Calendar two, Calendar fy_start) throws Exception { if (one == null || two == null) throw new Exception("CoversFYStart: Null dates passed in"); if (fy_start == null) throw new Exception("CoversFYStart: Null FY Start"); int fy_month = fy_start.get(Calendar.MONTH); int fy_day = fy_start.get(Calendar.DAY_OF_MONTH); Calendar cal = (Calendar) one.clone(); while (true) { cal.add(Calendar.DATE, 1); int month = cal.get(Calendar.MONTH); int day = cal.get(Calendar.DAY_OF_MONTH); if (month == fy_month && day == fy_day) break; }/*from ww w. j a v a 2s . c om*/ return cal.before(two); }
From source file:Main.java
public static long read(long data, int start, int len) throws Exception { if (start < 0 || len < 1 || start + len >= 64 || data < 0) throw new Exception("Invalid Param!"); return ((data >> start) & (MASK_4F >> (63 - len))); }
From source file:Main.java
public static HashMap<String, Typeface> getFontsMap() { if (fonts == null) { try {/*w ww . ja v a 2 s . co m*/ throw new Exception( "You should call createFonts method in your application class before using library"); } catch (Exception e) { e.printStackTrace(); } return null; } else { return fonts; } }
From source file:Main.java
public static byte[] Clear(byte[] ss) throws Exception { try {/*from www. j av a 2s.com*/ for (int m = 0; m < ss.length; m++) { ss[m] = new Integer(0).byteValue(); } return ss; } catch (Exception e) { throw new Exception(e); } }
From source file:Main.java
public static void setNamedChildValue(Element element, String name, String value) throws Exception { Element e = getNamedChild(element, name); if (e == null) throw new Exception("unable to find element " + name); e.setAttribute("value", value); }
From source file:Main.java
public static boolean compareNode(Node nQ, Node nN, Boolean considerLength, Map<String, Node> qvars) throws Exception { if (qvars == null) { throw new Exception("qvars array must not be null"); }/*from w ww. j a va2 s.c o m*/ if (nQ.hasChildNodes()) { int nQChildLength = nQ.getChildNodes().getLength(); if (nN.hasChildNodes() && (!considerLength || nQChildLength == nN.getChildNodes().getLength())) { //loop through all childnodes for (int i = 0; i < nQChildLength; i++) { //System.out.println("recurse to "+ nQ.getChildNodes().item( i )+"vs"+nN.getChildNodes().item( i )); //DEBUG if (!compareNode(nQ.getChildNodes().item(i), nN.getChildNodes().item(i), considerLength, qvars)) { return false; } } } } if (nQ.getNodeName().equals("mws:qvar")) { String qvarName = nQ.getAttributes().getNamedItem("name").getNodeValue(); if (qvars.containsKey(qvarName)) { return compareNode(qvars.get(qvarName), nN, considerLength, qvars); } else { qvars.put(qvarName, nN); return true; } } else { if (nQ.getNodeName().equals(nN.getNodeName())) { try { return nQ.getNodeValue().trim().equals(nN.getNodeValue().trim()); } catch (NullPointerException e) { //NodeValue does not exist return true; } } else { return false; } } }
From source file:Main.java
public static JTextArea getTextAreaFromJScrollPane(JScrollPane scrollBar) { if (scrollBar != null) return ((JTextArea) scrollBar.getViewport().getView()); else {//w w w . j a va 2 s. c o m try { throw new Exception("JTextArea received was equal to null!"); } catch (Exception e) { e.printStackTrace(); } return null; } }
From source file:Main.java
public static Element getElement(Element root, String name) throws Exception { NodeList elements = root.getElementsByTagName(name); if (elements.getLength() > 0) { return (Element) elements.item(0); }//www . jav a 2 s. co m throw new Exception("Child element '" + name + "' to parent " + root.getNodeName() + " not found."); }
From source file:Main.java
public static JTextField getTextFieldFromJScrollPane(JScrollPane scrollBar) { if (scrollBar != null) return ((JTextField) scrollBar.getViewport().getView()); else {//from ww w. j a v a2 s . c o m try { throw new Exception("JTextField received was equal to null!"); } catch (Exception e) { e.printStackTrace(); } return null; } }