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:fr.paris.lutece.plugins.genericattributes.service.entrytype.AbstractEntryTypeRadioButton.java

/**
 * {@inheritDoc}/*w  w w  .j a va2  s. c o m*/
 */
@Override
public String getRequestData(Entry entry, HttpServletRequest request, Locale locale) {
    String strTitle = request.getParameter(PARAMETER_TITLE);
    String strCode = request.getParameter(PARAMETER_ENTRY_CODE);
    String strHelpMessage = (request.getParameter(PARAMETER_HELP_MESSAGE) != null)
            ? request.getParameter(PARAMETER_HELP_MESSAGE).trim()
            : null;
    String strComment = request.getParameter(PARAMETER_COMMENT);
    String strMandatory = request.getParameter(PARAMETER_MANDATORY);
    String strFieldInLine = request.getParameter(PARAMETER_FIELD_IN_LINE);
    String strCSSClass = request.getParameter(PARAMETER_CSS_CLASS);
    String strOnlyDisplayInBack = request.getParameter(PARAMETER_ONLY_DISPLAY_IN_BACK);

    int nFieldInLine = -1;

    String strFieldError = StringUtils.EMPTY;

    if (StringUtils.isBlank(strTitle)) {
        strFieldError = FIELD_TITLE;
    }

    if (StringUtils.isNotBlank(strFieldError)) {
        Object[] tabRequiredFields = { I18nService.getLocalizedString(strFieldError, locale) };

        return AdminMessageService.getMessageUrl(request, MESSAGE_MANDATORY_FIELD, tabRequiredFields,
                AdminMessage.TYPE_STOP);
    }

    // for don't update fields listFields=null
    entry.setFields(null);
    entry.setCode(strCode);
    entry.setTitle(strTitle);
    entry.setHelpMessage(strHelpMessage);
    entry.setComment(strComment);
    entry.setCSSClass(strCSSClass);

    entry.setMandatory(strMandatory != null);
    entry.setOnlyDisplayInBack(strOnlyDisplayInBack != null);

    try {
        nFieldInLine = Integer.parseInt(strFieldInLine);
    } catch (NumberFormatException ne) {
        AppLogService.error(ne.getMessage(), ne);
    }

    entry.setFieldInLine(nFieldInLine == 1);

    return null;
}

From source file:com.ephesoft.dcma.core.service.ServerHeartBeatMonitor.java

public boolean getServerActiveStatus(final String ipAddress, final String portNumber, final String context,
        final boolean isSecure) {
    boolean isActive = false;
    String pathURL = getURL(ipAddress, portNumber, context, isSecure);
    isActive = checkHealth(pathURL);/* www  . j  a  v a2s .c  om*/
    if (!isActive) {
        int noOfPings = 1;
        try {
            noOfPings = getNumberOfPings();
        } catch (final NumberFormatException nfe) {
            LOGGER.error(nfe.getMessage());
        }
        for (int index = 1; index < noOfPings; index++) {
            if (checkHealth(pathURL)) {
                break;
            }
        }
    }
    return isActive;
}

From source file:ch.cyberduck.core.importer.WsFtpBookmarkCollection.java

private boolean parse(final ProtocolFactory protocols, final Host current, final String line) {
    final Scanner scanner = new Scanner(line);
    scanner.useDelimiter("=");
    if (!scanner.hasNext()) {
        log.warn("Missing key in line:" + line);
        return false;
    }/*from   w  w w .  j a v  a2  s. co  m*/
    String name = scanner.next().toLowerCase(Locale.ROOT);
    if (!scanner.hasNext()) {
        log.warn("Missing value in line:" + line);
        return false;
    }
    String value = scanner.next().replaceAll("\"", StringUtils.EMPTY);
    if ("conntype".equals(name)) {
        try {
            switch (Integer.parseInt(value)) {
            case 4:
                current.setProtocol(protocols.forScheme(Scheme.sftp));
                break;
            case 5:
                current.setProtocol(protocols.forScheme(Scheme.ftps));
                break;
            }
            // Reset port to default
            current.setPort(-1);
        } catch (NumberFormatException e) {
            log.warn("Unknown Protocol:" + e.getMessage());
        }
    } else if ("host".equals(name)) {
        current.setHostname(value);
    } else if ("port".equals(name)) {
        try {
            current.setPort(Integer.parseInt(value));
        } catch (NumberFormatException e) {
            log.warn("Invalid Port:" + e.getMessage());
        }
    } else if ("dir".equals(name)) {
        current.setDefaultPath(value);
    } else if ("comment".equals(name)) {
        current.setComment(value);
    } else if ("uid".equals(name)) {
        current.getCredentials().setUsername(value);
    }
    return true;
}

From source file:cz.incad.kramerius.security.impl.criteria.MovingWall.java

@Override
public EvaluatingResult evalute() throws RightCriteriumException {
    int wallFromConf = Integer.parseInt((String) getObjects()[0]);
    try {//w  w w  .ja  v a  2s  .c  om
        ObjectPidsPath[] pathsToRoot = getEvaluateContext().getPathsToRoot();
        EvaluatingResult result = null;
        for (ObjectPidsPath pth : pathsToRoot) {
            String[] pids = pth.getPathFromLeafToRoot();
            for (String pid : pids) {

                if (pid.equals(SpecialObjects.REPOSITORY.getPid()))
                    continue;
                Document biblioMods = getEvaluateContext().getFedoraAccess().getBiblioMods(pid);
                // try all xpaths on mods
                for (String xp : MODS_XPATHS) {
                    result = resolveInternal(wallFromConf, pid, xp, biblioMods);
                    if (result != null)
                        break;
                }

                // TRUE or FALSE -> rozhodnul, nevratil NOT_APPLICABLE
                if (result != null
                        && (result.equals(EvaluatingResult.TRUE) || result.equals(EvaluatingResult.FALSE)))
                    return result;
            }
        }

        return result != null ? result : EvaluatingResult.NOT_APPLICABLE;
    } catch (NumberFormatException e) {
        LOGGER.log(Level.SEVERE, e.getMessage());
        return EvaluatingResult.NOT_APPLICABLE;
    } catch (IOException e) {
        LOGGER.log(Level.SEVERE, e.getMessage());
        return EvaluatingResult.NOT_APPLICABLE;
    } catch (XPathExpressionException e) {
        LOGGER.log(Level.SEVERE, e.getMessage());
        return EvaluatingResult.NOT_APPLICABLE;
    }
}

From source file:eu.stratosphere.myriad.driver.MyriadDriverFrontend.java

/**
 * @param args/*from ww  w.  jav a 2s .  c o  m*/
 * @return
 */
private ParsedOptions parseOptions(String[] args) throws ParseException {
    ParsedOptions parsedOptions = new ParsedOptions();

    if (args.length < 1) {
        throw new ParseException("Missing dgen-install-dir argument");
    }

    parsedOptions.setFile("dgen-install-dir", new File(args[0]));

    // parse the command line arguments
    CommandLineParser parser = new PosixParser();
    CommandLine line = parser.parse(this.options, Arrays.copyOfRange(args, 1, args.length));

    if (line.hasOption('x')) {
        parsedOptions.setStringArray("execute-stage", line.getOptionValues('x'));
    } else {
        parsedOptions.setErrorMessage("execute-stage",
                "You should provide at least one data generator stage to be executed");
    }

    try {
        parsedOptions.setFloat("scaling-factor", Float.parseFloat(line.getOptionValue('s', "1.0")));
    } catch (NumberFormatException e) {
        parsedOptions.setErrorMessage("scaling-factor", e.getMessage());
    }

    try {
        parsedOptions.setShort("node-count", Short.parseShort(line.getOptionValue('N', "1")));
    } catch (NumberFormatException e) {
        parsedOptions.setErrorMessage("node-count", e.getMessage());
    }

    parsedOptions.setString("dataset-id", line.getOptionValue('m', "default-dataset"));
    parsedOptions.setFile("output-base", new File(line.getOptionValue('o', "/tmp")));

    return parsedOptions;
}

From source file:ch.cyberduck.core.importer.WinScpBookmarkCollection.java

@Override
protected void parse(final ProtocolFactory protocols, final Local file) throws AccessDeniedException {
    try {/*  ww  w. jav a 2  s.c om*/
        final BufferedReader in = new BufferedReader(
                new InputStreamReader(file.getInputStream(), Charset.forName("UTF-8")));
        try {
            Host current = null;
            String line;
            while ((line = in.readLine()) != null) {
                if (line.startsWith("[Sessions\\")) {
                    current = new Host(protocols.forScheme(Scheme.sftp));
                    current.getCredentials()
                            .setUsername(PreferencesFactory.get().getProperty("connection.login.anon.name"));
                    Pattern pattern = Pattern.compile("\\[Session\\\\(.*)\\]");
                    Matcher matcher = pattern.matcher(line);
                    if (matcher.matches()) {
                        current.setNickname(matcher.group(1));
                    }
                } else if (StringUtils.isBlank(line)) {
                    this.add(current);
                    current = null;
                } else {
                    if (null == current) {
                        log.warn("Failed to detect start of bookmark");
                        continue;
                    }
                    Scanner scanner = new Scanner(line);
                    scanner.useDelimiter("=");
                    if (!scanner.hasNext()) {
                        log.warn("Missing key in line:" + line);
                        continue;
                    }
                    String name = scanner.next().toLowerCase(Locale.ROOT);
                    if (!scanner.hasNext()) {
                        log.warn("Missing value in line:" + line);
                        continue;
                    }
                    String value = scanner.next();
                    if ("hostname".equals(name)) {
                        current.setHostname(value);
                    } else if ("username".equals(name)) {
                        current.getCredentials().setUsername(value);
                    } else if ("portnumber".equals(name)) {
                        try {
                            current.setPort(Integer.parseInt(value));
                        } catch (NumberFormatException e) {
                            log.warn("Invalid Port:" + e.getMessage());
                        }
                    } else if ("fsprotocol".equals(name)) {
                        try {
                            switch (Integer.parseInt(value)) {
                            case 0:
                            case 1:
                            case 2:
                                current.setProtocol(protocols.forScheme(Scheme.sftp));
                                break;
                            case 5:
                                current.setProtocol(protocols.forScheme(Scheme.ftp));
                                break;
                            }
                            // Reset port to default
                            current.setPort(-1);
                        } catch (NumberFormatException e) {
                            log.warn("Unknown Protocol:" + e.getMessage());
                        }
                    }
                }
            }
        } finally {
            IOUtils.closeQuietly(in);
        }
    } catch (IOException e) {
        throw new AccessDeniedException(e.getMessage(), e);
    }
}

From source file:net.di2e.ddf.argo.probe.responder.ProbeResponder.java

public void updateConfiguration(Map<String, Object> properties) {
    LOGGER.debug("{} ProbeResponder updateConfiguration called with properties: {}",
            ArgoConstants.LOG_CONFIG_UPDATE_PREFIX, properties);
    if (properties != null) {
        destroy();/*from  w  w  w  .  ja  va 2s  . c  om*/

        address = (String) properties.get(MULTICAST_ADDRESS);
        Object portValue = properties.get(MULTICAST_PORT);
        if (portValue != null) {
            try {
                port = Integer.parseInt(portValue.toString());
            } catch (NumberFormatException e) {
                LOGGER.warn("Could not set port value because it is not an integer: " + e.getMessage(), e);
            }
        }
        String[] ignoreArray = (String[]) properties.get(IGNORE_PROBES_LIST);
        setIgnoreProbesList(ignoreArray == null ? new ArrayList<String>() : Arrays.asList(ignoreArray));

        try {
            init();
        } catch (IOException e) {
            LOGGER.warn("Could not restart Probe Responder multicast listener: " + e.getMessage(), e);
        }
    }

}

From source file:com.cloudera.oryx.ml.serving.als.Ingest.java

private void doPost(BufferedReader buffered) throws IOException, OryxServingException {
    TopicProducer<?, String> inputTopic = getInputProducer();
    String line;/* w  w  w . ja v  a 2  s  .  c om*/
    while ((line = buffered.readLine()) != null) {
        Iterator<String> tokens = COMMA.split(line).iterator();
        check(tokens.hasNext(), line);
        String userID = tokens.next();
        check(tokens.hasNext(), line);
        String itemID = tokens.next();
        String strength;
        long timestamp;
        // Has a strength?
        if (tokens.hasNext()) {
            String rawStrength = tokens.next();
            // Special case deletes:
            if (rawStrength.isEmpty()) {
                strength = "";
            } else {
                strength = Preference.validateAndStandardizeStrength(rawStrength);
            }
            // Has a timestamp?
            if (tokens.hasNext()) {
                try {
                    timestamp = Long.parseLong(tokens.next());
                } catch (NumberFormatException nfe) {
                    throw new OryxServingException(Response.Status.BAD_REQUEST, nfe.getMessage());
                }
                check(timestamp > 0, line);
            } else {
                timestamp = System.currentTimeMillis();
            }
        } else {
            strength = "1";
            timestamp = System.currentTimeMillis();
        }
        inputTopic.send(userID + "," + itemID + "," + strength + "," + timestamp);
    }
}

From source file:example.Example02.java

@Override
public Response init(ChaincodeStub stub) {
    try {/* w ww  .  java  2s.  c  o m*/
        final String function = stub.getFunction();
        switch (function) {
        case "init":
            return init(stub, stub.getParameters().stream().toArray(String[]::new));
        default:
            return newBadRequestResponse(format("Unknown function: %s", function));
        }
    } catch (NumberFormatException e) {
        return newBadRequestResponse(e.toString());
    } catch (IllegalArgumentException e) {
        return newBadRequestResponse(e.getMessage());
    } catch (Throwable e) {
        return newInternalServerErrorResponse(e);
    }
}

From source file:example.Example02.java

@Override
public Response invoke(ChaincodeStub stub) {

    try {//from  w w w . j  ava 2  s . co  m
        final String function = stub.getFunction();
        final String[] args = stub.getParameters().stream().toArray(String[]::new);

        switch (function) {
        case "invoke":
            return invoke(stub, args);
        case "delete":
            return delete(stub, args);
        case "query":
            return query(stub, args);
        default:
            return newBadRequestResponse(format("Unknown function: %s", function));
        }
    } catch (NumberFormatException e) {
        return newBadRequestResponse(e.toString());
    } catch (IllegalArgumentException e) {
        return newBadRequestResponse(e.getMessage());
    } catch (Throwable e) {
        return newInternalServerErrorResponse(e);
    }

}