List of usage examples for java.lang NullPointerException NullPointerException
public NullPointerException(String s)
From source file:edu.cornell.mannlib.vitro.webapp.auth.permissions.EditByRolePermission.java
public EditByRolePermission(String roleName, RoleLevel roleLevel) { super(NAMESPACE + roleName); if (roleName == null) { throw new NullPointerException("role may not be null."); }/*from w w w. j a v a 2 s . co m*/ if (roleLevel == null) { throw new NullPointerException("roleLevel may not be null."); } this.roleName = roleName; this.roleLevel = roleLevel; }
From source file:edu.cornell.mannlib.vitro.webapp.utils.SparqlQueryRunner.java
public SparqlQueryRunner(Model model) { if (model == null) { throw new NullPointerException("model may not be null."); }//from w w w. j ava 2 s. co m this.model = model; }
From source file:org.springframework.data.mapping.model.JsonPropertyPreservingFieldNamingStrategy.java
/** * @param backingStrategy the field naming strategy to use if the {@link JsonProperty} annotation isn't present *///from w w w . java2 s. c o m public JsonPropertyPreservingFieldNamingStrategy(FieldNamingStrategy backingStrategy) { if (backingStrategy == null) { throw new NullPointerException("A backing strategy hasn't been specified."); } this.backingStrategy = backingStrategy; }
From source file:com.hellogwt.server.persistence.GreetingDAO.java
@Override @Transactional(readOnly = true)//ww w . j a v a 2s.c o m public Greeting getGreeting(String text) { if (getCurrentSession() == null) { throw new NullPointerException("getCurrentSession() is null !"); } List<Greeting> greetingList = null; try { Query q = getCurrentSession().createQuery("from Greeting as greeting where greeting.text=:text"); q.setParameter("text", text); greetingList = (List<Greeting>) q.list(); } catch (Exception e) { e.printStackTrace(); } return greetingList.size() > 0 ? greetingList.get(0) : null; }
From source file:com.stoxa.SpringXML.Model.ContactBeanFactory.java
@Override public Contact getObject() throws Exception { String firstName;/* w w w. j a v a 2 s .co m*/ String lastName; String phone; String email; try { fis = new FileInputStream("src/main/resources/contacts.properties"); property.load(fis); if (!hasNextInstance()) { throw new NullPointerException( "There are no more contacts in file src/main/resources/contacts.properties, contactCount = " + contactCount); } newContact = new Contact(); firstName = property.getProperty(contactCount + ".firstName"); newContact.setFirstName(firstName); lastName = property.getProperty(contactCount + ".lastName"); newContact.setLastName(lastName); phone = property.getProperty(contactCount + ".phone"); newContact.setPhone(phone); email = property.getProperty(contactCount + ".email"); newContact.setEmail(email); } catch (IOException e) { System.err.println("?: ?? ??!"); } finally { fis.close(); } contactCount++; return newContact; }
From source file:FileUtils.java
/** * /*from ww w .j a va 2 s . c om*/ * Searches through the directory tree under the given context directory and * finds the first file that matches the file name. If the third parameter is * true, the method will also try to match directories, not just "regular" * files. * * @param contextRoot * The directory to start the search from. * * @param fileName * The name of the file (or directory) to search for. * * @param matchDirectories * True if the method should try and match the name against directory * names, not just file names. * * @return The java.io.File representing the <em>first</em> file or * directory with the given name, or null if it was not found. * */ public static File find(File contextRoot, String fileName, boolean matchDirectories) { if (contextRoot == null) throw new NullPointerException("NullContextRoot"); if (fileName == null) throw new NullPointerException("NullFileName"); if (!contextRoot.isDirectory()) { Object[] filler = { contextRoot.getAbsolutePath() }; String message = "NotDirectory"; throw new IllegalArgumentException(message); } File[] files = contextRoot.listFiles(); // // for all children of the current directory... // for (int n = 0; n < files.length; ++n) { String nextName = files[n].getName(); // // if we find a directory, there are two possibilities: // // 1. the names match, AND we are told to match directories. // in this case we're done // // 2. not told to match directories, so recurse // if (files[n].isDirectory()) { if (nextName.equals(fileName) && matchDirectories) return files[n]; File match = find(files[n], fileName); if (match != null) return match; } // // in the case of regular files, just check the names // else if (nextName.equals(fileName)) return files[n]; } return null; }
From source file:com.multimedia.service.advertisement.AdvertisementServiceImpl.java
@Override public void init() { super.init(); StringBuilder sb = new StringBuilder(); common.utils.MiscUtils.checkNotNull(positions, "positions", sb); if (sb.length() > 0) { throw new NullPointerException(sb.toString()); }//from w w w .j a v a 2 s .c o m }
From source file:TableModel.RestaurantTableModel.java
public Object[][] getRowData() { if (rowData != null) return rowData; else// w w w . j a v a2 s . co m throw new NullPointerException("Object[][] variable rowData is null!!"); }
From source file:net.nfpj.webcounter.service.CounterServiceImpl.java
@Inject public CounterServiceImpl(@Named("memCounterDM") CounterDM counterDM) { if (counterDM == null) { throw new NullPointerException("CounterDM cannot be null"); }//from w w w .j a v a 2 s . c o m this.counterDM = counterDM; }
From source file:gallery.web.validator.wallpaper.WallpaperUpdateBindValidator.java
public void init() { StringBuilder sb = new StringBuilder(); common.utils.MiscUtils.checkNotNull(wallpaper_service, "wallpaper_service", sb); if (sb.length() > 0) { throw new NullPointerException(sb.toString()); }/*from w ww.j a va 2 s .co m*/ }