List of usage examples for java.lang NumberFormatException getMessage
public String getMessage()
From source file:com.cloudera.flume.conf.FlumeBuilder.java
/** * Build a flume sink from a flume config specification. Sinks can be much * more complicated than sources.//w w w . j a va2 s . co m * * This should only throw FlumeSpecExceptions (No illegal arg exceptions * anymore) */ public static EventSink buildSink(Context context, String s) throws FlumeSpecException { try { CommonTree snkTree = parseSink(s); return buildEventSink(context, snkTree, sinkFactory); } catch (RecognitionException re) { LOG.debug("Failure to parse and instantiate sink: '" + s + "'", re); throw new FlumeSpecException(re.toString()); } catch (NumberFormatException nfe) { LOG.debug("Failure to parse and instantiate sink: '" + s + "'", nfe); throw new FlumeSpecException(nfe.getMessage()); } catch (IllegalArgumentException iae) { LOG.debug("Failure to parse and instantiate sink: '" + s + "'", iae); throw new FlumeSpecException(iae.getMessage()); } catch (RuntimeRecognitionException re) { LOG.debug("Failure to parse and instantiate sink: '" + s + "'", re); throw new FlumeSpecException(re.getMessage()); } }
From source file:dk.dma.ais.abnormal.analyzer.AbnormalAnalyzerAppModule.java
/** * Initialize internal data structures required to accept/reject track updates based on black list mechanism. * @param configuration/*from w w w . j a va 2 s. c o m*/ * @return */ private static int[] initVesselBlackList(Configuration configuration) { ArrayList<Integer> blacklistedMmsis = new ArrayList<>(); try { List blacklistedMmsisConfig = configuration.getList("blacklist.mmsi"); blacklistedMmsisConfig.forEach(blacklistedMmsi -> { try { Integer blacklistedMmsiBoxed = Integer.valueOf(blacklistedMmsi.toString()); if (blacklistedMmsiBoxed > 0 && blacklistedMmsiBoxed < 1000000000) { blacklistedMmsis.add(blacklistedMmsiBoxed); } else if (blacklistedMmsiBoxed != -1) { LOG.warn("Black listed MMSI no. out of range: " + blacklistedMmsiBoxed + "."); } } catch (NumberFormatException e) { LOG.warn("Black listed MMSI no. \"" + blacklistedMmsi + "\" cannot be cast to integer."); } }); } catch (ConversionException e) { LOG.warn(e.getMessage(), e); } if (blacklistedMmsis.size() > 0) { LOG.info("The following " + blacklistedMmsis.size() + " MMSI numbers are black listed and will not be tracked."); LOG.info(Arrays.toString(blacklistedMmsis.toArray())); } int[] array = new int[blacklistedMmsis.size()]; for (int i = 0; i < blacklistedMmsis.size(); i++) { array[i] = blacklistedMmsis.get(i); } return array; }
From source file:de.iteratec.iteraplan.businesslogic.exchange.legacyExcel.importer.ExcelImportUtilities.java
/** * Creates a NumberAV object from the attrValue for the given number attribute type. * @param at The attribute to which the created number should be linked. * @param attrValue Cell value holder which contains the relevant number value * @param valueOverride an override value for the actual cell content. If this String is non-null/empty and non-whitespace, it will used in the NumberAV, regardless of the cell content in attrValue! * @return A number attribute value object containing the value from attrValue or valueOverride, or <code>null</code> if no number could be parsed *///from ww w . java 2s .com @SuppressWarnings("boxing") private static NumberAV createNumberAV(NumberAT at, CellValueHolder attrValue, String valueOverride) { NumberAV numberV = new NumberAV(); Double cell = null; // if valueOverride is null, use attrValue as "default value" String value = StringUtils.defaultIfBlank(valueOverride, attrValue.getAttributeValue()); try { cell = contentAsDouble(value); } catch (NumberFormatException ex) { String warnMessage = "Cell [" + getCellRef(attrValue.getOriginCell()) + "] Ignoring value " + value + " for attribute type " + at.getName() + " due to error:" + ex.getMessage(); getProcessingLog().warn(warnMessage); attrValue.addProblem(ProblemMarker.WARNING, warnMessage); throw new IllegalArgumentException("\"" + value + "\" is not a number", ex); } catch (IllegalStateException ex) { String warnMessage = "Cell [" + getCellRef(attrValue.getOriginCell()) + "] Ignoring value " + value + " for attribute type " + at.getName() + " due to error:" + ex.getMessage(); getProcessingLog().warn(warnMessage); attrValue.addProblem(ProblemMarker.WARNING, warnMessage); throw new IllegalArgumentException(ex); } if (cell != null) { try { BigDecimal v = BigDecimal.valueOf(cell); numberV.setValue(v); return numberV; } catch (NumberFormatException e) { LOGGER.warn("Couldn't translate a Double into a BigDecimal"); } } return null; }
From source file:com.diversityarrays.kdxplore.KDXplore.java
public static void mainImpl(String[] args, Closure<KDXploreFrame> onCreateCallback, final Closure<UpdateCheckContext> updateChecker) { Locale defaultLocale = Locale.getDefault(); System.out.println("Locale=" + defaultLocale); //$NON-NLS-1$ // System.setProperty("apple.laf.useScreenMenuBar", "true"); // //$NON-NLS-1$ //$NON-NLS-2$ // Initialise the appFolder KdxplorePreferences prefs = KdxplorePreferences.getInstance(); applyUIdefaultPreferences(prefs);/*from ww w.j a va 2 s . co m*/ String kdxploreName = KDXPLORE_APP_NAME; ApplicationFolder defaultAppFolder = ApplicationFolders.getApplicationFolder(kdxploreName); String[] newArgs = CommandArgs.parseRunModeOption(defaultAppFolder, args); String baseNameForDistrib = kdxploreName.toLowerCase(); if (RunMode.DEMO == RunMode.getRunMode()) { kdxploreName = kdxploreName + "Demo"; //$NON-NLS-1$ } final ApplicationFolder appFolder = ApplicationFolders.getApplicationFolder(kdxploreName); CommandArgs commandArgs = new CommandArgs(appFolder, KdxConstants.VERSION, KdxConstants.VERSION_CODE, newArgs); org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(ClassPathExtender.class); if (commandArgs.baseDir == null) { File userDir = new File(System.getProperty("user.dir")); //$NON-NLS-1$ File distribDir; if ("kdxos_main".equals(userDir.getName())) { // In Eclipse project this is where we store it distribDir = new File(userDir.getParentFile(), baseNameForDistrib); } else { distribDir = new File(userDir, baseNameForDistrib); } System.out.println("userDir=" + userDir); //$NON-NLS-1$ System.out.println("distribDir=" + distribDir); //$NON-NLS-1$ commandArgs.baseDir = distribDir.isDirectory() ? distribDir : userDir; } if (!commandArgs.baseDir.isDirectory()) { GuiUtil.errorMessage(null, "baseDir is not a directory: " + commandArgs.baseDir); //$NON-NLS-1$ System.exit(1); } File libDir = new File(commandArgs.baseDir, "lib"); //$NON-NLS-1$ File[] libFiles = libDir.listFiles(); if (libFiles == null) { MsgBox.error(null, Msg.MSG_APP_START_DIRECTORY(kdxploreName, commandArgs.baseDir), Msg.ERRTITLE_MISSING_LIBRARY_FILES() + ": " + libDir.getPath()); System.exit(1); } else if (libFiles.length < REQD_LIB_COUNT) { MsgBox.error(null, Msg.MSG_APP_START_DIRECTORY(kdxploreName, commandArgs.baseDir), Msg.ERRTITLE_MISSING_LIBRARY_FILES() + ": " + libFiles.length); System.exit(1); } // = = = = = = = = = = = = = = = = = = = // = = = = = = = = = = = = = = = = = = = // = = = = = = = CLASSPATH = = = = = = = ClassPathExtender.VERBOSE = !commandArgs.quiet; // RunMode.getRunMode().isDeveloper(); String libs_sb = "lib,plugins,kdxlibs,../runlibs"; //$NON-NLS-1$ boolean[] seenPdfbox = new boolean[1]; Consumer<File> jarChecker = new Consumer<File>() { @Override public void accept(File f) { if (f.getName().startsWith("pdfbox")) { seenPdfbox[0] = true; } } }; ClassPathExtender.appendToClassPath(commandArgs.baseDir, libs_sb, jarChecker, log); if (seenPdfbox[0]) { System.setProperty("sun.java2d.cmm", "sun.java2d.cmm.kcms.KcmsServiceProvider"); } // = = = = = = = = = = = = = = = = = = = // = = = = = = = = = = = = = = = = = = = // = = = = = = = = = = = = = = = = = = = doStaticInitChecks(commandArgs.quiet); if (commandArgs.runInitChecks) { System.out.println("Init checks OK"); //$NON-NLS-1$ System.exit(0); } establishLogger(appFolder); @SuppressWarnings("unused") String configName = commandArgs.establishKdxConfig(); Long versionSubinfo = null; if (commandArgs.errmsg == null) { if (!KdxploreConfig.getInstance().isEternal()) { commandArgs.expiryChecks(KdxConstants.VERSION); versionSubinfo = KdxConstants.getVersionSubinfo(); if (versionSubinfo == Long.MAX_VALUE) { versionSubinfo = null; } } } String baseTitle = appFolder.getApplicationName() + " v" + KdxConstants.VERSION; //$NON-NLS-1$ String expiresIn = ""; //$NON-NLS-1$ if (versionSubinfo != null) { if ((0 < versionSubinfo && versionSubinfo < 14) || RunMode.getRunMode().isDeveloper()) { expiresIn = " " + Msg.KDX_EXPIRES_IN_N_DAYS(versionSubinfo.intValue()); //$NON-NLS-1$ } } if (commandArgs.errmsg != null) { JOptionPane.showMessageDialog(null, commandArgs.errmsg, baseTitle + expiresIn, JOptionPane.ERROR_MESSAGE); System.exit(1); } final String kdxploreTitle = buildKdxploreTitle(baseTitle, expiresIn, commandArgs.kdxConfigService.getConfigName()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { // TODO allow user to change "base font size" String uiMultiplier = null; try { String propertyName = CommandArgs.UI_MULTIPLIER_PROPERTY_NAME; uiMultiplier = System.getProperty(propertyName); if (uiMultiplier != null) { try { float multiplier = Float.parseFloat(uiMultiplier); setUIfontSize(multiplier); } catch (NumberFormatException e) { System.err.println(String.format("?invalid value for %s: %s", //$NON-NLS-1$ propertyName, uiMultiplier)); } } } catch (SecurityException e) { System.err.println(String.format("Ignoring: %s %s", //$NON-NLS-1$ e.getClass().getSimpleName(), e.getMessage())); } GuiUtil.initLookAndFeel(); try { KDXploreFrame frame = new KDXploreFrame(appFolder, kdxploreTitle, KdxConstants.VERSION_CODE, KdxConstants.VERSION, updateChecker); frame.setVisible(true); if (onCreateCallback != null) { onCreateCallback.execute(frame); } } catch (IOException e) { MsgBox.error(null, e, Msg.ERRTITLE_UNABLE_TO_START_KDXPLORE(KDXPLORE_APP_NAME)); } } }); }
From source file:com.ephesoft.dcma.da.common.UpgradePatchPreparation.java
private static String changeDependenciesIdentifierToName(String dependencyNames) { String[] andDependencies = dependencyNames.split(DataAccessConstant.AND); StringBuffer andDependenciesNameAsString = new StringBuffer(); for (String andDependency : andDependencies) { if (!andDependenciesNameAsString.toString().isEmpty()) { andDependenciesNameAsString.append(DataAccessConstant.AND); }//from w ww.ja va 2s. c om String[] orDependencies = andDependency.split(DataAccessConstant.OR_SYMBOL); StringBuffer orDependenciesNameAsString = new StringBuffer(); for (String dependencyIdentifier : orDependencies) { if (!orDependenciesNameAsString.toString().isEmpty()) { orDependenciesNameAsString.append(DataAccessConstant.OR_SYMBOL); } try { long dependencyId = Long.valueOf(dependencyIdentifier); orDependenciesNameAsString .append(pluginService.getPluginPropertiesForPluginId(dependencyId).getPluginName()); } catch (NumberFormatException e) { LOG.error(e.getMessage()); } } andDependenciesNameAsString.append(orDependenciesNameAsString); orDependenciesNameAsString = new StringBuffer(); } return andDependenciesNameAsString.toString(); }
From source file:com.ephesoft.dcma.da.common.UpgradePatchPreparation.java
/** * This method creates patch for modules. * // w w w.j a v a 2 s . c o m * @param batchClassIdentifier {@link String} * @param moduleName {@link String} * @param batchClassService {@link BatchClassService} * @return {@link BatchClassModule} */ private static BatchClassModule createPatchForModule(String batchClassIdentifier, String moduleName, BatchClassService batchClassService) { BatchClassModule createdModule = null; try { BatchClass batchClass = batchClassService.getLoadedBatchClassByIdentifier(batchClassIdentifier); batchClassService.evict(batchClass); List<BatchClassModule> bcms = batchClass.getBatchClassModules(); for (BatchClassModule bcm : bcms) { if (bcm.getModule().getName().equalsIgnoreCase(moduleName)) { createdModule = bcm; break; } } if (createdModule != null) { createdModule.setId(0); createdModule.setBatchClass(null); List<BatchClassPlugin> newBatchClassPluginsList = new ArrayList<BatchClassPlugin>(); for (BatchClassPlugin bcp : createdModule.getBatchClassPlugins()) { preparePluginForSerialization(bcp); newBatchClassPluginsList.add(bcp); } createdModule.setBatchClassPlugins(newBatchClassPluginsList); } } catch (NumberFormatException e) { LOG.error("Module Id should be numeric." + e.getMessage(), e); } return createdModule; }
From source file:controllers.api.v1.Dataset.java
public static Result getPagedDatasets() { ObjectNode result = Json.newObject(); String urn = request().getQueryString("urn"); int page = 1; String pageStr = request().getQueryString("page"); if (StringUtils.isBlank(pageStr)) { page = 1;/*from w w w . j a v a 2 s .c om*/ } else { try { page = Integer.parseInt(pageStr); } catch (NumberFormatException e) { Logger.error("Dataset Controller getPagedDatasets wrong page parameter. Error message: " + e.getMessage()); page = 1; } } int size = 10; String sizeStr = request().getQueryString("size"); if (StringUtils.isBlank(sizeStr)) { size = 10; } else { try { size = Integer.parseInt(sizeStr); } catch (NumberFormatException e) { Logger.error("Dataset Controller getPagedDatasets wrong size parameter. Error message: " + e.getMessage()); size = 10; } } result.put("status", "ok"); String username = session("user"); result.set("data", DatasetsDAO.getPagedDatasets(urn, page, size, username)); return ok(result); }
From source file:com.ephesoft.dcma.da.common.UpgradePatchPreparation.java
/** * This method creates patch for batch class. * //from w w w.jav a 2 s . c om * @param batchClassIdentifier {@link String} * @param batchClassService {@link BatchClassService} * @return {@link BatchClass} */ private static BatchClass createPatchForBatchClass(String batchClassIdentifier, BatchClassService batchClassService) { BatchClass createdBatchClass = null; BatchClassModule createdBatchClassModule = null; List<BatchClassModule> batchClassModules = new ArrayList<BatchClassModule>(); try { BatchClass batchClass = batchClassService.getLoadedBatchClassByIdentifier(batchClassIdentifier); batchClassService.evict(batchClass); // preparing to copy batch class modules.. List<BatchClassModule> bcms = batchClass.getBatchClassModules(); for (BatchClassModule bcm : bcms) { String moduleName = bcm.getModule().getName(); if (moduleName != null) { createdBatchClassModule = createPatchForModule(batchClassIdentifier, moduleName, batchClassService); if (createdBatchClassModule != null) { List<BatchClassPlugin> newBatchClassPluginsList = new ArrayList<BatchClassPlugin>(); for (BatchClassPlugin bcp : createdBatchClassModule.getBatchClassPlugins()) { preparePluginForSerialization(bcp); newBatchClassPluginsList.add(bcp); } createdBatchClassModule.setBatchClassPlugins(newBatchClassPluginsList); batchClassModules.add(createdBatchClassModule); } } } // preparing to copy document types.. List<DocumentType> documentTypes = batchClass.getDocumentTypes(); List<DocumentType> newDocumentType = new ArrayList<DocumentType>(); for (DocumentType documentType : documentTypes) { newDocumentType.add(documentType); documentType.setId(0); documentType.setBatchClass(null); documentType.setIdentifier(null); preparePageTypeForSerialization(documentType); prepareFieldTypeForSerialization(documentType); prepareTableInfoForSerialization(documentType); prepareFunctionKeyForSerialization(documentType); } batchClass.setDocumentTypes(newDocumentType); createdBatchClass = batchClass; if (createdBatchClass != null) { prepareBatchClassForSerialization(createdBatchClass, batchClassModules, newDocumentType); } } catch (NumberFormatException e) { LOG.error("Module Id should be numeric." + e.getMessage(), e); } return createdBatchClass; }
From source file:com.ephesoft.dcma.da.common.UpgradePatchPreparation.java
/** * This method is used to create patch./*from w ww . j a v a 2 s . c o m*/ * * @param batchClassIdentifier {@link String} * @param moduleId {@link String} * @param pluginId {@link String} * @param batchClassService {@link BatchClassService} * @return {@link BatchClassPlugin} */ private static BatchClassPlugin createPatch(String batchClassIdentifier, String moduleId, String pluginId, BatchClassService batchClassService) { BatchClassPlugin createdPlugin = null; try { int modId = Integer.parseInt(moduleId); int plgId = Integer.parseInt(pluginId); BatchClass batchClass = batchClassService.getLoadedBatchClassByIdentifier(batchClassIdentifier); batchClassService.evict(batchClass); List<BatchClassModule> mods = batchClass.getBatchClassModules(); List<BatchClassPlugin> plugins = null; boolean pluginFound = false; for (BatchClassModule bcm : mods) { if (bcm.getModule().getId() == modId) { plugins = bcm.getBatchClassPlugins(); for (BatchClassPlugin bcp : plugins) { if (bcp.getPlugin().getId() == plgId) { createdPlugin = bcp; pluginFound = true; break; } } if (pluginFound) { break; } } } // preparing the plugin for addition to batch classes. if (createdPlugin != null) { preparePluginForSerialization(createdPlugin); } } catch (NumberFormatException e) { LOG.error("Module Id and Plugin Id should be numeric." + e.getMessage(), e); } return createdPlugin; }
From source file:controllers.api.v1.Dataset.java
public static Result getPagedDatasetComments(int id) { ObjectNode result = Json.newObject(); String username = session("user"); if (username == null) { username = ""; }/*from w w w. j a va 2 s .c om*/ int page = 1; String pageStr = request().getQueryString("page"); if (StringUtils.isBlank(pageStr)) { page = 1; } else { try { page = Integer.parseInt(pageStr); } catch (NumberFormatException e) { Logger.error("Dataset Controller getPagedDatasetComments wrong page parameter. Error message: " + e.getMessage()); page = 1; } } int size = 10; String sizeStr = request().getQueryString("size"); if (StringUtils.isBlank(sizeStr)) { size = 10; } else { try { size = Integer.parseInt(sizeStr); } catch (NumberFormatException e) { Logger.error("Dataset Controller getPagedDatasetComments wrong size parameter. Error message: " + e.getMessage()); size = 10; } } result.put("status", "ok"); result.set("data", DatasetsDAO.getPagedDatasetComments(username, id, page, size)); return ok(result); }