List of usage examples for java.lang Number intValue
public abstract int intValue();
From source file:org.springmodules.samples.cache.guava.repository.jdbc.JdbcPostRepository.java
@Override public void create(Post post) { Number id = insertPost .executeAndReturnKey(new MapSqlParameterSource().addValue("user_name", post.getUserName()) .addValue("submit_date", post.getSubmitDate()).addValue("content", post.getContent())); post.setId(id.intValue()); }
From source file:nl.edia.sakai.tool.skinmanager.download.SkinDownloadView.java
@SuppressWarnings("unchecked") public void render(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception { String myName = (String) model.get("id"); Number myVersion = (Number) model.get("version"); setHeaders(response, myName);//from w w w .jav a2s .c o m ServletOutputStream myOutputStream = response.getOutputStream(); if (myVersion != null) { skinArchiveService.fetchSkinArchiveData(myName, myVersion.intValue(), myOutputStream); } else { skinArchiveService.fetchSkinArchiveData(myName, myOutputStream); } }
From source file:litmus.unit.validation.FieldValidationAssert.java
public FieldValidationAssert<T> mustNotBeLessThan(Number minNumber) { return checkBoundary(Integer.toString(minNumber.intValue() - 1), MIN); }
From source file:io.selendroid.client.SelendroidDriver.java
/** * {@inheritDoc}//ww w . j av a 2 s . c o m */ @Override public int getBrightness() { Response response = execute("selendroid-getBrightness"); Number value = (Number) response.getValue(); return value.intValue(); }
From source file:name.persistent.behaviours.RemoteDomainSupport.java
private InetSocketAddress pickService(List<Service> services) { int total = 0; List<InetSocketAddress> addresses = new ArrayList<InetSocketAddress>(); for (int i = 0, n = services.size(); i < n; i++) { addresses.add(null);//from w w w.j a va 2 s . c om Service srv = services.get(i); Object url = srv.getPurlServer(); if (url == null) continue; ParsedURI parsed = new ParsedURI(((RDFObject) url).getResource().stringValue()); int port = "https".equalsIgnoreCase(parsed.getScheme()) ? 443 : 80; InetSocketAddress server = resolve(parsed.getAuthority(), port); if (isBlackListed(server) || server.isUnresolved()) continue; addresses.set(i, server); Number weight = srv.getPurlWeight(); total += weight == null ? 1 : weight.intValue(); } total = random(total); for (int i = 0, n = services.size(); i < n; i++) { Service srv = services.get(i); if (addresses.get(i) == null) continue; Number weight = srv.getPurlWeight(); total -= weight == null ? 1 : weight.intValue(); if (total < 0) { return addresses.get(i); } } return null; }
From source file:com.intel.stl.ui.main.view.HealthHistoryView.java
public void setDataset(final IntervalXYDataset dataset) { JFreeChart chart = ComponentFactory.createStepAreaChart(dataset, new XYItemLabelGenerator() { @Override// w w w.j a v a2s . com public String generateLabel(XYDataset dataset, int series, int item) { Number val = dataset.getY(series, item); return UIConstants.INTEGER.format(val.intValue()); } }); chart.addProgressListener(new ChartProgressListener() { @Override public void chartProgress(ChartProgressEvent event) { if (event.getType() == ChartProgressEvent.DRAWING_STARTED && currentValue != null) { currentValue.setText(scoreString); currentValue.setPaint(scoreColor); currentValue.setToolTipText(scoreTip); } } }); XYPlot plot = chart.getXYPlot(); plot.getRangeAxis().setRange(0, 105); plot.getRenderer().setSeriesPaint(0, UIConstants.INTEL_BLUE); currentValue = new TextTitle(scoreString, scoreFont); currentValue.setPaint(scoreColor); currentValue.setToolTipText(scoreTip); // currentValue.setBackgroundPaint(new Color(255, 255, 255, 128)); currentValue.setPosition(RectangleEdge.BOTTOM); XYTitleAnnotation xytitleannotation = new XYTitleAnnotation(0.49999999999999998D, 0.49999999999999998D, currentValue, RectangleAnchor.CENTER); // xytitleannotation.setMaxWidth(0.47999999999999998D); plot.addAnnotation(xytitleannotation); chartPanel.setChart(chart); }
From source file:moe.yuna.palinuridae.core.BaseDao.java
/** * @param columnValuePair//w w w.j a v a 2 s . co m * @param tableName * @return * @throws DBUtilException */ public Object save(Map<String, Object> columnValuePair, String tableName) throws DBUtilException { try { final List<Object> paras = new ArrayList<>(); final String sql = getDialect().insert(tableName, columnValuePair, paras); log.debug("insert sql:" + sql); int id = 0; KeyHolder keyHolder = new GeneratedKeyHolder(); getJdbcTemplate().update((PrepareStatementCreator) (conn) -> { PreparedStatement stat = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); for (int i = 0, size = paras.size(); i < size; i++) { stat.setObject(i + 1, paras.get(i)); } return stat; }, keyHolder); Number key = keyHolder.getKey(); id = key != null ? key.intValue() : 0; return id; } catch (DataAccessException ex) { throw new DBUtilException(ex); } }
From source file:org.dataone.proto.trove.mn.rest.v1.ExceptionController.java
@RequestMapping(value = "/{errorId}", method = RequestMethod.GET) public void get(HttpServletRequest request, HttpServletResponse response, @PathVariable String errorId) throws NotFound, ServiceFailure, NotImplemented, InvalidRequest, InvalidCredentials, NotAuthorized, AuthenticationTimeout, InsufficientResources { int status = 500; log.info("received error of " + errorId); NumberFormat nf = NumberFormat.getInstance(); nf.setParseIntegerOnly(true);/*ww w .j ava 2s. c o m*/ try { Number nstatus = nf.parse(errorId); status = nstatus.intValue(); } catch (ParseException ex) { throw new ServiceFailure("500", "Could not determine the server error thrown"); } response.setStatus(status); switch (status) { case 400: { throw new InvalidRequest("400", "Bad Request: The request could not be understood by the server due to malformed syntax."); } case 401: { throw new InvalidCredentials("401", "Unauthorized: The request requires user authentication."); } case 403: { throw new NotAuthorized("403", "Forbidden: The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated."); } case 404: { throw new NotFound("404", "Not Found: The server has not found anything matching the Request-URI."); } case 405: { throw new InvalidRequest("405", "Method Not Allowed: The method specified in the Request-Line is not allowed for the resource identified by the Request-URI."); } case 406: { throw new InvalidRequest("406", "Not Acceptable: The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request."); } case 407: { throw new NotAuthorized("407", "Proxy Authentication Required: The client must first authenticate itself with the proxy."); } case 408: { throw new AuthenticationTimeout("408", "Request Timeout: The client did not produce a request within the time that the server was prepared to wait."); } case 409: { throw new InvalidRequest("409", "Conflict: The request could not be completed due to a conflict with the current state of the resource."); } case 410: { throw new NotFound("410", "Gone: The requested resource is no longer available at the server and no forwarding address is known."); } case 411: { throw new InvalidRequest("411", "Length Required: The server refuses to accept the request without a defined Content-Length."); } case 412: { throw new InvalidRequest("412", "Precondition Failed: The precondition given in one or more of the request-header fields evaluated to false when it was tested on the server."); } case 413: { throw new InsufficientResources("413", "Request Entity Too Large: The server is refusing to process a request because the request entity is larger than the server is willing or able to process."); } case 414: { throw new InvalidRequest("414", "Request-URI Too Long: The server is refusing to service the request because the Request-URI is longer than the server is willing to interpret."); } case 415: { throw new InvalidRequest("415", "Unsupported Media Type: The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method."); } case 416: { throw new InvalidRequest("416", "Requested Range Not Satisfiable: A server SHOULD return a response with this status code if a request included a Range request-header field."); } case 417: { throw new InvalidRequest("417", "Expectation Failed: The expectation given in an Expect request-header field could not be met by this server."); } case 500: { throw new ServiceFailure("500", "Internal Server Error: The server encountered an unexpected condition which prevented it from fulfilling the request."); } case 501: { throw new NotImplemented("501", "Not Implemented: The server does not support the functionality required to fulfill the request."); } case 502: { throw new ServiceFailure("502", "Bad Gateway: The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request."); } case 503: { throw new ServiceFailure("503", "Service Unavailable: The server is currently unable to handle the request due to a temporary overloading or maintenance of the server."); } case 504: { throw new ServiceFailure("504", "Gateway Timeout: The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URI (e.g. HTTP, FTP, LDAP) or some other auxiliary server (e.g. DNS) it needed to access in attempting to complete the request."); } case 505: { throw new ServiceFailure("505", "HTTP Version Not Supported: The server does not support, or refuses to support, the HTTP protocol version that was used in the request message."); } default: { throw new ServiceFailure("500", "Could not determine the server error thrown"); } } // this.writeToResponse(errorXml.getInputStream(), response.getOutputStream()); }
From source file:de.hs.mannheim.modUro.controller.diagram.ModeltypeDiagramController.java
public void init(ModelType modeltype) { this.modeltypeDiagram = new ModeltypeDiagram(modeltype); if (leftLastSelectedIndex == null || rightLastSelectedIndex == null) { initializeChoiceboxContent();/*from w w w .j a v a 2 s . c om*/ } else { if (simulationContainsMetricType()) { setChoiceBoxContent(); setLeftChartContent(modeltypeDiagram.getMetricTypeNames().get(leftLastSelectedIndex)); setRightChartContent(modeltypeDiagram.getMetricTypeNames().get(rightLastSelectedIndex)); } else { Alert alert = new Alert(Alert.AlertType.WARNING); alert.setTitle("Warning"); alert.setHeaderText("Metrictype Warning"); alert.setContentText("Simulation does not have Metrictype: " + leftLastSelectedMetrictypename); alert.showAndWait(); initializeChoiceboxContent(); } } /*ChangeListerners for selected items in choicebox.*/ leftMetricType.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { setLeftChartContent(modeltypeDiagram.getMetricTypeNames().get(newValue.intValue())); leftLastSelectedIndex = newValue.intValue(); leftLastSelectedMetrictypename = modeltypeDiagram.getMetricTypeNames().get(leftLastSelectedIndex); } }); rightMetricType.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { setRightChartContent(modeltypeDiagram.getMetricTypeNames().get(newValue.intValue())); rightLastSelectedIndex = newValue.intValue(); rightLastSelectedMetrictypename = modeltypeDiagram.getMetricTypeNames().get(rightLastSelectedIndex); } }); }
From source file:MutableInt.java
/** * Adds a value.// w ww . j ava 2 s . c o m * * @param operand * the value to add * @throws NullPointerException * if the object is null * * @since Commons Lang 2.2 */ public void add(Number operand) { this.value += operand.intValue(); }