private boolean isParentLoaded(String className) { try { return null != parentFindLoadedClass.invoke(parent, className); } catch (Exception e) { throw Exceptions.uncheck(e); } }
public static String encode(String url, String charset) { if(null == url) { return url; } try { return URLEncoder.encode(url, charset); } catch (UnsupportedEncodingException e) { throw Exceptions.wrap(e); } }
public final void toString(Appendable buf) { try { toString_(buf); } catch (IOException e) { Exceptions.wrapAndThrow(e); } }
public static void read(Reader reader,CsvProcessor processor) throws NestedIOException { CSVParser parser = null; try{ parser = new CSVParser(reader, DEFAULT_FORMAT); String[] row; int rownum = 0; while((row = parser.nextRecord1()) != null){ rownum++; processor.process(rownum,row); } }catch(IOException e){ throw Exceptions.wrap(e); }catch(Exception e){ throw Exceptions.uncheck(e); }finally{ IO.close(reader); IO.close(parser); } }
future.get(); } catch (Exception e) { Exceptions.uncheckAndThrow(e);
protected static void onInited(AppContext context) { try { context.postInit(); for (AppContextInitializable bean : context.getBeanFactory().getBeans(AppContextInitializable.class)) { bean.postInit(context); } context.getBeanFactory().postInit(context); } catch (Throwable e) { Exceptions.uncheckAndThrow(e); } }
public static String decode(String s) { if(null == s) { return s; } try { return URLDecoder.decode(s, Charsets.UTF_8_NAME); } catch (UnsupportedEncodingException e) { throw Exceptions.wrap(e); } }
protected String[] readLines(String content) { BufferedReader reader = new BufferedReader(new StringReader(content)); List<String> lines = new ArrayList<>(); try { String line; while ((line = reader.readLine()) != null) { lines.add(line); } } catch (IOException e) { throw Exceptions.uncheck(e); } return lines.toArray(new String[lines.size()]); } }
public final void toSql(Appendable buf) { try { toSql_(buf); } catch (IOException e) { Exceptions.wrapAndThrow(e); } }
public static String decode(String s, String charset) { if(null == s) { return s; } try { return URLDecoder.decode(s, charset); } catch (UnsupportedEncodingException e) { throw Exceptions.wrap(e); } }
public static void throwUnchecked(CatchRunnable runnable) { try{ runnable.run(); }catch (Throwable e) { throw Exceptions.uncheck(e); } }
public final void buildStatement(SqlContext context, Sql sql, SqlStatementBuilder stm, Params params) { try { buildStatement_(context, sql, stm, params); } catch (IOException e) { Exceptions.wrapAndThrow(e); } }
@Override public File getFile() { try { return wrapped.getFile(); }catch (IOException e) { throw Exceptions.wrap(e); } }
public static <T> T throwUncheckedWithResult(CatchSupplier<T> supplier) { try{ return supplier.run(); }catch (Throwable e) { throw Exceptions.uncheck(e); } }
/** * Returns the api spec to {@link ApiMetadataBuilder}. */ default ApiMetadataBuilder read(String spec) { try(Reader reader = new StringReader(spec)){ return read(reader); }catch(IOException e) { Exceptions.wrapAndThrow(e); return null; } }
public static String encode(String url) { if(null == url) { return url; } try { return URLEncoder.encode(url, Charsets.UTF_8_NAME); } catch (UnsupportedEncodingException e) { throw Exceptions.wrap(e); } }
private AppClassLoader(ClassLoader parent) { this.parent = parent; this.testing = AppContextInitializer.isTesting(); try { parentLoaderDefineClass = ClassLoader.class.getDeclaredMethod("defineClass", new Class[] {String.class, byte[].class, int.class,int.class}); parentLoaderDefineClass.setAccessible(true); parentFindLoadedClass = ClassLoader.class.getDeclaredMethod("findLoadedClass", String.class); parentFindLoadedClass.setAccessible(true); } catch (Exception e) { throw Exceptions.uncheck(e); } }
public final void prepareBatchStatement(SqlContext context, PreparedBatchSqlStatementBuilder stm,Object[] params) { try { prepareBatchStatement_(context, stm,params); } catch (IOException e) { Exceptions.wrapAndThrow(e); } }
@Override public InputStream getInputStream() throws NestedIOException { try { HttpEntity entity = httpResponse.getEntity(); return null == entity ? null : entity.getContent(); } catch (IOException e) { throw Exceptions.wrap("Error reading response body", e); } }
public void validate(DomDocument doc) throws XmlValidationException,NestedIOException { Validator validator = schema.newValidator(); try { Source source = null; if(null != doc.domDocument()){ source = new DOMSource(doc.domDocument()); }else{ source = new StreamSource(new StringReader(doc.toXml())); } validator.validate(source); } catch (SAXException e) { throw new XmlValidationException(Strings.format("Error validating xml : {0} \n {1}",e.getMessage(),doc.location()),e); } catch (IOException e) { throw Exceptions.uncheck(e); } } }