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.opera.core.systems.OperaDriver.java

/**
 * Make a new settings object, automatically finding the Opera and launcher
 * binaries.//from w w  w. ja v a  2s.  c om
 *
 * @return A new settings object that is correctly set up.
 */
private static OperaDriverSettings makeSettings(Capabilities caps) {
    OperaDriverSettings settings = new OperaDriverSettings();

    OperaPaths paths = new OperaPaths();

    settings.setOperaBinaryLocation(paths.operaPath());
    settings.setOperaLauncherBinary(paths.launcherPath());

    settings.setOperaBinaryArguments("");

    if (caps != null && caps.getCapability("opera.display") != null) {
        try {
            int x = Integer.parseInt(caps.getCapability("opera.display").toString());
            settings.setOperaLauncherXvfbDisplay(x);
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException(
                    caps.getCapability("opera.display") + " is not a valid display." + e.getMessage());
        }
    }
    return settings;
}

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

@Override
public boolean validateParams(Object[] vals) {
    if (vals.length == 1) {
        try {/*from   ww  w. java  2s .  co  m*/
            Integer.parseInt((String) vals[0]);
            return true;
        } catch (NumberFormatException e) {
            LOGGER.log(Level.SEVERE, e.getMessage(), e);
            return false;
        }
    } else
        return false;
}

From source file:fr.paris.lutece.portal.web.upload.UploadFilter.java

/**
 * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
 * @param config//from w w  w  .  j  a  v  a2 s  .  c om
 *            The FilterConfig
 * @throws ServletException
 *             The ServletException
 */
@Override
public void init(FilterConfig config) throws ServletException {
    _filterConfig = config;

    try {
        String paramValue = _filterConfig.getInitParameter(SIZE_THRESHOLD);

        if (paramValue != null) {
            _nSizeThreshold = Integer.parseInt(paramValue);
        }

        paramValue = _filterConfig.getInitParameter(REQUEST_SIZE_MAX);

        if (paramValue != null) {
            _nRequestSizeMax = Long.parseLong(paramValue);
        }

        paramValue = _filterConfig.getInitParameter(ACTIVATE_NORMALIZE_FILE_NAME);

        if (paramValue != null) {
            _bActivateNormalizeFileName = Boolean.valueOf(paramValue);
        }
    } catch (NumberFormatException ex) {
        AppLogService.error(ex.getMessage(), ex);
        throw new ServletException(ex.getMessage(), ex);
    }
}

From source file:eu.crisis_economics.abm.model.parameters.FromFileTimeseriesParameter.java

/**
  * Create a {@link FromFileTimeseriesParameter} object using the specified
  * file.<br><br>//from  w w  w  .j  a  v  a2 s  .  c  om
  * 
  * See also {@link FromFileTimeseriesParameter} and {@link Parameter}.
  * 
  * @param filename
  *        The name of the file from which to read timeseries data.
  * @param parameterName
  *        The name of the resulting {@link Parameter}. It is acceptable
  *        for this argument to be the empty string.
  * @param interpolator
  *        An instance of a {@link UnivariateInterpolator}. This interpolator
  *        is used to convert timeseries keypoints into a queryable function
  *        {@code f(T)} for all {@code T} in the domain of the interpolation
  *        keys. Possible examples, among others, include the {@link SplineInterpolator}
  *        and the {@link LinearInterpolator}.
  * 
  * @throws IOException
  *         This method raises {@link IOException} if, for any reason, the stated
  *         file cannot be processed. Reasons for such failure include: (a) the
  *         file does not exist; (b) the file is inaccessible to the read stream;
  *         (c) the file does not contain any data or contains fewer than two 
  *         records; (d) the file exists and can be accessed but does not have
  *         the required format. See {@link FromFileTimeseriesParameter}.
  */
@Inject
public FromFileTimeseriesParameter(@Named("FROM_FILE_TIMESERIES_PARAMETER_FILENAME") final String filename,
        @Named("FROM_FILE_TIMESERIES_PARAMETER_NAME") final String parameterName,
        @Named("FROM_FILE_TIMESERIES_PARAMETER_INTERPOLATOR") final UnivariateInterpolator interpolator)
        throws IOException {
    super(parameterName);
    Preconditions.checkNotNull(filename);
    final BufferedReader reader = new BufferedReader(new FileReader(filename));
    String line = null;
    final List<Double> x = new ArrayList<Double>(), y = new ArrayList<Double>();
    int numInterpolationPoints = 0;
    try {
        while ((line = reader.readLine()) != null) {
            if (line.isEmpty())
                continue;
            final String[] entries = line.split("[\\s:;,\t]+");
            if (entries.length != 2)
                throw new IOException(getClass().getSimpleName() + ": serialized timeseries are expected to "
                        + "consist of exactly two data columns. The input data: " + entries + " does "
                        + "not conform to this template. The data in file " + filename + " could not "
                        + "be parsed.");
            x.add(Double.parseDouble(entries[0]));
            y.add(Double.parseDouble(entries[1]));
            ++numInterpolationPoints;
        }
    } catch (final NumberFormatException e) {
        throw new IOException(e.getMessage());
    } finally {
        reader.close();
    }

    if (numInterpolationPoints <= 1)
        throw new IllegalArgumentException(getClass().getSimpleName() + ": file " + filename
                + " exists and has valid format,"
                + " but contains fewer than 2 records. At least two interpolation points are required.");
    final UnivariateFunction function = interpolator.interpolate(ArrayUtil.toPrimitive(x),
            ArrayUtil.toPrimitive(y));
    this.interpolation = function;
    this.bounds = new SimpleDomainBounds(x.get(0), x.get(x.size() - 1));
    this.outOfRangeEvaluation = new SimpleDomainBounds(y.get(0), y.get(y.size() - 1));
}

From source file:com.sfs.whichdoctor.search.http.AddressVerificationInputHandler.java

/**
 * Process the incoming HttpRequest for search parameters.
 *
 * @param request the request/*from w  ww .  ja  v a  2s .co m*/
 * @param user the user
 *
 * @return the search bean
 */
public final SearchBean process(final HttpServletRequest request, final UserBean user) {

    SearchBean search = addressVerificationSqlHandler.initiate(user);

    AddressVerificationBean searchCriteria = (AddressVerificationBean) search.getSearchCriteria();
    AddressVerificationBean searchConstraints = (AddressVerificationBean) search.getSearchConstraints();

    /* Process search form */
    String strIdentifier = DataFilter.getHtml(request.getParameter("identifier"));
    String strReturnCode = DataFilter.getHtml(request.getParameter("returnCode"));
    String strProcessStatus = DataFilter.getHtml(request.getParameter("processStatus"));

    String strCreatedA = DataFilter.getHtml(request.getParameter("createdA"));
    String strCreatedB = DataFilter.getHtml(request.getParameter("createdB"));

    /* Set identity (identifier/name) requirements */
    if (StringUtils.isNotBlank(strIdentifier)) {
        int identifier = 0;
        try {
            identifier = Integer.parseInt(strIdentifier.trim());
        } catch (NumberFormatException nfe) {
            dataLogger.debug("Error parsing identifier: " + nfe.getMessage());
        }
        if (identifier > 0) {
            searchCriteria.setPersonIdentifier(identifier);
        } else {
            searchCriteria.setPersonName(strIdentifier);
        }
    }

    if (StringUtils.isNotBlank(strReturnCode) && !StringUtils.equalsIgnoreCase(strReturnCode, "Null")) {
        searchCriteria.setReturnCode(strReturnCode);
    }

    if (StringUtils.isNotBlank(strProcessStatus) && !StringUtils.equalsIgnoreCase(strProcessStatus, "Null")) {
        searchCriteria.setProcessStatus(strProcessStatus);
    }

    if (StringUtils.isNotBlank(strCreatedA)) {
        searchCriteria.setCreatedDate(DataFilter.parseDate(strCreatedA, false));
    }
    if (StringUtils.isNotBlank(strCreatedB)) {
        searchConstraints.setCreatedDate(DataFilter.parseDate(strCreatedB, false));

        if (StringUtils.equals(strCreatedB, "+")) {
            /* All dates above Date A requested */
            searchConstraints.setCreatedDate(getMaximumDate());
        }
        if (StringUtils.equals(strCreatedB, "-")) {
            /* Add dates below Date A requested */
            searchConstraints.setCreatedDate(getMinimumDate());
        }
    }

    search.setSearchCriteria(searchCriteria);
    search.setSearchConstraints(searchConstraints);

    return search;
}

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

private boolean read(final ProtocolFactory protocols, final PlistDeserializer bookmark) {
    final String server = bookmark.stringForKey("Server");
    if (null == server) {
        return false;
    }/*from  w ww .  j a  v a2  s.c om*/
    final Host host = new Host(protocols.forScheme(Scheme.ftp), server);
    final String port = bookmark.stringForKey("Port");
    if (StringUtils.isNotBlank(port)) {
        host.setPort(Integer.parseInt(port));
    }
    String path = bookmark.stringForKey("InitialPath");
    if (StringUtils.isNotBlank(path)) {
        host.setDefaultPath(path);
    }
    String name = bookmark.stringForKey("Name");
    if (StringUtils.isNotBlank(name)) {
        host.setNickname(name);
    }
    String user = bookmark.stringForKey("Username");
    if (StringUtils.isNotBlank(user)) {
        host.getCredentials().setUsername(user);
    } else {
        host.getCredentials().setUsername(PreferencesFactory.get().getProperty("connection.login.anon.name"));
    }
    final String mode = bookmark.stringForKey("PreferredFTPDataConnectionType");
    if (StringUtils.isNotBlank(mode)) {
        if ("Passive".equals(mode)) {
            host.setFTPConnectMode(FTPConnectMode.passive);
        }
        if ("Active".equals(mode)) {
            host.setFTPConnectMode(FTPConnectMode.active);
        }
    }
    final String protocol = bookmark.stringForKey("Protocol");
    if (StringUtils.isNotBlank(protocol)) {
        try {
            switch (Integer.parseInt(protocol)) {
            case 0:
                host.setProtocol(protocols.forScheme(Scheme.ftp));
                break;
            case 1:
                host.setProtocol(protocols.forScheme(Scheme.sftp));
                break;
            case 3:
                host.setProtocol(protocols.forScheme(Scheme.s3));
                break;
            case 2:
            case 4:
                if (host.getPort() == Scheme.davs.getPort()) {
                    host.setProtocol(protocols.forScheme(Scheme.davs));
                } else {
                    host.setProtocol(protocols.forScheme(Scheme.dav));
                }
                break;
            }
            // Reset port to default
            host.setPort(-1);
        } catch (NumberFormatException e) {
            log.warn("Unknown protocol:" + e.getMessage());
        }
    }
    this.add(host);
    return true;
}

From source file:fr.paris.lutece.plugins.genericattributes.service.entrytype.AbstractEntryTypeRadioButton.java

/**
 * {@inheritDoc}/*from ww w  . j  a va2 s .c om*/
 */
@Override
public GenericAttributeError getResponseData(Entry entry, HttpServletRequest request,
        List<Response> listResponse, Locale locale) {
    String strIdField = request.getParameter(PREFIX_ATTRIBUTE + entry.getIdEntry());
    int nIdField = -1;
    Field field = null;
    Response response = new Response();
    response.setEntry(entry);

    if (strIdField != null) {
        try {
            nIdField = Integer.parseInt(strIdField);
        } catch (NumberFormatException ne) {
            AppLogService.error(ne.getMessage(), ne);
        }
    }

    if (nIdField != -1) {
        field = GenericAttributesUtils.findFieldByIdInTheList(nIdField, entry.getFields());
    }

    if (field != null) {
        response.setResponseValue(field.getValue());
        response.setField(field);
    }

    listResponse.add(response);

    if (entry.isMandatory()) {
        if ((field == null) || StringUtils.isBlank(field.getValue())) {
            return new MandatoryError(entry, locale);
        }
    }

    return null;
}

From source file:cc.slda.DisplayTopic.java

@SuppressWarnings("unchecked")
public int run(String[] args) throws Exception {
    Options options = new Options();

    options.addOption(Settings.HELP_OPTION, false, "print the help message");
    options.addOption(OptionBuilder.withArgName(Settings.PATH_INDICATOR).hasArg()
            .withDescription("input beta file").create(Settings.INPUT_OPTION));
    options.addOption(OptionBuilder.withArgName(Settings.PATH_INDICATOR).hasArg()
            .withDescription("term index file").create(ParseCorpus.INDEX));
    options.addOption(OptionBuilder.withArgName(Settings.INTEGER_INDICATOR).hasArg()
            .withDescription("display top terms only (default - 10)").create(TOP_DISPLAY_OPTION));

    String betaString = null;//from ww w  .  j a v a2 s .  c o  m
    String indexString = null;
    int topDisplay = TOP_DISPLAY;

    CommandLineParser parser = new GnuParser();
    HelpFormatter formatter = new HelpFormatter();
    try {
        CommandLine line = parser.parse(options, args);

        if (line.hasOption(Settings.HELP_OPTION)) {
            formatter.printHelp(ParseCorpus.class.getName(), options);
            System.exit(0);
        }

        if (line.hasOption(Settings.INPUT_OPTION)) {
            betaString = line.getOptionValue(Settings.INPUT_OPTION);
        } else {
            throw new ParseException("Parsing failed due to " + Settings.INPUT_OPTION + " not initialized...");
        }

        if (line.hasOption(ParseCorpus.INDEX)) {
            indexString = line.getOptionValue(ParseCorpus.INDEX);
        } else {
            throw new ParseException("Parsing failed due to " + ParseCorpus.INDEX + " not initialized...");
        }

        if (line.hasOption(TOP_DISPLAY_OPTION)) {
            topDisplay = Integer.parseInt(line.getOptionValue(TOP_DISPLAY_OPTION));
        }
    } catch (ParseException pe) {
        System.err.println(pe.getMessage());
        formatter.printHelp(ParseCorpus.class.getName(), options);
        System.exit(0);
    } catch (NumberFormatException nfe) {
        System.err.println(nfe.getMessage());
        System.exit(0);
    }

    JobConf conf = new JobConf(DisplayTopic.class);
    FileSystem fs = FileSystem.get(conf);

    Path indexPath = new Path(indexString);
    Preconditions.checkArgument(fs.exists(indexPath) && fs.isFile(indexPath), "Invalid index path...");

    Path betaPath = new Path(betaString);
    Preconditions.checkArgument(fs.exists(betaPath) && fs.isFile(betaPath), "Invalid beta path...");

    SequenceFile.Reader sequenceFileReader = null;
    try {
        IntWritable intWritable = new IntWritable();
        Text text = new Text();
        Map<Integer, String> termIndex = new HashMap<Integer, String>();
        sequenceFileReader = new SequenceFile.Reader(fs, indexPath, conf);
        while (sequenceFileReader.next(intWritable, text)) {
            termIndex.put(intWritable.get(), text.toString());
        }

        PairOfIntFloat pairOfIntFloat = new PairOfIntFloat();
        // HMapIFW hmap = new HMapIFW();
        HMapIDW hmap = new HMapIDW();
        TreeMap<Double, Integer> treeMap = new TreeMap<Double, Integer>();
        sequenceFileReader = new SequenceFile.Reader(fs, betaPath, conf);
        while (sequenceFileReader.next(pairOfIntFloat, hmap)) {
            treeMap.clear();

            System.out.println("==============================");
            System.out.println(
                    "Top ranked " + topDisplay + " terms for Topic " + pairOfIntFloat.getLeftElement());
            System.out.println("==============================");

            Iterator<Integer> itr1 = hmap.keySet().iterator();
            int temp1 = 0;
            while (itr1.hasNext()) {
                temp1 = itr1.next();
                treeMap.put(-hmap.get(temp1), temp1);
                if (treeMap.size() > topDisplay) {
                    treeMap.remove(treeMap.lastKey());
                }
            }

            Iterator<Double> itr2 = treeMap.keySet().iterator();
            double temp2 = 0;
            while (itr2.hasNext()) {
                temp2 = itr2.next();
                if (termIndex.containsKey(treeMap.get(temp2))) {
                    System.out.println(termIndex.get(treeMap.get(temp2)) + "\t\t" + -temp2);
                } else {
                    System.out.println("How embarrassing! Term index not found...");
                }
            }
        }
    } finally {
        IOUtils.closeStream(sequenceFileReader);
    }

    return 0;
}

From source file:cd.go.contrib.elasticagents.marathon.PluginSettings.java

@SuppressWarnings("unused")
public Integer getMaxInstances() {
    try {/*from www. ja  v  a 2  s .  c om*/
        return Integer.valueOf(maxInstances);
    } catch (NumberFormatException e) {
        LOG.warn("getMaxInstances failed: " + e.getMessage(), e);
        return 10;
    }

}

From source file:it.crs4.seal.prq.PrqOptionParser.java

@Override
protected CommandLine parseOptions(Configuration conf, String[] args) throws IOException, ParseException {
    conf.setInt(MinBasesThresholdConfigName, DefaultMinBasesThreshold);
    conf.setBoolean(DropFailedFilterConfigName, DropFailedFilterDefault);
    conf.setBoolean(WarningOnlyIfUnpairedConfigName, WarningOnlyIfUnpairedDefault);
    conf.setInt(NumReadsExpectedConfigName, NumReadsExpectedDefault);

    CommandLine line = super.parseOptions(conf, args);

    /* **** handle deprected properties **** */
    if (conf.get(PrqOptionParser.OLD_INPUT_FORMAT_CONF) != null) {
        throw new ParseException("The property " + PrqOptionParser.OLD_INPUT_FORMAT_CONF
                + " is no longer supported.\n" + "Please use the command line option --input-format instead.");
    }/*from   w  w w  . j  a  v  a2 s. c  o  m*/

    Utils.checkDeprecatedProp(conf, LOG, MinBasesThresholdConfigName_deprecated, MinBasesThresholdConfigName);
    Utils.checkDeprecatedProp(conf, LOG, DropFailedFilterConfigName_deprecated, DropFailedFilterConfigName);
    Utils.checkDeprecatedProp(conf, LOG, WarningOnlyIfUnpairedConfigName_deprecated,
            WarningOnlyIfUnpairedConfigName);

    // Let the deprecated properties override the new ones, unless the new ones have a non-default value.
    // If the new property has a non-default value, it must have been set by the user.
    // If, on the other hand, the deprecated property has a value, it must have been set by the user since
    // we're not setting them here.
    if (conf.get(MinBasesThresholdConfigName_deprecated) != null
            && conf.getInt(MinBasesThresholdConfigName, DefaultMinBasesThreshold) == DefaultMinBasesThreshold) {
        conf.setInt(MinBasesThresholdConfigName,
                conf.getInt(MinBasesThresholdConfigName_deprecated, DefaultMinBasesThreshold));
    }

    if (conf.get(DropFailedFilterConfigName_deprecated) != null && conf.getBoolean(DropFailedFilterConfigName,
            DropFailedFilterDefault) == DropFailedFilterDefault) {
        conf.setBoolean(DropFailedFilterConfigName,
                conf.getBoolean(DropFailedFilterConfigName_deprecated, DropFailedFilterDefault));
    }

    if (conf.get(WarningOnlyIfUnpairedConfigName_deprecated) != null
            && conf.getBoolean(WarningOnlyIfUnpairedConfigName,
                    WarningOnlyIfUnpairedDefault) == WarningOnlyIfUnpairedDefault) {
        conf.setBoolean(WarningOnlyIfUnpairedConfigName,
                conf.getBoolean(WarningOnlyIfUnpairedConfigName_deprecated, WarningOnlyIfUnpairedDefault));
    }

    /* **** end handle deprecated properties **** */

    if (line.hasOption(opt_traditionalIds.getOpt()))
        conf.setBoolean(PairReadsQSeq.PRQ_CONF_TRADITIONAL_IDS, true);

    if (line.hasOption(opt_numReads.getOpt())) {
        int numReads;
        try {
            numReads = Integer.valueOf(line.getOptionValue(opt_numReads.getOpt()));
            if (numReads <= 0)
                throw new ParseException("Number of reads per fragment must be >= 0 (got " + numReads + ")");
            if (numReads > 2) {
                throw new ParseException(
                        "Working with more than two reads per template is not supported at the moment.\n"
                                + "If you're interested in seeing this feature implemented contact the Seal developers.");
            }
        } catch (NumberFormatException e) {
            throw new ParseException(e.getMessage());
        }
        conf.setInt(NumReadsExpectedConfigName, numReads);
    }

    // set number of reduce tasks to use
    conf.set(ClusterUtils.NUM_RED_TASKS_PROPERTY, String.valueOf(getNReduceTasks()));
    return line;
}