List of usage examples for java.lang NullPointerException NullPointerException
public NullPointerException()
From source file:XMLResourceBundleControl.java
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException { if ((baseName == null) || (locale == null) || (format == null) || (loader == null)) { throw new NullPointerException(); }// w w w .j a v a 2 s . c o m ResourceBundle bundle = null; if (!format.equals(XML)) { return null; } String bundleName = toBundleName(baseName, locale); String resourceName = toResourceName(bundleName, format); URL url = loader.getResource(resourceName); if (url == null) { return null; } URLConnection connection = url.openConnection(); if (connection == null) { return null; } if (reload) { connection.setUseCaches(false); } InputStream stream = connection.getInputStream(); if (stream == null) { return null; } BufferedInputStream bis = new BufferedInputStream(stream); bundle = new XMLResourceBundle(bis); bis.close(); return bundle; }
From source file:com.fizzed.rocker.runtime.HtmlStringify.java
@Override public String s(Object obj) { // what to do with null objects? if (obj == null) { throw new NullPointerException(); }/*from ww w . j a v a2s. c o m*/ return s(obj.toString()); }
From source file:DeliberateException.java
public void init(ServletConfig config) throws ServletException { super.init(config); throw new NullPointerException(); }
From source file:simple.crawler.http.HttpClientUtil.java
public static Cookie addCookie(HttpClient httpclient, String name, String value) { if (httpclient == null) { throw new NullPointerException(); }/*from w w w . jav a2 s .c o m*/ BasicClientCookie cookie = new BasicClientCookie(name, value); ((AbstractHttpClient) httpclient).getCookieStore().addCookie(cookie); return cookie; }
From source file:lda.inference.internal.Topics.java
Topics(LDA lda) { if (lda == null) throw new NullPointerException(); topics = new ArrayList<>(); for (int t = 0; t < lda.getNumTopics(); ++t) { topics.add(new Topic(t, lda.getBow().getNumVocabs())); }//from ww w .ja va 2 s. c o m }
From source file:StringUtils.java
/** * Replaces a string with an other string. * * @param orig Original string. Null is safe. * @param src The string to find.// w w w .j a v a2 s . c o m * @param dest The string to replace <I>src</I> with. * @return A string with the replacement done. */ public static final String replaceString(String orig, String src, String dest) { if (orig == null) return null; if (src == null || dest == null) throw new NullPointerException(); if (src.length() == 0) return orig; StringBuffer res = new StringBuffer(orig.length() + 20); // Pure guesswork int start = 0; int end = 0; int last = 0; while ((start = orig.indexOf(src, end)) != -1) { res.append(orig.substring(last, start)); res.append(dest); end = start + src.length(); last = start + src.length(); } res.append(orig.substring(end)); return res.toString(); }
From source file:com.milaboratory.util.CompressionType.java
private static InputStream createInputStream(CompressionType ct, InputStream is) throws IOException { switch (ct) { case None://from w ww.j a va2 s .c om return is; case GZIP: return new GZIPInputStream(is, 2048); case BZIP2: CompressorStreamFactory factory = new CompressorStreamFactory(); try { return factory.createCompressorInputStream(CompressorStreamFactory.BZIP2, new BufferedInputStream(is)); } catch (CompressorException e) { throw new IOException(e); } } throw new NullPointerException(); }
From source file:XMLResourceBundleControl.java
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException {/*from w w w . ja v a2 s.co m*/ if ((baseName == null) || (locale == null) || (format == null) || (loader == null)) { throw new NullPointerException(); } ResourceBundle bundle = null; if (!format.equals(XML)) { return null; } String bundleName = toBundleName(baseName, locale); String resourceName = toResourceName(bundleName, format); URL url = loader.getResource(resourceName); if (url == null) { return null; } URLConnection connection = url.openConnection(); if (connection == null) { return null; } if (reload) { connection.setUseCaches(false); } InputStream stream = connection.getInputStream(); if (stream == null) { return null; } BufferedInputStream bis = new BufferedInputStream(stream); bundle = new XMLResourceBundle(bis); bis.close(); return bundle; }
From source file:pdsanchez.mywebtools.model.service.ToolsSvcImpl.java
@Override public void addTool(Tool tool) { if (tool == null) { throw new NullPointerException(); }// w w w . j a va 2s.co m Category category = this.addCategory(tool.getCategory()); tool.setCategory(category); Subcategory subcategory = this.addSubcategory(tool.getSubcategory()); tool.setSubcategory(subcategory); toolDAO.create(tool); }
From source file:com.collective.celos.Util.java
public static <T> T requireNonNull(T object) { if (object == null) throw new NullPointerException(); else//w w w . ja va 2 s.c o m return object; }