List of usage examples for java.lang NullPointerException NullPointerException
public NullPointerException(String s)
From source file:it.scoppelletti.mobilepower.app.HelpDialogFragment.java
/** * Istanzia un frammento.//from www. ja v a 2 s. c om * * @param mode Modalità. * @param titleId Identificatore della risorsa del titolo. * @param textId Identificatore della risorsa del testo. * @param prefKey Chiave della preferenza che indica se la Guida è * già stata visualizzata. * @return Frammento. */ public static HelpDialogFragment newInstance(int mode, int titleId, int textId, String prefKey) { Bundle args; HelpDialogFragment fragment; if (StringUtils.isBlank(prefKey)) { throw new NullPointerException("Argument prefKey is null."); } args = new Bundle(); args.putInt(HelpDialogFragment.ARG_MODE, mode); args.putInt(HelpDialogFragment.ARG_TITLEID, titleId); args.putInt(HelpDialogFragment.ARG_TEXTID, textId); args.putString(HelpDialogFragment.ARG_PREFKEY, prefKey); fragment = new HelpDialogFragment(); fragment.setArguments(args); return fragment; }
From source file:com.dianping.lion.util.UrlUtils.java
public static String resolveUrl(String url, Map<String, ?> parameters, String... includes) { if (url == null) { throw new NullPointerException("Param[url] cannot be null."); }// w w w.ja v a 2s. c o m return resolveUrl(url, resolveUrl(parameters, includes)); }
From source file:com.martinkampjensen.thesis.minimization.ObjectiveFunction.java
/** * Constructs a new {@link MultivariateRealFunction} for use with the * optimization classes of the Apache Commons Math package. * // w ww . jav a 2s . com * @param model the model being optimized. * @throws NullPointerException if <code>model</code> is <code>null</code>. * @see <a href="http://commons.apache.org/math/">Apache Commons Math</a> */ public ObjectiveFunction(Model model) { if (model == null) { throw new NullPointerException("model == null"); } _model = model.copy(); }
From source file:edu.cornell.mannlib.vitro.webapp.auth.permissions.DisplayByRolePermission.java
public DisplayByRolePermission(String roleName, RoleLevel roleLevel) { super(NAMESPACE + roleName); if (roleName == null) { throw new NullPointerException("role may not be null."); }//from www . j a v a2s . co m if (roleLevel == null) { throw new NullPointerException("roleLevel may not be null."); } this.roleName = roleName; this.roleLevel = roleLevel; }
From source file:com.espertech.esper.epl.view.OutputConditionPolledTime.java
/** * Constructor.//from ww w .j ava 2 s . c om * @param timePeriod is the number of minutes or seconds to batch events for, may include variables * @param context is the view context for time scheduling */ public OutputConditionPolledTime(ExprTimePeriod timePeriod, AgentInstanceContext context) { if (context == null) { String message = "OutputConditionTime requires a non-null view context"; throw new NullPointerException(message); } this.context = context; this.timePeriod = timePeriod; Double numSeconds = (Double) timePeriod.evaluate(null, true, context); if (numSeconds == null) { throw new IllegalArgumentException( "Output condition by time returned a null value for the interval size"); } if ((numSeconds < 0.001) && (!timePeriod.hasVariable())) { throw new IllegalArgumentException( "Output condition by time requires a interval size of at least 1 msec or a variable"); } this.msecIntervalSize = Math.round(1000 * numSeconds); this.lastUpdate = -msecIntervalSize - 1; }
From source file:Main.java
/** * Get the thread info for the thread with the given name. A null is * returned if no such thread info is found. If more than one thread has the * same name, the thread info for the first one found is returned. * /*from w w w .ja v a 2 s . c om*/ * @param name * the thread name to search for * @return the thread info, or null if not found * @throws NullPointerException * if the name is null */ public static ThreadInfo getThreadInfo(final String name) { if (name == null) { throw new NullPointerException("Null name"); } final Thread[] threads = getAllThreads(); for (Thread thread : threads) { if (thread.getName().equals(name)) { return getThreadInfo(thread.getId()); } } return null; }
From source file:com.nfwork.dbfound.json.JSONDynaBean.java
public boolean contains(String name, String key) { Object value = dynaValues.get(name); if (value == null) { throw new NullPointerException("Unmapped property name: " + name + " key: " + key); } else if (!(value instanceof Map)) { throw new IllegalArgumentException("Non-Mapped property name: " + name + " key: " + key); }/*from w w w. j av a 2 s . c o m*/ return ((Map) value).containsKey(key); }
From source file:net.centro.rtb.monitoringcenter.config.HostAndPort.java
/** * Parses a host and port from a string and instantiates an instance of HostAndPort using the obtained values. * * @param hostAndPortStr a string to parse. * @return an instance of HostAndPort containing the host and port values parsed from the passed in string. * @throws NullPointerException if the passed in string is <tt>null</tt>. * @throws IllegalArgumentException if the passed in string is empty. */// www.j a v a2s. c om public static HostAndPort fromString(String hostAndPortStr) { if (hostAndPortStr == null) { throw new NullPointerException("hostAndPortStr cannot be null"); } if (hostAndPortStr.trim().isEmpty()) { throw new IllegalArgumentException("hostAndPortStr cannot be blank"); } String[] hostAndPortStrParts = hostAndPortStr.split(":"); if (hostAndPortStrParts.length == 2) { String host = hostAndPortStrParts[0].trim(); String portStr = hostAndPortStrParts[1].trim(); Integer port = null; try { port = Integer.parseInt(portStr); } catch (NumberFormatException e) { throw new IllegalArgumentException("Port cannot be parsed from " + portStr, e); } return new HostAndPort(host, port); } else { throw new IllegalArgumentException("Invalid format: " + hostAndPortStr + ". Expected host:port."); } }
From source file:com.cyclopsgroup.waterview.jelly.ScriptLayout.java
/** * Constructor for class JellyScriptLayout * * @param script Jelly script object/*from ww w . j a v a 2 s. c o m*/ * @param module Module to run */ public ScriptLayout(Script script, Module module) { this.script = script; if (script == null) { throw new NullPointerException("Script can not be null"); } setModule(module); }
From source file:org.echocat.nodoodle.server.WebService.java
@Override public void init(ServletContext servletContext) throws ServletException { if (servletContext == null) { throw new NullPointerException("No servletContext provided."); }/*from w w w .j a va 2 s .c o m*/ if (_applicationContext == null) { throw new IllegalStateException("The applicationContext is not set."); } final ServletConfigImpl servletConfig = new ServletConfigImpl(servletContext); _servlet.init(servletConfig); }