List of usage examples for java.lang Exception Exception
public Exception()
From source file:Main.java
public static String getClassName() { return new Exception().getStackTrace()[0].getClassName(); }
From source file:Main.java
public static String getMethodName() { return new Exception().getStackTrace()[0].getMethodName(); }
From source file:Main.java
/**returns the type of document represented * @param d document to get the type of// w ww.j a va 2 s. c o m * @return string representing type of document*/ static public String getDocumentType(Document d) throws Exception { if (d == null) throw new Exception(); else return (d.getDoctype().getName()); }
From source file:Main.java
public static byte[] padding(byte[] source) throws Exception { if (source.length >= 0x2000000000000000l) { throw new Exception(); }/*from ww w . j a v a2 s. co m*/ long l = source.length * 8; long k = 448 - (l + 1) % 512; if (k < 0) { k = k + 512; } ByteArrayOutputStream baos = new ByteArrayOutputStream(); baos.write(source); baos.write(FirstPadding); long i = k - 7; while (i > 0) { baos.write(ZeroPadding); i -= 8; } baos.write(long2bytes(l)); return baos.toByteArray(); }
From source file:Main.java
public static String _FILE_() { StackTraceElement traceElement = ((new Exception()).getStackTrace())[2]; return traceElement.getFileName(); }
From source file:Main.java
public static Document getdoc(String uri) throws Exception { uri = uri.replace(" ", "%20"); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = null;//from www. j ava 2 s . co m db = dbf.newDocumentBuilder(); Document doc = db.newDocument(); doc = db.parse(new URL(uri).openStream()); if (doc == null || doc.getTextContent() == "") { throw new Exception(); } else return doc; }
From source file:Main.java
public static String getLineMethod() { StackTraceElement traceElement = ((new Exception()).getStackTrace())[2]; StringBuffer toStringBuffer = new StringBuffer("[").append(traceElement.getLineNumber()).append(" | ") .append(traceElement.getMethodName()).append("]"); return toStringBuffer.toString(); }
From source file:Main.java
public static String convertPhoneNumberTo8Format(String text) { try {//from w w w .ja v a 2s . c o m text = text.trim(); if (text.charAt(0) == '+') { text = text.substring(1); } if (text.charAt(0) == '7') { StringBuilder strBuilder = new StringBuilder(text); strBuilder.setCharAt(0, '8'); text = strBuilder.toString(); } BigInteger dummy = new BigInteger(text); if (text.charAt(0) != '8' || text.length() != 11) { throw new Exception(); } } catch (Throwable t) { text = ""; //LOGE("convertPhoneNumberTo8Format: " + t.getMessage()); t.printStackTrace(); } return text; }
From source file:Main.java
public static String validateAndFixUserPhoneNumber(String text) { try {// www . j av a 2 s . co m text = text.trim(); if (text.charAt(0) == '+') { text = text.substring(1); } BigInteger dummy = new BigInteger(text); if (text.charAt(0) == '8') { StringBuilder strBuilder = new StringBuilder(text); strBuilder.setCharAt(0, '7'); text = strBuilder.toString(); } if (text.charAt(0) != '7' || text.length() != 11) { throw new Exception(); } text = "+" + text; } catch (Throwable t) { text = ""; //LOGE("validateAndFixUserPhoneNumber: " + t.getMessage()); t.printStackTrace(); } return text; }
From source file:Main.java
public static String _FILE_() { StackTraceElement traceElement = ((new Exception()).getStackTrace())[1]; return traceElement.getFileName(); }