List of usage examples for java.lang NullPointerException printStackTrace
public void printStackTrace()
From source file:com.likya.myra.jef.controller.BaseSchedulerController.java
@SuppressWarnings("unchecked") public int getNumOfActiveJobs() { StateName.Enum filterStates[] = { StateName.RUNNING }; HashMap<String, AbstractJobType> abstractJobTypeList = JobQueueOperations.toAbstractJobTypeList(jobQueue); Collection<AbstractJobType> filteredList; int listSize = 0; try {//from ww w .j a v a 2 s. c o m filteredList = CollectionUtils.select(abstractJobTypeList.values(), new StateFilter(filterStates).anyPredicate()); listSize = filteredList.size(); } catch (NullPointerException n) { n.printStackTrace(); } // System.err.println("filteredList.size() : " + filteredList.size()); return listSize; }
From source file:org.processmining.analysis.performance.PerformanceLogReplayResult.java
/** * Calculates the average, min ad max throughput time out of the throughput * times of all traces in piList. Next to this, the arrival rate is * calculated. All metrics are based on the process instances in piList only * //from w w w . jav a 2s . c om * @param piList * ArrayList: the process instances used * @param fitOption * int: the fit option used (how to deal with non-conformance) * @throws Exception */ public void calculateMetrics(ArrayList piList, int fitOption) throws Exception { properFrequency = 0; timeStats.clear(); arrivalStats.clear(); ArrayList arrivalDates = new ArrayList(); ListIterator lit = piList.listIterator(); while (lit.hasNext()) { ExtendedLogTrace currentTrace = (ExtendedLogTrace) lit.next(); if (currentTrace.hasProperlyTerminated() && currentTrace.hasSuccessfullyExecuted()) { properFrequency++; } try { long tp = (currentTrace.getEndDate().getTime() - currentTrace.getBeginDate().getTime()); if (fitOption == 0) { // timeStats based on all traces timeStats.addValue(tp); arrivalDates.add(currentTrace.getBeginDate()); } if (currentTrace.hasProperlyTerminated() && currentTrace.hasSuccessfullyExecuted()) { if (fitOption == 1) { // timeStats based on fitting traces only timeStats.addValue(tp); arrivalDates.add(currentTrace.getBeginDate()); } } } catch (NullPointerException ex) { ex.printStackTrace(); } } Date[] arrivals = (Date[]) arrivalDates.toArray(new Date[0]); // make sure arrivaldates are sorted Arrays.sort(arrivals); if (arrivals.length > 1) { for (int i = 1; i < arrivals.length; i++) { long t1 = arrivals[i].getTime(); long t2 = arrivals[i - 1].getTime(); long iat = arrivals[i].getTime() - arrivals[i - 1].getTime(); if (iat >= 0) { arrivalStats.addValue(iat); } } } }
From source file:org.digitalcampus.oppia.model.Course.java
public void setLangsFromJSONString(String jsonStr) { try {/*from w w w . ja va 2s .c om*/ JSONArray langsArray = new JSONArray(jsonStr); for (int i = 0; i < langsArray.length(); i++) { JSONObject titleObj = langsArray.getJSONObject(i); @SuppressWarnings("unchecked") Iterator<String> iter = (Iterator<String>) titleObj.keys(); while (iter.hasNext()) { Lang l = new Lang(iter.next().toString(), ""); this.langs.add(l); } } } catch (JSONException e) { e.printStackTrace(); } catch (NullPointerException npe) { npe.printStackTrace(); } }
From source file:com.savor.ads.core.Session.java
/** * boxId?Mac?/*w ww . ja v a2s.co m*/ */ public static String getWiredMacAddr() { String cmd = "busybox ifconfig eth0"; Process process = null; InputStream is = null; try { process = Runtime.getRuntime().exec(cmd); is = process.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String line = reader.readLine(); return line.substring(line.indexOf("HWaddr") + 6).trim().replaceAll(":", ""); } catch (NullPointerException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (is != null) { is.close(); } } catch (IOException e) { e.printStackTrace(); } } return ""; }
From source file:com.dtolabs.rundeck.core.resources.TestURLResourceModelSource.java
public void testConfigureProperties() throws Exception { final URLResourceModelSource provider = new URLResourceModelSource(getFrameworkInstance()); try {/*from w w w . j a v a2 s . c om*/ provider.configure(null); fail("Should throw NPE"); } catch (NullPointerException e) { e.printStackTrace(); } Properties props = new Properties(); try { provider.configure(props); fail("shouldn't succeed"); } catch (ConfigurationException e) { assertEquals("project is required", e.getMessage()); } props.setProperty("project", PROJ_NAME); try { provider.configure(props); fail("shouldn't succeed"); } catch (ConfigurationException e) { assertEquals("url is required", e.getMessage()); } props.setProperty("url", "blah"); try { provider.configure(props); fail("shouldn't succeed"); } catch (ConfigurationException e) { assertTrue(e.getMessage().startsWith("url is malformed")); } props.setProperty("url", "ftp://example.com/blah"); try { provider.configure(props); fail("shouldn't succeed"); } catch (ConfigurationException e) { assertTrue(e.getMessage().startsWith("url protocol not allowed: ")); } props.setProperty("url", "http://example.com/test"); provider.configure(props); assertNotNull(provider.configuration.nodesUrl); assertEquals("http://example.com/test", provider.configuration.nodesUrl.toExternalForm()); assertEquals(PROJ_NAME, provider.configuration.project); props.setProperty("url", "https://example.com/test"); provider.configure(props); assertNotNull(provider.configuration.nodesUrl); assertEquals("https://example.com/test", provider.configuration.nodesUrl.toExternalForm()); props.setProperty("url", "file://some/file"); provider.configure(props); assertNotNull(provider.configuration.nodesUrl); assertEquals("file://some/file", provider.configuration.nodesUrl.toExternalForm()); props.setProperty("timeout", "notanumber"); try { provider.configure(props); fail("shouldn't succeed"); } catch (ConfigurationException e) { assertTrue(e.getMessage().startsWith("timeout is invalid: ")); } props.setProperty("timeout", "12345"); provider.configure(props); assertEquals(12345, provider.configuration.timeout); assertEquals(true, provider.configuration.useCache); props.setProperty("cache", "false"); provider.configure(props); assertEquals(false, provider.configuration.useCache); }
From source file:io.github.jeremgamer.editor.panels.Labels.java
public Labels(final JFrame frame, final LabelPanel lp, final PanelSave ps) { this.frame = frame; this.setBorder(BorderFactory.createTitledBorder("")); JButton add = null;// w ww . j a v a 2 s .com try { add = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png")))); } catch (IOException e) { e.printStackTrace(); } add.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") String name = jop.showInputDialog((JFrame) SwingUtilities.windowForComponent(labelList), "Nommez le label :", "Crer un label", JOptionPane.QUESTION_MESSAGE); if (name != null) { for (int i = 0; i < data.getSize(); i++) { if (data.get(i).equals(name)) { name += "1"; } } data.addElement(name); new LabelSave(name); ActionPanel.updateLists(); OtherPanel.updateLists(); PanelsPanel.updateLists(); } } catch (IOException e) { e.printStackTrace(); } } }); JButton remove = null; try { remove = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e) { e.printStackTrace(); } remove.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { if (labelList.getSelectedValue() != null) { File file = new File("projects/" + Editor.getProjectName() + "/labels/" + labelList.getSelectedValue() + ".rbd"); JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") int option = jop.showConfirmDialog((JFrame) SwingUtilities.windowForComponent(labelList), "tes-vous sr de vouloir supprimer ce label?", "Avertissement", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (option == JOptionPane.OK_OPTION) { File dir = new File("projects/" + Editor.getProjectName() + "/panels"); for (File f : FileUtils.listFilesAndDirs(dir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) { if (!f.isDirectory()) { try { ps.load(f); } catch (IOException e) { e.printStackTrace(); } for (String section : ps .getSectionsContaining(labelList.getSelectedValue() + " (Label)")) { ps.removeSection(section); try { ps.save(f); } catch (IOException e) { e.printStackTrace(); } } } } if (labelList.getSelectedValue().equals(lp.getFileName())) { lp.setFileName(""); } lp.hide(); file.delete(); data.remove(labelList.getSelectedIndex()); ActionPanel.updateLists(); OtherPanel.updateLists(); PanelsPanel.updateLists(); } } } catch (NullPointerException npe) { npe.printStackTrace(); } } }); JPanel buttons = new JPanel(); buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS)); buttons.add(add); buttons.add(remove); updateList(); labelList.addMouseListener(new MouseAdapter() { @SuppressWarnings("unchecked") public void mouseClicked(MouseEvent evt) { JList<String> list = (JList<String>) evt.getSource(); if (evt.getClickCount() == 2) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { lp.show(); lp.load(new File("projects/" + Editor.getProjectName() + "/labels/" + list.getModel().getElementAt(index) + ".rbd")); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { lp.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { lp.hideThenShow(); previousSelection = list.getSelectedValue(); lp.load(new File("projects/" + Editor.getProjectName() + "/labels/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { lp.hide(); list.clearSelection(); } } } else if (evt.getClickCount() == 3) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { lp.show(); lp.load(new File("projects/" + Editor.getProjectName() + "/labels/" + list.getModel().getElementAt(index) + ".rbd")); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { lp.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { lp.hideThenShow(); previousSelection = list.getSelectedValue(); lp.load(new File("projects/" + Editor.getProjectName() + "/labels/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { lp.hide(); list.clearSelection(); } } } } }); JScrollPane listPane = new JScrollPane(labelList); listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); this.add(buttons); this.add(listPane); }
From source file:jade.lang.acl.StringACLCodec.java
/** * if there was an automatical Base64 encoding, then it performs * automatic decoding./*from w ww .j a v a2 s.c o m*/ **/ private void checkBase64Encoding(ACLMessage msg) { String encoding = msg.getUserDefinedParameter(BASE64ENCODING_KEY); if (CaseInsensitiveString.equalsIgnoreCase(BASE64ENCODING_VALUE, encoding)) { try { // decode Base64 String content = msg.getContent(); if ((content != null) && (content.length() > 0)) { //char[] cc = new char[content.length()]; //content.getChars(0,content.length(),cc,0); msg.setByteSequenceContent(Base64.decodeBase64(content.getBytes("US-ASCII"))); msg.removeUserDefinedParameter(BASE64ENCODING_KEY); // reset the slot value for encoding } } catch (java.lang.StringIndexOutOfBoundsException e) { e.printStackTrace(); } catch (java.lang.NullPointerException e2) { e2.printStackTrace(); } catch (java.lang.NoClassDefFoundError jlncdfe) { System.err.println("\t\t===== E R R O R !!! =======\n"); System.err.println("Missing support for Base64 conversions"); System.err.println("Please refer to the documentation for details."); System.err.println("=============================================\n\n"); try { Thread.currentThread().sleep(3000); } catch (InterruptedException ie) { } } catch (UnsupportedEncodingException e3) { System.err.println("\t\t===== E R R O R !!! =======\n"); System.err.println("Missing support for US-ASCII encoding for Base64 conversions"); } } //end of if CaseInsensitiveString }
From source file:com.jainbooks.activitys.DashboardActivity.java
@Override public void onBackPressed() { try {// ww w .j a va2 s. com setTitle(mFragmentTitlesTitles[currentPosition]); } catch (NullPointerException e) { e.printStackTrace(); } int i = getFragmentManager().getBackStackEntryCount(); if (i == 0) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); // set title alertDialogBuilder.setTitle(R.string.app_name); // set dialog message alertDialogBuilder.setMessage("Do you want to exit ?").setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); finish(); } }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // if this button is clicked, just close // the dialog box and do nothing dialog.cancel(); } }); // create alert dialog AlertDialog alertDialog = alertDialogBuilder.create(); // show it alertDialog.show(); } else { super.onBackPressed(); } }
From source file:com.siacra.beans.PermanenciaDocBean.java
public Docente getPrincipal() { try {//from ww w . j av a 2s . c om Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String name = auth.getName(); User user = getUserService().getUserLogin(name); if (!getDocenteService().existDocente(user.getIdUsuario())) { principal = getDocenteService().getDocenteByUser(user.getIdUsuario()); } } catch (NullPointerException e) { e.printStackTrace(); } return principal; }
From source file:fr.cobaltians.cobalt.plugin.CobaltPluginManager.java
/**************************************************************************************************************************************** * COBALT METHODS/*from w w w. j a va 2s . com*/ ****************************************************************************************************************************************/ public boolean onMessage(Context context, CobaltFragment fragment, JSONObject message) { try { String pluginName = message.getString(Cobalt.kJSPluginName); Class<? extends CobaltAbstractPlugin> pluginClass = mPluginsMap.get(pluginName); if (pluginClass != null) { try { Method pluginGetInstanceMethod = pluginClass.getDeclaredMethod(GET_INSTANCE_METHOD_NAME, CobaltPluginWebContainer.class); try { CobaltPluginWebContainer webContainer = new CobaltPluginWebContainer((Activity) context, fragment); CobaltAbstractPlugin plugin = (CobaltAbstractPlugin) pluginGetInstanceMethod.invoke(null, webContainer); plugin.onMessage(webContainer, message); return true; } catch (NullPointerException exception) { if (Cobalt.DEBUG) { Log.e(TAG, "onMessage: " + pluginClass.getSimpleName() + ".getInstance(CobaltPluginWebContainer) method must be static."); exception.printStackTrace(); } } catch (IllegalAccessException exception) { if (Cobalt.DEBUG) exception.printStackTrace(); } catch (InvocationTargetException exception) { if (Cobalt.DEBUG) { Log.e(TAG, "onMessage: exception thrown by " + pluginClass.getSimpleName() + ".getInstance(CobaltPluginWebContainer) method."); exception.printStackTrace(); } } } catch (NoSuchMethodException exception) { if (Cobalt.DEBUG) { Log.e(TAG, "onMessage: no method found matching " + pluginClass.getSimpleName() + ".getInstance(CobaltPluginWebContainer)."); exception.printStackTrace(); } } } else if (Cobalt.DEBUG) Log.e(TAG, "onMessage: no plugin class found for name " + pluginName + "."); } catch (JSONException exception) { if (Cobalt.DEBUG) { Log.e(TAG, "onMessage: name field not found or not a String."); exception.printStackTrace(); } } return false; }