List of usage examples for java.lang NullPointerException printStackTrace
public void printStackTrace()
From source file:com.bjorsond.android.timeline.sync.ServerDownloader.java
protected static Groups getGroupsFromServer(User user) { try {// w w w .j a v a 2 s . co m Log.i("DOWNLOADER", "Json Parser started.. Getting all groups for the user " + user.getUserName()); Gson gson = new Gson(); Reader r = new InputStreamReader(getJSONData("/rest/groups/" + user.getUserName() + "/")); Groups groups = null; groups = gson.fromJson(r, Groups.class); try { Log.i("DOWNLOADER", "Fetched " + groups.getGroups().size() + " groups"); } catch (NullPointerException e) { Log.i("DOWNLOADER", "No groups on server!"); } return groups; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:com.ln.methods.Descparser.java
public static void parsedesc() { String Desc = ""; String Title = ""; String Hour = ""; String Minute = ""; String formatted[] = new String[Betaparser.Description.length]; int selectedindex = Main.Titlebox.getSelectedIndex(); for (int i1 = 0; i1 != Betaparser.Hours.length; i1++) { if (Betaparser.Events[i1].startsWith(Main.monthday)) { Desc = Desc + "" + Betaparser.Description[i1] + "~"; Title = Title + "" + Betaparser.Title[i1] + "~"; Hour = Hour + "" + Betaparser.Hours[i1] + "~"; Minute = Minute + "" + Betaparser.Minutes[i1] + "~"; }/*from ww w . ja v a 2 s . c om*/ } String[] Desc2 = StringUtils.substringsBetween(Desc, "", "~"); String[] Title2 = StringUtils.substringsBetween(Title, "", "~"); String[] Hour2 = StringUtils.substringsBetween(Hour, "", "~"); String[] Minute2 = StringUtils.substringsBetween(Minute, "", "~"); String[] Full = new String[Desc2.length]; TTT = ""; DDD = 0; HHH = 0; MMM = 0; for (int i = 0; i != Title2.length; i++) { int h = Integer.parseInt(Hour2[i]); int m = Integer.parseInt(Minute2[i]); DateFormat df = new SimpleDateFormat("dd"); DateFormat dm = new SimpleDateFormat("MM"); Date month = new Date(); Date today = new Date(); int mon = Integer.parseInt(dm.format(month)); int d = Integer.parseInt(df.format(today)); int dif = 0; int ds = 0; int pastd = 0; int pasth = 0; int pastm = 0; d = Main.sdate - d; h = h - Parser.hour; m = m - Parser.minute; if (d > 0) { ds = 1; } if (mon > Main.globmonth) { dif = dif + 1; } if (Main.sdate > d) { dif = dif + 1; } if (h < 0) { pasth = Math.abs(h); } if (m < 0) { pastm = Math.abs(m); h = h - 1; m = m + 60; } if (d < 0) { pastd = d; } if (d > 0 && h < 0) { d = d - 1; h = h + 24; } if (d == 0) { formatted[i] = "<font size=\"4\" color=\"lime\"><br><b>Starts in: " + String.format("%01d Hours %01d Minutes", h, m) + "</b></font>"; } if (d >= 1) { formatted[i] = "<font size=\"4\" color=\"lime\"><br><b>Starts in: " + String.format("%01d Days %01d Hours %01d Minutes", d, h, m) + "</b></font>"; } if (pastd == 0 && h < 0) { formatted[i] = "<font size=\"4\" color=\"#B00000\"><br><b>Event is finished/going on. Started " + String.format("%01d Hours %01d Minutes", pasth, pastm) + " Ago</b></font>"; } if (pastd < 0 && h < 0) { formatted[i] = "<font size=\"4\" color=\"#B00000\"><br><b>Event is finished/going on. Started " + String.format("%01d Days %01d Hours %01d Minutes", pastd, pasth, pastm) + " Ago</b></font>"; } } for (int i = 0; i != Title2.length; i++) { Full[i] = Title2[i]; } try { if (Desc2[selectedindex] != null) { StringBuilder sb = new StringBuilder(Desc2[selectedindex]); int i = 0; while ((i = sb.indexOf(" ", i + 50)) != -1) { // sb.replace(i, i + 1, "<br>"); String formatteddesc = sb.toString(); formatteddesc = formatteddesc.replace("/forum/", "http://www.teamliquid.net/forum/"); TextProcessor processor = BBProcessorFactory.getInstance().create(); formatteddesc = processor.process(formatteddesc); formatteddesc = formatteddesc.replace("#T#", "").replace("#P#", "").replace("#Z#", ""); formatteddesc = formatteddesc.replace("[tlpd#players", "[tlpd][cat]players[/cat]"); formatteddesc = formatteddesc.replace("[/cat]#", "[ID]"); formatteddesc = formatteddesc.replace("sc2-korean]", "[/ID][region]sc2-korean[/region][name]") .replace("sc2-international", "[/ID][region]sc2-international[/region][name]"); formatteddesc = formatteddesc.replace("[/tlpd]", "[/name][/tlpd]"); String[] tlpd = StringUtils.substringsBetween(formatteddesc, "[tlpd]", "[/tlpd]"); String[] cat = StringUtils.substringsBetween(formatteddesc, "[cat]", "[ID]"); String[] ids = StringUtils.substringsBetween(formatteddesc, "[ID]", "[/ID]"); String[] names = StringUtils.substringsBetween(formatteddesc, "[name]", "[/name]"); String[] region = StringUtils.substringsBetween(formatteddesc, "[region]", "[/region]"); try { if (formatteddesc.contains("tlpd")) { formatteddesc = formatteddesc.replace("[tlpd]", "").replace("[/tlpd]", ""); for (int i1 = 0; i1 != tlpd.length; i1++) { formatteddesc = formatteddesc.replace(tlpd[i1], "<a href=\"http://www.teamliquid.net/tlpd/" + cat[i1] + "/" + region[i1] + "/" + ids[i1] + "\">" + names[i1] + "</a>"); // formatteddesc = formatteddesc.replace("[tlpd]", "").replace("[/tlpd]", ""); } } } catch (NullPointerException e) { e.printStackTrace(); } formatteddesc = formatteddesc.replace("<", "").replace("gt;", ""); Main.Description .setText((Full[selectedindex] + formatted[selectedindex] + "<br>" + formatteddesc)); try { if (formatted[selectedindex].contains("lime")) { String[] notfytime = new String[formatted.length]; String[] form = new String[formatted.length]; form[selectedindex] = formatted[selectedindex].replace("Starts in: ", "$"); notfytime[selectedindex] = StringUtils.substringBetween(form[selectedindex], "$", "</b>"); if (formatted[selectedindex].contains("Days")) { String DD = StringUtils.substringBetween(notfytime[selectedindex], "", " Days"); String HH = StringUtils.substringBetween(notfytime[selectedindex], "Days ", " Hours"); String MM = StringUtils.substringBetween(notfytime[selectedindex], "Hours ", " Minutes"); DDD = Integer.parseInt(DD); HHH = Integer.parseInt(HH); MMM = Integer.parseInt(MM); TTT = Full[selectedindex]; } if (!formatted[selectedindex].contains("Days")) { String HH = StringUtils.substringBetween(notfytime[selectedindex], "", " Hours"); String MM = StringUtils.substringBetween(notfytime[selectedindex], "Hours ", " Minutes"); HHH = Integer.parseInt(HH); MMM = Integer.parseInt(MM); TTT = Full[selectedindex]; } } } catch (Exception e) { e.printStackTrace(); } Main.Description.setCaretPosition(0); } } } catch (IndexOutOfBoundsException e) { e.printStackTrace(); } }
From source file:com.thyn.backend.gcm.GcmSender.java
public static void sendMessageToTopic(String topic, String message) { try {/*from w w w.j a va2 s. c o m*/ // Prepare JSON containing the GCM message content. What to send and where to send. JSONObject jGcmData = new JSONObject(); JSONObject jData = new JSONObject(); jData.put("message", message); // Where to send GCM message. String topicName = "/topics/topic_thyN_" + topic.trim(); if (topic != null) { jGcmData.put("to", topicName); } else { jGcmData.put("to", "/topics/global"); } // What to send in GCM message. jGcmData.put("data", jData); // Create connection to send GCM Message request. URL url = new URL("https://android.googleapis.com/gcm/send"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("Authorization", "key=" + API_KEY); conn.setRequestProperty("Content-Type", "application/json"); conn.setRequestMethod("POST"); conn.setDoOutput(true); // Send GCM message content. OutputStream outputStream = conn.getOutputStream(); outputStream.write(jGcmData.toString().getBytes()); // Read GCM response. InputStream inputStream = conn.getInputStream(); String resp = IOUtils.toString(inputStream); System.out.println(resp); System.out.println("Sending message: '" + message + "' to " + topicName); System.out.println("Check your device/emulator for notification or logcat for " + "confirmation of the receipt of the GCM message."); } catch (NullPointerException e) { e.printStackTrace(); } catch (IOException e) { System.out.println("Unable to send GCM message."); System.out.println("Please ensure that API_KEY has been replaced by the server " + "API key, and that the device's registration token is correct (if specified)."); e.printStackTrace(); } }
From source file:takatuka.classreader.dataObjs.attribute.Instruction.java
public static String getMnemonic(int opcode) { try {/*from ww w .ja v a 2 s . c o m*/ return opcodeMnemoicProperties.getProperty(opcode + "").trim().toUpperCase(); } catch (NullPointerException ex) { Miscellaneous.printlnErr("cannot find mnemonic for opcode =" + opcode); ex.printStackTrace(); Miscellaneous.exit(); } return null; }
From source file:net.sf.tweety.cli.plugins.CliMain.java
/** * This method is meant to load the tweety plugin pathes on startup * /*from ww w. jav a2 s. c o m*/ * @return an object with one or more pluginpathes * @throws ConfigurationException */ public static Map<String, String> configCLI() throws ConfigurationException, FileNotFoundException { System.out.println("Initialize CLI..."); // TODO : exception handling for empty/erroneous configuration Map<String, String> loadablePlugins = new HashMap<String, String>(); XMLConfiguration tweetyXmlConfig = new XMLConfiguration(); File in = new File(TWEETY_CLI_DEFAULT_CONFIG); try { System.out.print("Loading Configuration..."); String inPath = in.getAbsolutePath(); tweetyXmlConfig .setBasePath(inPath.substring(0, inPath.length() - TWEETY_CLI_DEFAULT_CONFIG.length() - 1)); tweetyXmlConfig.load(in); System.out.print("success.\n"); } catch (NullPointerException e) { e.printStackTrace(); } // map ueber "plugins.plugin" mit keys () // TODO: Verhalten bei leeren Feldern pruefen // TODO: Verhalten bei einem einzelnen Eintrag prfen Iterator<String> it = tweetyXmlConfig.getKeys("plugin"); // // TODO fix the casts! // if (it.hasNext()) { // // String pluginPath = (String) tweetyXmlConfig.getProperty(it.next() // .toString()); // // String pluginName = (String) tweetyXmlConfig.getProperty(it.next() // .toString()); // // // for (int i = 0; i < pluginPath.size(); i++) { // // System.out.println(pluginName.get(i) + pluginPath.get(i)); // loadablePlugins.put(pluginName, pluginPath); // } // } System.out.print("Getting Plugins..."); // TODO fix the casts! if (it.hasNext()) { @SuppressWarnings("unchecked") ArrayList<String> pluginPath = (ArrayList<String>) tweetyXmlConfig.getProperty(it.next()); @SuppressWarnings("unchecked") ArrayList<String> pluginName = (ArrayList<String>) tweetyXmlConfig.getProperty(it.next()); for (int i = 0; i < pluginPath.size(); i++) { // System.out.println(pluginName.get(i) + pluginPath.get(i)); loadablePlugins.put(pluginName.get(i), pluginPath.get(i)); } } System.out.print("done.\n"); System.out.println("CLI initialized"); return loadablePlugins; }
From source file:control.LoadControler.java
public static Set<File> listFilesForFolder(final File folder) { Set<File> set = new HashSet<>(); // JOptionPane.showMessageDialog(null, "Chargement :\n" + folder); // DEBUG try {//from w ww . ja v a 2 s . co m for (final File fileEntry : folder.listFiles()) { if (fileEntry.isDirectory()) { listFilesForFolder(fileEntry); } else { set.add(fileEntry); } } } catch (NullPointerException e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, e); } return set; }
From source file:com.cws.esolutions.core.listeners.CoreServiceInitializer.java
/** * Initializes the core service in a standalone mode - used for applications outside of a container or when * run as a standalone jar./*from w w w. ja v a 2 s . c o m*/ * * @param configFile - The service configuration file to utilize * @param logConfig - The logging configuration file to utilize * @param loadSecurity - Flag to start security * @param startConnections - Flag to start connections * @throws CoreServiceException @{link com.cws.esolutions.core.exception.CoreServiceException} * if an exception occurs during initialization */ public static void initializeService(final String configFile, final String logConfig, final boolean loadSecurity, final boolean startConnections) throws CoreServiceException { URL xmlURL = null; JAXBContext context = null; Unmarshaller marshaller = null; SecurityConfig secConfig = null; CoreConfigurationData configData = null; SecurityConfigurationData secConfigData = null; if (loadSecurity) { secConfigData = SecurityServiceBean.getInstance().getConfigData(); secConfig = secConfigData.getSecurityConfig(); } final String serviceConfig = (StringUtils.isBlank(configFile)) ? System.getProperty("coreConfigFile") : configFile; final String loggingConfig = (StringUtils.isBlank(logConfig)) ? System.getProperty("coreLogConfig") : logConfig; try { try { DOMConfigurator.configure(Loader.getResource(loggingConfig)); } catch (NullPointerException npx) { try { DOMConfigurator.configure(FileUtils.getFile(loggingConfig).toURI().toURL()); } catch (NullPointerException npx1) { System.err.println("Unable to load logging configuration. No logging enabled!"); System.err.println(""); npx1.printStackTrace(); } } xmlURL = CoreServiceInitializer.class.getClassLoader().getResource(serviceConfig); if (xmlURL == null) { // try loading from the filesystem xmlURL = FileUtils.getFile(configFile).toURI().toURL(); } context = JAXBContext.newInstance(CoreConfigurationData.class); marshaller = context.createUnmarshaller(); configData = (CoreConfigurationData) marshaller.unmarshal(xmlURL); CoreServiceInitializer.appBean.setConfigData(configData); if (startConnections) { Map<String, DataSource> dsMap = CoreServiceInitializer.appBean.getDataSources(); if (DEBUG) { DEBUGGER.debug("dsMap: {}", dsMap); } if (dsMap == null) { dsMap = new HashMap<String, DataSource>(); } for (DataSourceManager mgr : configData.getResourceConfig().getDsManager()) { if (!(dsMap.containsKey(mgr.getDsName()))) { StringBuilder sBuilder = new StringBuilder() .append("connectTimeout=" + mgr.getConnectTimeout() + ";") .append("socketTimeout=" + mgr.getConnectTimeout() + ";") .append("autoReconnect=" + mgr.getAutoReconnect() + ";") .append("zeroDateTimeBehavior=convertToNull"); if (DEBUG) { DEBUGGER.debug("StringBuilder: {}", sBuilder); } BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(mgr.getDriver()); dataSource.setUrl(mgr.getDataSource()); dataSource.setUsername(mgr.getDsUser()); dataSource.setConnectionProperties(sBuilder.toString()); dataSource.setPassword(PasswordUtils.decryptText(mgr.getDsPass(), mgr.getSalt(), secConfig.getSecretAlgorithm(), secConfig.getIterations(), secConfig.getKeyBits(), secConfig.getEncryptionAlgorithm(), secConfig.getEncryptionInstance(), configData.getAppConfig().getEncoding())); if (DEBUG) { DEBUGGER.debug("BasicDataSource: {}", dataSource); } dsMap.put(mgr.getDsName(), dataSource); } } if (DEBUG) { DEBUGGER.debug("dsMap: {}", dsMap); } CoreServiceInitializer.appBean.setDataSources(dsMap); } } catch (JAXBException jx) { jx.printStackTrace(); throw new CoreServiceException(jx.getMessage(), jx); } catch (MalformedURLException mux) { mux.printStackTrace(); throw new CoreServiceException(mux.getMessage(), mux); } }
From source file:com.anjlab.sat3.Program.java
private static void verifySatisfiable(ObjectArrayList ctf, ObjectArrayList route) { boolean satisfiable = false; try {//from w w w. j av a2 s .co m satisfiable = Helper.evaluate(ctf, route); } catch (NullPointerException e) { // Bad route e.printStackTrace(); } if (!satisfiable) { throw new AssertionError("HSS was built but CTF is not satisfiable with values from HS route"); } else { LOGGER.info("CTF verified as satisfiable with variables from HSS route"); } }
From source file:com.anjlab.sat3.Program.java
private static void verifySatisfiable(ITabularFormula formula, ObjectArrayList route) { boolean satisfiable = false; try {//from w w w. j a v a 2 s . c o m satisfiable = formula.evaluate(route); } catch (NullPointerException e) { // Bad route e.printStackTrace(); } if (!satisfiable) { throw new AssertionError( "HSS was built but initial formula is not satisfiable with values from HS route"); } else { LOGGER.info("Initial formula verified as satisfiable with variables from HSS route"); } }
From source file:swift.selenium.Automation.java
/** Loads the Config sheet into HashMap **/ public static void LoadConfigData(String configFile) throws IOException { try {// w ww .j a va 2s .c o m Date initialDate = new Date(); String strInitialDate = dtFormat.format(initialDate); TransactionMapping.report.setFromDate(strInitialDate); DataFormatter format = new DataFormatter(); //String projectPath = System.getProperty("user.dir"); //String configPath = projectPath + "\\CommonResources\\Config.xls"; HSSFSheet configSheet = ExcelUtility.GetSheet(configFile, "Config"); for (int rowIndex = 1; rowIndex <= configSheet.getLastRowNum(); rowIndex++) { HSSFRow rowActual = configSheet.getRow(rowIndex); String parameterName = format.formatCellValue(rowActual.getCell(0)); String value = format.formatCellValue(rowActual.getCell(1)); // Following 'if' is replacement of above, checks if parameterName and value are neither null nor Blank if (StringUtils.isNotBlank(parameterName) || StringUtils.isNotBlank(value)) { configHashMap.put(parameterName, value); } } if (configHashMap.containsKey("MOBILETEST")) { if (configHashMap.get("MOBILETEST").toString().equalsIgnoreCase("true")) { String appiumconfigPath = configHashMap.get("APPIUM_CONFIG_PATH").toString(); HSSFSheet appiumconfigSheet = ExcelUtility.GetSheet(appiumconfigPath, "Config"); int arowCount = appiumconfigSheet.getLastRowNum() + 1; for (int rowIndex = 1; rowIndex < arowCount; rowIndex++) { HSSFRow rowActual = appiumconfigSheet.getRow(rowIndex); String parameterName = format.formatCellValue(rowActual.getCell(0)); String value = format.formatCellValue(rowActual.getCell(1)); if (StringUtils.isNotBlank(parameterName) || StringUtils.isNotBlank(value)) { appiumConfigMap.put(parameterName, value); } } } } } catch (NullPointerException npe) { TransactionMapping.pauseFun("Null Values Found in Config Sheet"); npe.printStackTrace(); } catch (Exception e) { e.printStackTrace(); TransactionMapping.pauseFun(e.getMessage() + " From LoadConfig Function"); } }