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:de.sub.goobi.metadaten.copier.MetadataPathSelector.java

/**
 * Creates a new MetadataPathSelector.//from ww  w  . j  a  v  a  2 s  .  c om
 *
 * @param path
 *            path to create sub-selector, passed to {
 *            {@link #create(String)}.
 * @throws ConfigurationException
 *             if the path is invalid
 */

public MetadataPathSelector(String path) throws ConfigurationException {
    String pathSegment = matchCurrentPathSegment(path);
    Matcher pathSelectorHasElementSelector = SEGMENT_WITH_ELEMENT_SELELCTOR_SCHEME.matcher(pathSegment);
    if (pathSelectorHasElementSelector.matches()) {
        docStructType = pathSelectorHasElementSelector.group(1);
        String indexSymbol = pathSelectorHasElementSelector.group(2);
        try {
            index = getIndexValue(indexSymbol);
            if (index instanceof Integer && ((Integer) index).intValue() < 0) {
                throw new ConfigurationException("Negative element count is not allowed, in path: " + path);
            }
        } catch (NumberFormatException e) {
            throw new ConfigurationException("Cannot create metadata path selector: " + e.getMessage(), e);
        }
    } else {
        docStructType = pathSegment;
        index = null;
    }
    selector = super.create(path.substring(pathSegment.length() + 1));
}

From source file:com.apigee.sdk.apm.http.impl.client.cache.CachedResponseSuitabilityChecker.java

/**
 * Determine if I can utilize a {@link HttpCacheEntry} to respond to the
 * given {@link HttpRequest}/*from  w  w  w.  j a v  a  2 s  .  c  o  m*/
 * 
 * @param host
 *            {@link HttpHost}
 * @param request
 *            {@link HttpRequest}
 * @param entry
 *            {@link HttpCacheEntry}
 * @return boolean yes/no answer
 */
public boolean canCachedResponseBeUsed(HttpHost host, HttpRequest request, HttpCacheEntry entry, Date now) {
    if (!isFreshEnough(entry, request, now)) {
        log.debug("Cache entry was not fresh enough");
        return false;
    }

    if (!validityStrategy.contentLengthHeaderMatchesActualLength(entry)) {
        log.debug("Cache entry Content-Length and header information do not match");
        return false;
    }

    if (hasUnsupportedConditionalHeaders(request)) {
        log.debug("Request contained conditional headers we don't handle");
        return false;
    }

    if (isConditional(request) && !allConditionalsMatch(request, entry, now)) {
        return false;
    }

    for (Header ccHdr : request.getHeaders(HeaderConstants.CACHE_CONTROL)) {
        for (HeaderElement elt : ccHdr.getElements()) {
            if (HeaderConstants.CACHE_CONTROL_NO_CACHE.equals(elt.getName())) {
                log.debug("Response contained NO CACHE directive, cache was not suitable");
                return false;
            }

            if (HeaderConstants.CACHE_CONTROL_NO_STORE.equals(elt.getName())) {
                log.debug("Response contained NO STORE directive, cache was not suitable");
                return false;
            }

            if (HeaderConstants.CACHE_CONTROL_MAX_AGE.equals(elt.getName())) {
                try {
                    int maxage = Integer.parseInt(elt.getValue());
                    if (validityStrategy.getCurrentAgeSecs(entry, now) > maxage) {
                        log.debug("Response from cache was NOT suitable due to max age");
                        return false;
                    }
                } catch (NumberFormatException ex) {
                    // err conservatively
                    log.debug("Response from cache was malformed: " + ex.getMessage());
                    return false;
                }
            }

            if (HeaderConstants.CACHE_CONTROL_MAX_STALE.equals(elt.getName())) {
                try {
                    int maxstale = Integer.parseInt(elt.getValue());
                    if (validityStrategy.getFreshnessLifetimeSecs(entry) > maxstale) {
                        log.debug("Response from cache was not suitable due to Max stale freshness");
                        return false;
                    }
                } catch (NumberFormatException ex) {
                    // err conservatively
                    log.debug("Response from cache was malformed: " + ex.getMessage());
                    return false;
                }
            }

            if (HeaderConstants.CACHE_CONTROL_MIN_FRESH.equals(elt.getName())) {
                try {
                    long minfresh = Long.parseLong(elt.getValue());
                    if (minfresh < 0L)
                        return false;
                    long age = validityStrategy.getCurrentAgeSecs(entry, now);
                    long freshness = validityStrategy.getFreshnessLifetimeSecs(entry);
                    if (freshness - age < minfresh) {
                        log.debug("Response from cache was not suitable due to min fresh "
                                + "freshness requirement");
                        return false;
                    }
                } catch (NumberFormatException ex) {
                    // err conservatively
                    log.debug("Response from cache was malformed: " + ex.getMessage());
                    return false;
                }
            }
        }
    }

    log.debug("Response from cache was suitable");
    return true;
}

From source file:net.rim.ejde.internal.packaging.RAPCFile.java

/**
 * Get the resource id for the given project. We look this up given the resource title key that has been chosen. We used to
 * store the id number but problems occur if people update their resources outside of the resource editor (which preserves the
 * id numbers)./*  w ww .  j  av  a2 s .  c o  m*/
 *
 * @throws CoreException
 */
private int getTitleResourceId(BlackBerryProperties properties) throws CoreException {
    String key = properties._resources.getTitleResourceBundleKey();
    Map<String, RRHFile> resourceMap = ProjectUtils.getProjectResources(_bbProject);
    RRHFile rrhFile = resourceMap.get(properties._resources.getTitleResourceBundleClassName());
    if (rrhFile == null) {
        String msg = "Could not find key information for "
                + properties._resources.getTitleResourceBundleClassName();
        _log.error(msg);
        throw new CoreException(StatusFactory.createErrorStatus(msg));
    }
    Hashtable<String, String> headerKey2Id = rrhFile.getKeyTalbe();
    if (headerKey2Id == null) {
        String path;
        if (rrhFile.getFile() != null) {
            path = rrhFile.getFile().getLocation().toOSString();
        } else {
            path = properties._resources.getTitleResourceBundleClassName();
        }
        String msg = NLS.bind(Messages.RAPCFIlE_NO_KEY_MSG, path);
        _log.error(msg);
        throw new CoreException(StatusFactory.createErrorStatus(msg));
    }
    String resourceId = headerKey2Id.get(key);
    if (resourceId == null) {
        String msg = NLS.bind(Messages.RAPCFIlE_RESOURCE_KEY_NOT_FOUND_MSG, key);
        _log.error(msg);
        throw new CoreException(StatusFactory.createErrorStatus(msg));
    }
    try {
        return Integer.parseInt(resourceId);
    } catch (NumberFormatException nfe) {
        _log.error(nfe);
        throw new CoreException(StatusFactory.createErrorStatus(nfe.getMessage()));
    }
}

From source file:org.geowebcache.service.wms.WMSService.java

/**
 * Handles a getfeatureinfo request/*from   ww  w  .  j a v  a  2 s.c  o  m*/
 * 
 * @param conv
 */
private void handleGetFeatureInfo(ConveyorTile tile) throws GeoWebCacheException {
    TileLayer tl = tld.getTileLayer(tile.getLayerId());

    if (tl == null) {
        throw new GeoWebCacheException(tile.getLayerId() + " is unknown.");
    }

    String[] keys = { "x", "y", "srs", "info_format", "bbox", "height", "width" };
    Map<String, String> values = ServletUtils.selectedStringsFromMap(tile.servletReq.getParameterMap(),
            tile.servletReq.getCharacterEncoding(), keys);

    // TODO Arent we missing some format stuff here?
    GridSubset gridSubset = tl.getGridSubsetForSRS(SRS.getSRS(values.get("srs")));

    BoundingBox bbox = null;
    try {
        bbox = new BoundingBox(values.get("bbox"));
    } catch (NumberFormatException nfe) {
        log.debug(nfe.getMessage());
    }

    if (bbox == null || !bbox.isSane()) {
        throw new ServiceException(
                "The bounding box parameter (" + values.get("srs") + ") is missing or not sane");
    }

    // long[] tileIndex = gridSubset.closestIndex(bbox);

    MimeType mimeType;
    try {
        mimeType = MimeType.createFromFormat(values.get("info_format"));
    } catch (MimeException me) {
        throw new GeoWebCacheException(
                "The info_format parameter (" + values.get("info_format") + ")is missing or not recognized.");
    }

    if (mimeType != null && !tl.getInfoMimeTypes().contains(mimeType)) {
        throw new GeoWebCacheException(
                "The info_format parameter (" + values.get("info_format") + ") is not supported.");
    }

    ConveyorTile gfiConv = new ConveyorTile(sb, tl.getName(), gridSubset.getName(), null, mimeType,
            tile.getFullParameters(), tile.servletReq, tile.servletResp);
    gfiConv.setTileLayer(tl);

    int x, y;
    try {
        x = Integer.parseInt(values.get("x"));
        y = Integer.parseInt(values.get("y"));
    } catch (NumberFormatException nfe) {
        throw new GeoWebCacheException("The parameters for x and y must both be positive integers.");
    }

    int height, width;
    try {
        height = Integer.parseInt(values.get("height"));
        width = Integer.parseInt(values.get("width"));
    } catch (NumberFormatException nfe) {
        throw new GeoWebCacheException("The parameters for height and width must both be positive integers.");
    }

    Resource data = tl.getFeatureInfo(gfiConv, bbox, height, width, x, y);

    try {
        tile.servletResp.setContentType(mimeType.getMimeType());
        ServletOutputStream outputStream = tile.servletResp.getOutputStream();
        data.transferTo(Channels.newChannel(outputStream));
        outputStream.flush();
    } catch (IOException ioe) {
        tile.servletResp.setStatus(500);
        log.error(ioe.getMessage());
    }

}

From source file:com.mycompany.parcinghtml.ParsingClassPlayers.java

public void downloadSource() throws SQLException {
    //ds = prepareDataSource();
    String sql = "INSERT INTO PLAYERS(NAME,AGE,HEIGHT,WEIGHT,PLAYERNUM,POSITION,PLAYERID) VALUES(?,?,?,?,?,?,?)";
    ArrayList<String> duplicity = new ArrayList<>();
    int playerID = 1;

    for (int i = 2015; i > 2004; i--) {
        Document doc = null;/* w w  w .  ja v a  2 s. c om*/
        try {
            doc = Jsoup.connect("http://www.hcsparta.cz/soupiska.asp?sezona=" + Integer.toString(i)).get();
        } catch (IOException e) {
            System.out.println(e.getMessage());
        }
        if (doc == null) {
            System.out.println("doc is null");
            return;
        }

        Elements posNum;
        Elements elList;
        posNum = doc.getElementsByAttributeValueContaining("class", "soupiska");
        //elList = doc.getElementsByAttributeValueContaining("id", "soupiska");
        for (int j = 0; j < 3; j++) {
            elList = posNum.get(j).getElementsByAttributeValueContaining("id", "soupiska");

            for (Element item : elList) {
                String[] secondName = item.child(2).text().split(" ");
                if (duplicity.contains(item.child(2).text()))
                    continue;
                duplicity.add(item.child(2).text());
                try (Connection conn = ds.getConnection()) {

                    try (PreparedStatement st = conn.prepareStatement(sql)) {
                        st.setString(1, item.child(2).text());
                        String[] age = item.child(4).text().split(" ");
                        st.setInt(2, Integer.parseInt(age[0]));
                        String[] height = item.child(5).text().split(" ");
                        st.setInt(3, Integer.parseInt(height[0]));
                        String[] weight = item.child(6).text().split(" ");
                        st.setInt(4, Integer.parseInt(weight[0]));

                        try {
                            st.setInt(5, Integer.parseInt(item.child(0).text()));
                        } catch (NumberFormatException ex) {
                            st.setInt(5, 0);
                        }
                        st.setInt(6, j);
                        st.setInt(7, playerID);
                        int addedRows = st.executeUpdate();
                        playerID++;
                    }
                } catch (SQLException ex) {
                    throw new SQLException(ex.getMessage(), ex.fillInStackTrace());
                }

            }
        }

    }

}

From source file:de.tudarmstadt.lt.lm.web.servlet.LanguageModelProviderServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    String port = config.getInitParameter("rmiport");
    _host = config.getInitParameter("rmihost");
    if (_host == null || port == null) {
        LOG.warn("rmihost or rmiport parameter not specified. Please specify correct parameters in web.xml:{}.",
                getClass().getSimpleName());
        if (_host == null)
            _host = "localhost";
        if (port == null)
            port = String.valueOf(Registry.REGISTRY_PORT);
    }//from w  ww .ja v  a2 s  .c  o m
    try {
        _port = Integer.parseInt(port);
    } catch (NumberFormatException e) {
        LOG.warn(
                "rmiport option value '{}' could not be parsed: {} {}. Please specify correct parameter in web.xml:{}.",
                port, e, getClass().getSimpleName(), e.getMessage(), getClass().getSimpleName());
        _port = Registry.REGISTRY_PORT;
    }
}

From source file:com.mirantis.cachemod.filter.CacheConfiguration.java

public CacheConfiguration(FilterConfig config) {

    alreadyFilteredKey = ALREADY_FILTERED_KEY + config.getFilterName();

    String fragmentParam = config.getInitParameter("fragment");
    if (fragmentParam != null) {
        if ("no".equalsIgnoreCase(fragmentParam)) {
            fragment = FragmentType.NO;/* w  w  w. j  av a 2 s  .co m*/
        } else if ("yes".equalsIgnoreCase(fragmentParam)) {
            fragment = FragmentType.YES;
        } else if ("auto".equalsIgnoreCase(fragmentParam)) {
            fragment = FragmentType.AUTO;
        } else {
            log.error("CacheFilter: Wrong value '" + fragmentParam
                    + "' for init parameter 'fragment', default is 'auto'.");
        }
    }

    String escapeSessionIdParam = config.getInitParameter("escapeSessionId");
    if (escapeSessionIdParam != null) {
        if ("on".equalsIgnoreCase(escapeSessionIdParam)) {
            escapeSessionId = true;
        } else if ("off".equalsIgnoreCase(escapeSessionIdParam)) {
            escapeSessionId = false;
        } else {
            log.error("CacheFilter: Wrong value '" + escapeSessionIdParam
                    + "' for init parameter 'escapeSessionId', default is 'no'.");
        }
    }

    String escapeMethodsParam = config.getInitParameter("escapeMethods");
    if (escapeMethodsParam != null && escapeMethodsParam.length() > 0) {
        StringTokenizer tokenizer = new StringTokenizer(escapeMethodsParam);
        while (tokenizer.hasMoreTokens()) {
            String token = tokenizer.nextToken().trim();
            if (token != null && token.length() > 0) {
                escapeMethods.add(token.toUpperCase());
            }
        }
    }

    String timeParam = config.getInitParameter("time");
    if (timeParam != null) {
        try {
            time = Integer.parseInt(timeParam);
        } catch (NumberFormatException nfe) {
            log.error("CacheFilter: Unexpected value for the init parameter 'time', default is '60'. Message="
                    + nfe.getMessage());
        }
    }

    String lastModifiedParam = config.getInitParameter("lastModified");
    if (lastModifiedParam != null) {
        if ("on".equalsIgnoreCase(lastModifiedParam)) {
            lastModified = LastModifiedType.ON;
        } else if ("off".equalsIgnoreCase(lastModifiedParam)) {
            lastModified = LastModifiedType.OFF;
        } else if ("initial".equalsIgnoreCase(lastModifiedParam)) {
            lastModified = LastModifiedType.INITIAL;
        } else {
            log.error(
                    "CacheFilter: Invalid parameter 'lastModified'. Expected 'on', 'off' or 'initial'. Be default is 'initial'.");
        }
    }

    String expiresParam = config.getInitParameter("expires");
    if (expiresParam != null) {
        if ("on".equalsIgnoreCase(expiresParam)) {
            expires = ExpiresType.ON;
        } else if ("off".equalsIgnoreCase(expiresParam)) {
            expires = ExpiresType.OFF;
        } else if ("time".equalsIgnoreCase(expiresParam)) {
            expires = ExpiresType.TIME;
        } else {
            log.error(
                    "CacheFilter: Invalid parameter 'expires'. Expected 'on', 'off' or 'time'. Be default is 'on'.");
        }
    }

    String maxAgeParam = config.getInitParameter("max-age");
    if (maxAgeParam != null) {
        if (maxAgeParam.equalsIgnoreCase("no init")) {
            maxAgeType = MaxAgeType.NO_INIT;
        } else if (maxAgeParam.equalsIgnoreCase("time")) {
            maxAgeType = MaxAgeType.TIME;
        } else {
            try {
                maxAgeType = MaxAgeType.NUMBER;
                maxAge = Long.parseLong(maxAgeParam);
                if (maxAge < 0) {
                    log.error(
                            "CacheFilter: 'max-age' parameter must be at least a positive integer, default is '60'.");
                    maxAge = 60;
                }
            } catch (NumberFormatException nfe) {
                log.error(
                        "CacheFilter: Unexpected value for the init parameter 'max-age', default is '60'. Message="
                                + nfe.getMessage());
            }
        }
    }

    CacheProvider cacheProviderParam = (CacheProvider) initClass(config, "CacheProvider", CacheProvider.class);
    if (cacheProviderParam != null) {
        this.cacheProvider = cacheProviderParam;
    } else {
        this.cacheProvider = new LRUCacheProvider();
    }

    KeyProvider cacheKeyProviderParam = (KeyProvider) initClass(config, "KeyProvider", KeyProvider.class);
    if (cacheKeyProviderParam != null) {
        this.cacheKeyProvider = cacheKeyProviderParam;
    } else {
        this.cacheKeyProvider = new HashedKeyProvider();
    }

    UserDataProvider userDataProviderParam = (UserDataProvider) initClass(config, "UserDataProvider",
            UserDataProvider.class);
    if (userDataProviderParam != null) {
        this.userDataProvider = userDataProviderParam;
    }

    this.cacheName = config.getInitParameter("cacheName");
    if (cacheName == null) {
        this.cacheName = DEF_CACHE_NAME;
    }

}

From source file:edu.umd.cs.submitServer.MultipartRequest.java

/**
 * @param string/*from w w  w .  jav a2  s  .  c  o m*/
 *            name of the parameter
 * @return
 */
public int getIntParameter(String key) throws InvalidRequiredParameterException {
    try {
        String value = getStringParameter(key);
        return Integer.parseInt(value);
    } catch (NumberFormatException e) {
        throw new InvalidRequiredParameterException(e.getMessage());
    }
}

From source file:edu.umd.cs.submitServer.MultipartRequest.java

/**
 * @param string/*from ww  w.  jav  a  2s  . c  o m*/
 * @return
 */
public long getLongParameter(String key) throws InvalidRequiredParameterException {
    try {
        String value = getStringParameter(key);
        return Long.parseLong(value);
    } catch (NumberFormatException e) {
        throw new InvalidRequiredParameterException(e.getMessage());
    }
}

From source file:ch.cyberduck.core.Profile.java

@Override
public int getDefaultPort() {
    final String v = this.value("Default Port");
    if (StringUtils.isBlank(v)) {
        return parent.getDefaultPort();
    }// ww  w.j  a v  a 2 s  .co m
    try {
        return Integer.valueOf(v);
    } catch (NumberFormatException e) {
        log.warn(String.format("Port %s is not a number", e.getMessage()));
    }
    return parent.getDefaultPort();
}