Example usage for java.lang NumberFormatException getMessage

List of usage examples for java.lang NumberFormatException getMessage

Introduction

In this page you can find the example usage for java.lang NumberFormatException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.tupilabs.pbs.parser.QstatJobsParser.java

@Override
public List<Job> parse(String text) throws ParseException {
    final List<Job> jobs;
    if (StringUtils.isNotBlank(text)) {
        text = StringUtils.replace(text, "\n\t", "");
        jobs = new LinkedList<Job>();
        String separator = "\n";
        if (text.indexOf("\r\n") > 0) {
            separator = "\r\n";
        }/* w ww  .j  ava 2  s . c  o m*/
        final String[] lines = text.split(separator);
        Job job = null;
        for (final String line : lines) {
            Matcher matcher = PATTERN_JOB.matcher(line);
            if (matcher.matches()) {
                if (job != null) {
                    jobs.add(job);
                }
                job = new Job();
                final String id = matcher.group(1).trim();
                job.setId(id);
            } else if (StringUtils.isNotBlank(line)) {
                String[] temp = Utils.splitFirst(line, CHAR_EQUALS);
                if (temp.length == 2) {
                    final String key = temp[0].trim().toLowerCase();
                    final String value = temp[1].trim();
                    if ("job_name".equalsIgnoreCase(key)) {
                        job.setName(value);
                    } else if ("job_owner".equalsIgnoreCase(key)) {
                        job.setOwner(value);
                    } else if (key.startsWith("resources_used.")) {
                        job.getResourcesUsed().put(key, value);
                    } else if ("job_state".equalsIgnoreCase(key)) {
                        job.setState(value);
                    } else if ("queue".equalsIgnoreCase(key)) {
                        job.setQueue(value);
                    } else if ("server".equalsIgnoreCase(key)) {
                        job.setServer(value);
                    } else if ("checkpoint".equalsIgnoreCase(key)) {
                        job.setCheckpoint(value);
                    } else if ("ctime".equalsIgnoreCase(key)) {
                        job.setCtime(value);
                    } else if ("error_path".equalsIgnoreCase(key)) {
                        job.setErrorPath(value);
                    } else if ("exec_host".equalsIgnoreCase(key)) {
                        job.setExecHost(value);
                    } else if ("exec_port".equalsIgnoreCase(key)) {
                        job.setExecPort(value);
                    } else if ("hold_types".equalsIgnoreCase(key)) {
                        job.setHoldTypes(value);
                    } else if ("join_path".equalsIgnoreCase(key)) {
                        job.setJoinPath(value);
                    } else if ("keep_files".equalsIgnoreCase(key)) {
                        job.setKeepFiles(value);
                    } else if ("mail_points".equalsIgnoreCase(key)) {
                        job.setMailPoints(value);
                    } else if ("mail_users".equalsIgnoreCase(key)) {
                        job.setMailUsers(value);
                    } else if ("mtime".equalsIgnoreCase(key)) {
                        job.setMtime(value);
                    } else if ("output_path".equalsIgnoreCase(key)) {
                        job.setOutputPath(value);
                    } else if ("priority".equalsIgnoreCase(key)) {
                        try {
                            job.setPriority(Integer.parseInt(value));
                        } catch (NumberFormatException nfe) {
                            LOGGER.log(Level.WARNING, "Failed parsing job priority: " + nfe.getMessage(), nfe);
                            job.setPriority(-1);
                        }
                    } else if ("qtime".equalsIgnoreCase(key)) {
                        job.setQtime(value);
                    } else if ("rerunable".equalsIgnoreCase(key)) {
                        job.setRerunable(Boolean.parseBoolean(value));
                    } else if (key.startsWith("resource_list.")) {
                        job.getResourceList().put(key, value);
                    } else if ("session_id".equalsIgnoreCase(key)) {
                        try {
                            job.setSessionId(Integer.parseInt(value));
                        } catch (NumberFormatException nfe) {
                            LOGGER.log(Level.WARNING, "Failed parsing job session id: " + nfe.getMessage(),
                                    nfe);
                            job.setSessionId(-1);
                        }
                    } else if ("substate".equalsIgnoreCase(key)) {
                        try {
                            job.setSubstate(Integer.parseInt(value));
                        } catch (NumberFormatException nfe) {
                            LOGGER.log(Level.WARNING, "Failed parsing job substate: " + nfe.getMessage(), nfe);
                            job.setSubstate(-1);
                        }
                    } else if (key.startsWith("variable_list")) {
                        job.getVariableList().put(key, value);
                    } else if ("etime".equalsIgnoreCase(key)) {
                        job.setEtime(value);
                    } else if ("euser".equalsIgnoreCase(key)) {
                        job.setEuser(value);
                    } else if ("egroup".equalsIgnoreCase(key)) {
                        job.setEgroup(value);
                    } else if ("hashname".equalsIgnoreCase(key)) {
                        job.setHashName(value);
                    } else if ("queue_rank".equalsIgnoreCase(key)) {
                        try {
                            job.setQueueRank(Integer.parseInt(value));
                        } catch (NumberFormatException nfe) {
                            LOGGER.log(Level.WARNING, "Failed parsing job queue rank: " + nfe.getMessage(),
                                    nfe);
                            job.setQueueRank(-1);
                        }
                    } else if ("queue_type".equalsIgnoreCase(key)) {
                        job.setQueueType(value);
                    } else if ("comment".equalsIgnoreCase(key)) {
                        job.setComment(value);
                    } else if ("submit_args".equalsIgnoreCase(key)) {
                        job.setSubmitArgs(value);
                    } else if ("submit_host".equalsIgnoreCase(key)) {
                        job.setSubmitHost(value);
                    } else if ("start_time".equalsIgnoreCase(key)) {
                        job.setStartTime(value);
                    } else if ("start_count".equalsIgnoreCase(key)) {
                        try {
                            job.setStartCount(Integer.parseInt(value));
                        } catch (NumberFormatException nfe) {
                            LOGGER.log(Level.WARNING, "Failed parsing job start count: " + nfe.getMessage(),
                                    nfe);
                            job.setStartCount(-1);
                        }
                    } else if ("fault_tolerant".equalsIgnoreCase(key)) {
                        job.setFaultTolerant(Boolean.parseBoolean(value));
                    } else if ("job_array_id".equalsIgnoreCase(key)) {
                        job.setJobArrayId(Integer.parseInt(value));
                    } else if ("job_radix".equalsIgnoreCase(key)) {
                        try {
                            job.setRadix(Integer.parseInt(value));
                        } catch (NumberFormatException nfe) {
                            LOGGER.log(Level.WARNING, "Failed parsing job radix: " + nfe.getMessage(), nfe);
                            job.setRadix(-1);
                        }
                    } else if ("walltime.remaining".equalsIgnoreCase(key)) {
                        try {
                            job.setWalltimeRemaining(Long.parseLong(value));
                        } catch (NumberFormatException nfe) {
                            LOGGER.log(Level.WARNING,
                                    "Failed parsing job walltime remaining: " + nfe.getMessage(), nfe);
                            job.setWalltimeRemaining(-1L);
                        }
                    }
                }
            }
        }
        if (job != null) {
            jobs.add(job);
        }
        return jobs;
    } else {
        return Collections.emptyList();
    }
}

From source file:org.kuali.mobility.push.service.CXFPushService.java

@GET
@Path("/getUserDetails")
public String getUserDetails(@QueryParam("pushId") final String id) {
    Push push = new Push();
    long pushId = 0;
    try {/*from  w w  w  .j  ava  2s.c o m*/
        pushId = Long.parseLong(id);
    } catch (NumberFormatException nfe) {
        LOG.error("Number Format Exception: " + nfe.getMessage());
    }
    push = pushService.findPushById(pushId);
    String value = "pushJSON('" + JSONSerializer.toJSON(push).toString() + "');";
    return value;
}

From source file:com.cyberway.issue.crawler.postprocessor.LinksScoper.java

/**
 * The CrawlURI has a prerequisite; apply scoping and update
 * Link to CandidateURI in manner analogous to outlink handling. 
 * @param curi CrawlURI with prereq to consider
 *///  www . j  ava2 s  . co m
protected void handlePrerequisite(CrawlURI curi) {
    try {
        // Create prerequisite CandidateURI
        CandidateURI caUri = curi.createCandidateURI(curi.getBaseURI(), (Link) curi.getPrerequisiteUri());
        int prereqPriority = curi.getSchedulingDirective() - 1;
        if (prereqPriority < 0) {
            prereqPriority = 0;
            LOGGER.severe("Unable to promote prerequisite " + caUri + " above " + curi);
        }
        caUri.setSchedulingDirective(prereqPriority);
        caUri.setForceFetch(true);
        if (isInScope(caUri)) {
            // replace link with CandidateURI
            curi.setPrerequisiteUri(caUri);
        } else {
            // prerequisite is out-of-scope; mark CrawlURI as error,
            // preventinting normal S_DEFERRED handling
            curi.setFetchStatus(S_PREREQUISITE_UNSCHEDULABLE_FAILURE);
        }
    } catch (URIException ex) {
        Object[] array = { curi, curi.getPrerequisiteUri() };
        getController().uriErrors.log(Level.INFO, ex.getMessage(), array);
    } catch (NumberFormatException e) {
        // UURI.createUURI will occasionally throw this error.
        Object[] array = { curi, curi.getPrerequisiteUri() };
        getController().uriErrors.log(Level.INFO, e.getMessage(), array);
    }
}

From source file:es.mityc.firmaJava.configuracion.Configuracion.java

/**
 * Invoca el valor de tipo entero y devuelve su valor. Si no encuentra la clave devuelve -1.
 * @param clave Nombre de la clave a comparar
 * @return Valor de la clave.//  w  w w  .ja  va2s. c  o m
 */
public int getInteger(String clave) //    throws NumberFormatException
{
    int number = -1;
    String valor = (String) configuracion.get(clave);
    if ((valor == null || valor.equals(CADENA_VACIA)) && clave != null) {
        try {
            number = Integer.parseInt(valor, 10);
        } catch (NumberFormatException e) {
            log.debug(ERROR_DOS_PUNTOS + clave + e.getMessage());
            //             throw new NumberFormatException (e.getMessage());
        }
    }
    return number;

}

From source file:generic.GenericModelBuilder.java

/**
 * @return//from w  ww .j  ava 2s .  co m
 */
private Pair<List<GenericRow>, String[]> readData() {
    List<ColumnSpec> cols = spec.getColumns();
    StringBuilder report = new StringBuilder();
    try (BufferedReader r = Files.newBufferedReader(new File(spec.getDataSourcePath()).toPath(),
            Charset.forName("UTF-8"))) {
        String header = r.readLine();
        String[] columns = header.split(spec.getDelimiter());
        String line;
        List<GenericRow> result = new ArrayList<>();
        for (int line_i = 0; ((line = r.readLine()) != null); ++line_i) {
            String[] vals = line.split(spec.getDelimiter());
            Object[] data = new Object[spec.getColumns().size()];
            for (int i = 0; i < cols.size(); ++i) {
                try {
                    data[i] = cols.get(i).parse(vals);
                } catch (NumberFormatException e) {
                    log.error("can't parse: " + line_i + " col " + cols.get(i).col, e);
                    report.append(line_i).append("/").append(cols.get(i).col).append(": parsing error: ")
                            .append(e.getMessage()).append('\n');
                    data[i] = null;
                }
            }
            result.add(new GenericRow(data));
        }
        if (report.length() > 0) {
            ErrorDialog.openError(null, "Parsing Errors", "Loading Error",
                    new Status(IStatus.ERROR, "GenericModelBuilder", report.toString()));
        }
        return Pair.make(result, columns);
    } catch (IOException e) {
        ErrorDialog.openError(null, "Error during loading", "Loading Error",
                new Status(IStatus.ERROR, "GenericModelBuilder", e.getMessage(), e));
        log.error("can't parse", e);
    }
    return Pair.make(Collections.<GenericRow>emptyList(), null);
}

From source file:org.psidnell.omnifocus.model.CommonProjectAndTaskAttributes.java

private void extractIcsAttributes(String text) {

    // The config and the note may be set in any order, must do this lazily

    if (text != null && !icsAttribsSet) {
        String[] lines = text.split("\n");
        for (String line : lines) {
            line = line.trim();//from  w ww  . ja  v a2 s. c o m
            if (line.startsWith("%of2")) {
                line = line.substring(4, line.length()).trim();
                String bits[] = line.split(" ");
                if (bits.length == 2) {
                    String command = bits[0];
                    try {
                        switch (command.toLowerCase()) {
                        case "start":
                            icsStart = bits[1].trim();
                            break;
                        case "end":
                            icsEnd = bits[1].trim();
                            break;
                        case "alarm":
                            icsAlarm = Boolean.parseBoolean(bits[1].trim());
                            break;
                        case "allday":
                            icsAllDay = Boolean.parseBoolean(bits[1].trim());
                            break;
                        case "alarmminutes":
                            icsAlarmMinutes = Integer.parseInt(bits[1].trim());
                            break;
                        }
                    } catch (NumberFormatException e) {
                        LOGGER.error(e.getMessage());
                    }
                }
            }
        }
    }
    icsAttribsSet = true;
}

From source file:fr.ens.biologie.genomique.eoulsan.actions.CreateDesignAction.java

@Override
public void action(final List<String> arguments) {

    final Options options = makeOptions();
    final CommandLineParser parser = new GnuParser();
    String filename = "design.txt";
    int argsOptions = 0;
    boolean pairedEndMode = false;
    final List<String> sampleSheetPaths = new ArrayList<>();
    String samplesProjectName = null;
    boolean symlinks = false;
    int formatVersion = DEFAULT_DESIGN_FORMAT;

    try {/*from   w w  w. ja v  a2  s . c  o m*/

        // parse the command line arguments
        final CommandLine line = parser.parse(options, arguments.toArray(new String[arguments.size()]), true);

        // Pair-end option
        if (line.hasOption("paired-end")) {
            pairedEndMode = true;
            argsOptions += 1;
        }

        // Help option
        if (line.hasOption("help")) {
            help(options);
        }

        // Output option
        if (line.hasOption("o")) {

            filename = line.getOptionValue("o");
            argsOptions += 2;
        }

        // Casava design option
        if (line.hasOption("s")) {

            String[] sampleSheets = line.getOptionValues("s");
            sampleSheetPaths.addAll(Arrays.asList(sampleSheets));
            argsOptions += sampleSheets.length * 2;
        }

        // Casava project option
        if (line.hasOption("n")) {

            samplesProjectName = line.getOptionValue("n");
            argsOptions += 2;
        }

        // Symbolic links option
        if (line.hasOption("symlinks")) {

            symlinks = true;
            argsOptions++;
        }

        // Eoulsan design format version option
        if (line.hasOption("f")) {

            try {
                formatVersion = Integer.parseInt(line.getOptionValue("f").trim());
            } catch (NumberFormatException e) {
                Common.errorExit(e, "Invalid Eoulsan design format version: " + e.getMessage());
            }
            argsOptions += 2;
        }

    } catch (ParseException e) {
        Common.errorExit(e, "Error while parsing command line arguments: " + e.getMessage());
    }

    // Write log entries
    Main.getInstance().flushLog();

    Design design = null;
    final DataFile designFile = new DataFile(filename);

    try {

        final List<String> newArgs = arguments.subList(argsOptions, arguments.size());

        final DesignBuilder db = new DesignBuilder();

        // Add all the files of a Casava design if Casava design path is defined
        for (String sampleSheetPath : sampleSheetPaths) {
            db.addBcl2FastqSamplesheetProject(new File(sampleSheetPath), samplesProjectName);
        }

        // Add files in the command line
        db.addFiles(newArgs);

        design = db.getDesign(pairedEndMode);

        if (symlinks) {
            DesignUtils.replaceLocalPathBySymlinks(design, designFile.getParent());
        }

    } catch (EoulsanException | IOException e) {
        Common.errorExit(e, "Error: " + e.getMessage());
    }

    if (design.getSamples().isEmpty()) {
        Common.showErrorMessageAndExit(
                "Error: Nothing to create, no file found.\n" + "  Use the -h option to get more information.\n"
                        + "usage: " + Globals.APP_NAME_LOWER_CASE + " createdesign files");

    }

    try {

        if (designFile.exists()) {
            throw new IOException("Output design file " + designFile + " already exists");
        }

        final DesignWriter dw;

        switch (formatVersion) {

        case 1:
            dw = new Eoulsan1DesignWriter(designFile.create());
            break;

        case 2:
            dw = new Eoulsan2DesignWriter(designFile.create());
            break;

        default:
            Common.showErrorMessageAndExit("Unknown Eoulsan design format version: " + formatVersion);
            return;
        }

        dw.write(design);

    } catch (IOException e) {
        Common.errorExit(e, "File not found: " + e.getMessage());
    }

}

From source file:com.datastax.brisk.BriskTool.java

public BriskTool(String[] args) throws Exception {
    CommandLineParser parser = new PosixParser();
    ToolCommandLine cmd = null;//from   w  w  w.j a  v a  2  s.c o m

    try {
        cmd = new ToolCommandLine(parser.parse(options, args));
    } catch (ParseException p) {
        badUse(p.getMessage());
    }

    String hostParam = cmd.getOptionValue(HOST_OPT.left);
    if (hostParam != null) {
        host = hostParam;
    }

    String portNum = cmd.getOptionValue(PORT_OPT.left);
    if (portNum != null) {
        try {
            port = Integer.parseInt(portNum);
        } catch (NumberFormatException e) {
            throw new ParseException("Port must be a number");
        }
    }

    BriskCommand command = null;

    try {
        command = cmd.getCommand();
    } catch (IllegalArgumentException e) {
        badUse(e.getMessage());
    }

    // Execute the requested command.
    String[] arguments = cmd.getCommandArguments();
    runCommand(command, arguments);

    System.exit(0);
}

From source file:hydrograph.ui.dataviewer.filemanager.DataViewerFileManager.java

/**
 * //w  w w.j a v a  2  s  .c  o  m
 * Download debug file in data viewer workspace
 * @param filterApplied 
 * @param filterConditions 
 * 
 * @return error code
 */
public StatusMessage downloadDataViewerFiles(boolean filterApplied, FilterConditions filterConditions,
        boolean isOverWritten) {

    // Get csv debug file name and location 
    String csvDebugFileAbsolutePath = null;
    String csvDebugFileName = null;
    try {
        if (filterConditions != null) {
            if (!filterConditions.getRetainRemote()) {
                if (!filterApplied) {
                    csvDebugFileAbsolutePath = getDebugFileAbsolutePath();
                } else {
                    csvDebugFileAbsolutePath = getDebugFileAbsolutePath();
                    csvDebugFileName = getFileName(csvDebugFileAbsolutePath);
                    csvDebugFileAbsolutePath = getFilterFileAbsolutePath(filterConditions, csvDebugFileName);
                }
            } else {
                csvDebugFileAbsolutePath = getDebugFileAbsolutePath();
                csvDebugFileName = getFileName(csvDebugFileAbsolutePath);
                csvDebugFileAbsolutePath = getFilterFileAbsolutePath(filterConditions, csvDebugFileName);
            }
        } else {
            csvDebugFileAbsolutePath = getDebugFileAbsolutePath();
        }
    } catch (MalformedURLException malformedURLException) {
        Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, malformedURLException.getMessage(),
                malformedURLException);
        StatusMessage statusMessage = new StatusMessage.Builder(StatusConstants.ERROR,
                Messages.UNABLE_TO_FETCH_DEBUG_FILE
                        + ": either no legal protocol could be found in a specification string or the path could not be parsed.")
                                .errorStatus(status).build();
        logger.error("Unable to fetch viewData file", malformedURLException);
        return statusMessage;
    } catch (HttpException httpException) {
        Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, httpException.getMessage(),
                httpException);
        StatusMessage statusMessage = new StatusMessage.Builder(StatusConstants.ERROR,
                Messages.UNABLE_TO_FETCH_DEBUG_FILE + ": error from Http client").errorStatus(status).build();
        logger.error("Unable to fetch viewData file", httpException);
        return statusMessage;
    } catch (NumberFormatException numberFormateException) {
        Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, numberFormateException.getMessage(),
                numberFormateException);
        StatusMessage statusMessage = new StatusMessage.Builder(StatusConstants.ERROR,
                Messages.UNABLE_TO_FETCH_DEBUG_FILE + ": please check if port number is defined correctly")
                        .errorStatus(status).build();
        logger.error("Unable to fetch viewData file", numberFormateException);
        return statusMessage;
    } catch (IOException ioException) {
        Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, ioException.getMessage(), ioException);
        StatusMessage statusMessage = new StatusMessage.Builder(StatusConstants.ERROR,
                Messages.UNABLE_TO_FETCH_DEBUG_FILE + ": please check if service is running")
                        .errorStatus(status).build();
        logger.error("Unable to fetch viewData file", ioException);
        return statusMessage;
    }
    if (csvDebugFileAbsolutePath != null) {
        csvDebugFileName = csvDebugFileAbsolutePath
                .substring(csvDebugFileAbsolutePath.lastIndexOf("/") + 1, csvDebugFileAbsolutePath.length())
                .replace(DEBUG_DATA_FILE_EXTENTION, "").trim();
    }

    //Copy csv debug file to Data viewers temporary file location
    if (StringUtils.isNotBlank(csvDebugFileName)) {
        String dataViewerDebugFile = getDataViewerDebugFile(csvDebugFileName);

        try {
            if (!filterApplied) {
                copyCSVDebugFileToDataViewerStagingArea(jobDetails, csvDebugFileAbsolutePath,
                        dataViewerDebugFile, isOverWritten);
            } else {
                copyFilteredFileToDataViewerStagingArea(jobDetails, csvDebugFileAbsolutePath,
                        dataViewerDebugFile);
            }
        } catch (IOException | JSchException e1) {
            logger.error("Unable to fetch viewData file", e1);
            return new StatusMessage(StatusConstants.ERROR,
                    Messages.UNABLE_TO_FETCH_DEBUG_FILE + ": unable to copy the files from temporary location");
        }

        File debugFile = new File(dataViewerDebugFile);
        double debugFileSizeInByte = (double) debugFile.length();
        double debugFileSizeKB = (debugFileSizeInByte / 1024);
        debugFileSizeInKB = new BigDecimal(debugFileSizeKB).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();

        // Delete csv debug file after copy
        deleteFileOnRemote(jobDetails, csvDebugFileName);

        // Check for empty csv debug file
        if (isEmptyDebugCSVFile(dataViewerFilePath, dataViewerFileName)) {
            logger.error("Empty viewData file");
            return new StatusMessage(StatusConstants.ERROR, Messages.EMPTY_DEBUG_FILE);
        }
    }
    return new StatusMessage(StatusConstants.SUCCESS);
}

From source file:cn.vlabs.umt.ui.actions.BatchCreateAction.java

public ActionForward changePage(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) {//  www . j  a  va 2  s.  c  om
    HttpSession session = request.getSession();
    Integer total = (Integer) session.getAttribute("batch.total");
    RecordFile records = (RecordFile) session.getAttribute("batch.records");
    if (total == null || records == null) {
        return MessagePage.showMenuMessagePage("batch.datanotfound", request, mapping);
    }

    PageBean bean = new PageBean(total);
    String page = request.getParameter("page");
    try {
        bean.setCurrentPage(Integer.parseInt(page));
    } catch (NumberFormatException e) {
        bean.setCurrentPage(0);
    }

    try {
        bean.setItems(records.load(bean.getCurrentPage()));
        request.setAttribute("PageBean", bean);
        return mapping.findForward("displayusers");
    } catch (IOException e) {
        request.setAttribute("message", e.getMessage());
        return mapping.findForward("displayusers");
    }
}