List of usage examples for java.lang Number intValue
public abstract int intValue();
From source file:org.datacleaner.widgets.result.ValueDistributionResultSwingRendererGroupDelegate.java
protected int getDataSetValue(int i) { Number value = _dataset.getValue(i, 0); return value.intValue(); }
From source file:io.fabric8.mq.controller.coordination.KubernetesControl.java
private void populateBrokerStatistics(Pod pod, J4pClient client) { ObjectName root = null;//from w ww. j a v a 2 s. c o m String attribute = ""; if (client != null) { try { root = getBrokerJMXRoot(client); attribute = "BrokerName"; Object brokerName = getAttribute(client, root, attribute); attribute = "BrokerId"; Object brokerId = getAttribute(client, root, attribute); attribute = "OpenWireURL"; Object uri = getAttribute(client, root, attribute); BrokerModel brokerModel = model.getBrokerById(brokerId.toString()); if (brokerModel == null) { BrokerView brokerView = new BrokerView(); brokerView.setBrokerName(brokerName.toString()); brokerView.setBrokerId(brokerId.toString()); brokerView.setUri(uri.toString()); brokerModel = new BrokerModel(pod, brokerView); brokerModel.start(); model.add(brokerModel); //add transports for (MessageDistribution messageDistribution : messageDistributionList) { brokerView.createTransport(messageDistribution); } } else { //transport might not be valid brokerModel.setUri(uri.toString()); brokerModel.updateTransport(); } BrokerOverview brokerOverview = new BrokerOverview(); attribute = "TotalConnectionsCount"; Number result = (Number) getAttribute(client, root, attribute); brokerOverview.setTotalConnections(result.intValue()); populateDestinations(client, root, brokerOverview); brokerModel.setBrokerStatistics(brokerOverview); } catch (Throwable e) { LOG.error("Unable able to get BrokerStatistics from root=" + root + ",attribute: " + attribute, e); } } }
From source file:com.amazonaws.metrics.internal.cloudwatch.PredefinedMetricTransformer.java
/** * Returns a list of metric datum recorded for the specified counter metric * type; or an empty list if there is none. * /*from w w w. j a v a2 s . c om*/ * @param includesRequestType * true iff an additional metric datum is to be created that * includes the "request" dimension */ protected List<MetricDatum> counterMetricOf(MetricType type, Request<?> req, Object resp, boolean includesRequestType) { AWSRequestMetrics m = req.getAWSRequestMetrics(); TimingInfo ti = m.getTimingInfo(); final String metricName = type.name(); Number counter = ti.getCounter(metricName); if (counter == null) { return Collections.emptyList(); } int count = counter.intValue(); if (count < 1) { LogFactory.getLog(getClass()).warn("Count must be at least one"); return Collections.emptyList(); } final List<MetricDatum> result = new ArrayList<MetricDatum>(); final Dimension metricDimension = new Dimension().withName(Dimensions.MetricType.name()) .withValue(metricName); // non-request type specific metric datum final MetricDatum first = new MetricDatum().withMetricName(req.getServiceName()) .withDimensions(metricDimension).withUnit(StandardUnit.Count).withValue(Double.valueOf(count)) .withTimestamp(endTimestamp(ti)); result.add(first); if (includesRequestType) { // additional request type specific metric datum Dimension requestDimension = new Dimension().withName(Dimensions.RequestType.name()) .withValue(requestType(req)); final MetricDatum second = newMetricDatum(first, metricDimension, requestDimension); result.add(second); } return result; }
From source file:org.datacleaner.widgets.result.ValueDistributionResultSwingRendererGroupDelegate.java
public int getDataSetValue(String label) { Number value = _dataset.getValue(label, ""); return value.intValue(); }
From source file:com.openmeap.model.ModelServiceImpl.java
@Override public int countVersionsByHashAndHashAlg(String hash, String hashAlg) { Query q = entityManager.createQuery("select count(av) " + "from ApplicationVersion av " + "left join av.archive ar " + "where ar.hash=:hash " + "and ar.hashAlgorithm=:hashAlgorithm"); q.setParameter("hash", hash); q.setParameter("hashAlgorithm", hashAlg); try {/*from w w w. j ava 2 s.c o m*/ Number ret = (Number) q.getSingleResult(); return ret.intValue(); } catch (NoResultException nre) { return 0; } }
From source file:com.openmeap.model.ModelServiceImpl.java
@Override public int countApplicationArchivesByHashAndHashAlg(String hash, String hashAlg) { Query q = entityManager.createQuery("select count(ar) " + "from ApplicationArchive ar " + "where ar.hash=:hash " + "and ar.hashAlgorithm=:hashAlgorithm "); q.setParameter("hash", hash); q.setParameter("hashAlgorithm", hashAlg); try {/*from www . j a va2 s.c o m*/ Number ret = (Number) q.getSingleResult(); return ret.intValue(); } catch (NoResultException nre) { return 0; } }
From source file:com.openmeap.model.ModelServiceImpl.java
@Override public int countDeploymentsByHashAndHashAlg(String hash, String hashAlg) { Query q = entityManager/*from w w w. java 2 s. c o m*/ .createQuery("select count(d) " + "from Deployment d " + "left join d.applicationArchive aa " + "where aa.hash=:hash " + "and aa.hashAlgorithm=:hashAlgorithm"); q.setParameter("hash", hash); q.setParameter("hashAlgorithm", hashAlg); try { Number ret = (Number) q.getSingleResult(); return ret.intValue(); } catch (NoResultException nre) { return 0; } }
From source file:com.opengamma.financial.analytics.volatility.surface.BloombergIRFutureOptionVolatilitySurfaceInstrumentProvider.java
@Override /**/*from w w w .jav a 2 s. co m*/ * Provides ExternalID for Bloomberg ticker, eg EDZ3C 99.250 Comdty, * given a reference date and an integer offset, the n'th subsequent option * The format is futurePrefix + month + year + callPutFlag + strike + postfix * * @param futureNumber n'th future following curve date * @param strike option's strike, expressed as price in %, e.g. 98.750 * @param surfaceDate date of curve validity; valuation date */ public ExternalId getInstrument(final Number futureOptionNumber, final Double strike, final LocalDate surfaceDate) { Validate.notNull(futureOptionNumber, "futureOptionNumber"); final StringBuffer ticker = new StringBuffer(); ticker.append(getFutureOptionPrefix()); ticker.append(BloombergFutureUtils.getExpiryCodeForFutureOptions(getFutureOptionPrefix(), futureOptionNumber.intValue(), surfaceDate)); ticker.append(strike > useCallAboveStrike() ? "C " : "P "); ticker.append(FORMATTER.format(strike)); ticker.append(" "); ticker.append(getPostfix()); return ExternalId.of(SCHEME, ticker.toString()); }
From source file:com.vuze.plugin.azVPN_Helper.Checker_PIA.java
private boolean checkStatusFileForPort(File pathPIAManagerData, StringBuilder sReply) { // Read the status_file for forwarding port boolean gotValidPort = false; File fileStatus = new File(pathPIAManagerData, "status_file.txt"); if (!fileStatus.isFile() || !fileStatus.canRead()) { return false; }/*from w ww . ja v a2 s .c om*/ try { byte[] statusFileBytes = FileUtil.readFileAsByteArray(fileStatus); if (statusFileBytes.length > STATUS_FILE_PORT_INDEX && statusFileBytes[STATUS_FILE_PORT_INDEX] == '{') { int endPos = STATUS_FILE_PORT_INDEX; while (endPos < statusFileBytes.length && statusFileBytes[endPos] > 1) { endPos++; } boolean gotPort = false; String jsonPort = new String(statusFileBytes, STATUS_FILE_PORT_INDEX, endPos - STATUS_FILE_PORT_INDEX); Map<?, ?> decodeJSON = JSONUtils.decodeJSON(jsonPort); if (decodeJSON.containsKey("single")) { Object oPort = decodeJSON.get("single"); if (oPort == null) { gotPort = true; String user = config.getPluginStringParameter(PluginConstants.CONFIG_USER); byte[] pass = config.getPluginByteParameter(PluginConstants.CONFIG_P); if (user == null || user.length() == 0 || pass == null || pass.length == 0) { boolean portForwardEnabled = false; File fileSettings = new File(pathPIAManagerData, "settings.json"); String settingsString = FileUtil.readFileAsString(fileSettings, -1); Map<?, ?> mapSettings = JSONUtils.decodeJSON(settingsString); if (mapSettings != null && mapSettings.containsKey("portforward")) { portForwardEnabled = (Boolean) mapSettings.get("portforward"); } addReply(sReply, CHAR_WARN, portForwardEnabled ? "pia.no.forwarding.port" : "pia.no.port.config"); } } if (oPort instanceof Number) { gotPort = true; gotValidPort = true; Number nPort = (Number) oPort; int port = nPort.intValue(); addReply(sReply, CHAR_GOOD, "pia.port.in.manager", new String[] { Integer.toString(port) }); changePort(port, sReply); } } if (!gotPort) { addReply(sReply, CHAR_BAD, "pia.invalid.port.status_file", new String[] { jsonPort }); } } } catch (IOException e) { e.printStackTrace(); } return gotValidPort; }
From source file:com.github.lpezet.antiope.metrics.aws.spi.PredefinedMetricTransformer.java
/** * Returns a list of metric datum recorded for the specified counter metric * type; or an empty list if there is none. * /*w w w. j av a2s . c om*/ * @param pIncludesRequestType * true iff an additional metric datum is to be created that * includes the "request" dimension */ protected List<MetricDatum> counterMetricOf(MetricType pType, Request<?> pReq, Object pResp, boolean pIncludesRequestType) { IMetrics m = pReq.getMetrics(); TimingInfo ti = m.getTimingInfo(); final String oMetricName = pType.name(); Number oCounter = ti.getCounter(oMetricName); if (oCounter == null) { return Collections.emptyList(); } int oCount = oCounter.intValue(); if (oCount < 1) { LogFactory.getLog(getClass()).warn("Count must be at least one"); return Collections.emptyList(); } final List<MetricDatum> oResult = new ArrayList<MetricDatum>(); final Dimension oMetricDimension = new Dimension().withName(Dimensions.MetricType.name()) .withValue(oMetricName); // non-request type specific metric datum final MetricDatum oFirst = new MetricDatum().withMetricName(pReq.getServiceName()) .withDimensions(oMetricDimension).withUnit(StandardUnit.Count).withValue(Double.valueOf(oCount)) .withTimestamp(endTimestamp(ti)); oResult.add(oFirst); if (pIncludesRequestType) { // additional request type specific metric datum Dimension oRequestDimension = new Dimension().withName(Dimensions.RequestType.name()) .withValue(requestType(pReq)); final MetricDatum oSecond = newMetricDatum(oFirst, oMetricDimension, oRequestDimension); oResult.add(oSecond); } return oResult; }