List of usage examples for java.lang NullPointerException NullPointerException
public NullPointerException(String s)
From source file:com.activecq.api.utils.ValidationUtil.java
/** * Checks if the value @ key is a path that exists in the JCR * * @param form//from w w w . j av a 2 s . c o m * @param key * @param resourceResolver * @return * @throws NullPointerException */ public static boolean isValidPath(ActiveForm form, String key, ResourceResolver resourceResolver) throws NullPointerException { if (!isPresent(form, key)) { return false; } if (resourceResolver == null) { throw new NullPointerException("ResourceResolver cannot be null."); } String val = form.get(key); Resource r = resourceResolver.resolve(val); return r != null && !(ResourceUtil.isA(r, NonExistingResource.RESOURCE_TYPE_NON_EXISTING)); }
From source file:com.pamarin.income.service.impl.IncomeItemServiceImpl.java
@Override public void delete(IncomeItem item) { if (item == null) { throw new NullPointerException("item is null."); }//w ww . j a v a 2s . c om repo.delete(item.getId()); }
From source file:com.multimedia.service.commonImage.CmsCommonImageServiceImpl.java
@Override public void init() { super.init(); StringBuilder sb = new StringBuilder(); common.utils.MiscUtils.checkNotNull(commonItemService, "commonItemService", sb); if (sb.length() > 0) { throw new NullPointerException(sb.toString()); }//w ww. jav a2s . c o m }
From source file:com.elasticgrid.examples.video.MencoderEncoder.java
public MencoderEncoder(boolean enableLog) { this.enableLog = enableLog; String rioHome = System.getProperty("org.rioproject.home"); if (rioHome == null) { throw new NullPointerException("Rio home property should be set!"); }//from ww w . jav a 2s. c o m String osName = System.getProperty("os.name"); try { if (osName.contains("Windows")) { encoderLocation = "mencoder.exe"; } else if (osName.contains("Linux")) { encoderLocation = "mencoder"; } else if (osName.contains("Mac")) { encoderLocation = "mencoder"; } else { throw new RuntimeException("Unsupported OS: " + osName); } logger.log(Level.INFO, "Using encoder located in {0}", encoderLocation); } catch (Exception e) { throw new RuntimeException("Can't find appropriate mencoder software", e); } }
From source file:net.ontopia.persistence.query.jdo.JDOField.java
public JDOField(JDOValueIF root, String name, boolean evaluatable) { this(root, new String[] { name }, evaluatable); if (name == null) throw new NullPointerException("Field name cannot be null."); }
From source file:net.dv8tion.jda.player.Playlist.java
public static Playlist getPlaylist(String url) { List<String> infoArgs = new LinkedList<>(); infoArgs.addAll(YOUTUBE_DL_PLAYLIST_ARGS); infoArgs.add("--"); //Url separator. Deals with YT ids that start with -- infoArgs.add(url);//from w w w .j av a 2s . c om //Fire up Youtube-dl and get all sources from the provided url. List<AudioSource> sources = new ArrayList<>(); Scanner scan = null; try { Process infoProcess = new ProcessBuilder().command(infoArgs).start(); byte[] infoData = IOUtils.readFully(infoProcess.getInputStream(), -1, false); if (infoData == null || infoData.length == 0) throw new NullPointerException( "The YT-DL playlist process resulted in a null or zero-length INFO!"); String sInfo = new String(infoData); scan = new Scanner(sInfo); JSONObject source = new JSONObject(scan.nextLine()); if (source.has("_type"))//Is a playlist { sources.add(new RemoteSource(source.getString("url"))); while (scan.hasNextLine()) { source = new JSONObject(scan.nextLine()); sources.add(new RemoteSource(source.getString("url"))); } } else //Single source link { sources.add(new RemoteSource(source.getString("webpage_url"))); } } catch (IOException e) { e.printStackTrace(); } finally { if (scan != null) scan.close(); } //Now that we have all the sources we can create our Playlist object. Playlist playlist = new Playlist("New Playlist"); playlist.sources = sources; return playlist; }
From source file:com.pamarin.income.service.impl.ExpensesItemServiceImpl.java
@Override public void delete(ExpensesItem item) { if (item == null) { throw new NullPointerException("item is null."); }/*www.ja v a 2s . co m*/ repo.delete(item.getId()); }
From source file:ml.dmlc.xgboost4j.java.Booster.java
/** * Load a new Booster model from modelPath * @param modelPath The path to the model. * @return The created Booster.//from ww w. j ava 2s . com * @throws XGBoostError */ static Booster loadModel(String modelPath) throws XGBoostError { if (modelPath == null) { throw new NullPointerException("modelPath : null"); } Booster ret = new Booster(new HashMap<String, Object>(), new DMatrix[0]); XGBoostJNI.checkCall(XGBoostJNI.XGBoosterLoadModel(ret.handle, modelPath)); return ret; }
From source file:edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.FilterByRoleLevelPermission.java
private static Permission getPermissionFromRequest(HttpServletRequest req) { if (req == null) { throw new NullPointerException("request may not be null."); }//from w ww . j a va 2 s. c o m IdentifierBundle ids = RequestIdentifiers.getIdBundleForRequest(req); for (Permission p : HasPermission.getPermissions(ids)) { if (p instanceof DisplayByRolePermission) { return p; } } return getDefaultPermission(req.getSession().getServletContext()); }
From source file:de.phoenix.rs.key.UpdateEntity.java
/** * Construct an empty UpdateEntity with the new Object as payload. * //from ww w. j ava2s . c o m * @param newObject * The object containing the values which replaces the old ones */ public UpdateEntity(T newObject) { if (newObject == null) { throw new NullPointerException("The new object cannot be null!"); } this.newObject = newObject; }