List of usage examples for java.lang Number intValue
public abstract int intValue();
From source file:org.openmrs.module.hospitalcore.db.hibernate.HibernateRadiologyDAO.java
public Integer countRadiologyTests(Date date, String status, Set<Concept> concepts, List<Patient> patients) throws ParseException { Criteria criteria = sessionFactory.getCurrentSession().createCriteria(RadiologyTest.class); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String startDate = sdf.format(date) + " 00:00:00"; String endDate = sdf.format(date) + " 23:59:59"; SimpleDateFormat dateTimeFormatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); criteria.add(//from w w w.j a v a 2 s .c o m Expression.between("date", dateTimeFormatter.parse(startDate), dateTimeFormatter.parse(endDate))); criteria.add(Restrictions.eq("status", status)); criteria.add(Restrictions.in("concept", concepts)); if (!CollectionUtils.isEmpty(patients)) criteria.add(Restrictions.in("patient", patients)); Number rs = (Number) criteria.setProjection(Projections.rowCount()).uniqueResult(); return rs != null ? rs.intValue() : 0; }
From source file:org.openmrs.module.hospitalcore.db.hibernate.HibernateRadiologyDAO.java
public Integer countRadiologyTestsByDiscontinuedDate(Date date, Set<Concept> concepts, List<Patient> patients) throws ParseException { Criteria criteria = sessionFactory.getCurrentSession().createCriteria(RadiologyTest.class); Criteria orderCriteria = criteria.createCriteria("order"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String startDate = sdf.format(date) + " 00:00:00"; String endDate = sdf.format(date) + " 23:59:59"; SimpleDateFormat dateTimeFormatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); orderCriteria.add(Expression.between("discontinuedDate", dateTimeFormatter.parse(startDate), dateTimeFormatter.parse(endDate))); criteria.add(Restrictions.in("concept", concepts)); if (!CollectionUtils.isEmpty(patients)) criteria.add(Restrictions.in("patient", patients)); Number rs = (Number) criteria.setProjection(Projections.rowCount()).uniqueResult(); return rs != null ? rs.intValue() : 0; }
From source file:edu.cuny.cat.ui.ClockPanel.java
@Override public void setup(final ParameterDatabase parameters, final Parameter base) { clock = GameController.getInstance().getClock(); dataset = new DefaultValueDataset(); meterplot = new MyMeterPlot(dataset) { /**/*from w w w . ja va 2 s. c o m*/ * */ private static final long serialVersionUID = 1L; @Override protected void drawValueLabel(final Graphics2D g2, final Rectangle2D area) { g2.setFont(getValueFont()); g2.setPaint(getValuePaint()); String valueStr = "No value"; if (dataset != null) { final Number n = dataset.getValue(); if (n != null) { if (n.intValue() == 0) { valueStr = "to start"; } else if (n.intValue() == clock.getGameLen() * clock.getDayLen()) { valueStr = "done"; } else { valueStr = "day " + (n.intValue() / clock.getDayLen()) + ", round " + (n.intValue() % clock.getDayLen()); } } } final float x = (float) area.getCenterX(); final float y = (float) area.getCenterY() + MeterPlot.DEFAULT_CIRCLE_SIZE; TextUtilities.drawAlignedString(valueStr, g2, x, y, TextAnchor.TOP_CENTER); } }; meterplot.setRange(new Range(0, clock.getDayLen() * clock.getGameLen())); meterplot.setNeedlePaint( parameters.getColorWithDefault(base.push(ClockPanel.P_NEEDLE), null, Color.darkGray)); meterplot.setDialBackgroundPaint(new Color(0, 255, 0, 64)); meterplot.setDialOutlinePaint(Color.gray); meterplot.setDialShape(DialShape.CHORD); meterplot.setMeterAngle(parameters.getIntWithDefault(base.push(ClockPanel.P_ANGLE), null, 260)); meterplot.setTickLabelsVisible(true); meterplot.setTickLabelFont(new Font("Dialog", 1, 10)); meterplot.setTickLabelPaint(Color.darkGray); meterplot.setTickSize(clock.getDayLen()); meterplot.setTickPaint(Color.lightGray); meterplot.setValuePaint(Color.black); meterplot.setValueFont(new Font("Dialog", 1, 14)); meterplot.setUnits(""); meterplot.setTickLabelFormat(new NumberFormat() { /** * */ private static final long serialVersionUID = 1L; @Override public StringBuffer format(final double number, final StringBuffer toAppendTo, final FieldPosition pos) { return format((long) number, toAppendTo, pos); } @Override public StringBuffer format(final long number, final StringBuffer toAppendTo, final FieldPosition pos) { if (number % clock.getDayLen() == 0) { toAppendTo.append(String.valueOf(number / clock.getDayLen())); } return toAppendTo; } @Override public Number parse(final String source, final ParsePosition parsePosition) { return null; } }); final JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, meterplot, false); final ChartPanel panel = new ChartPanel(chart); panel.setPreferredSize(new Dimension(parameters.getIntWithDefault(base.push(ClockPanel.P_WIDTH), null, 200), parameters.getIntWithDefault(base.push(ClockPanel.P_HEIGHT), null, 200))); add(panel, BorderLayout.CENTER); initIterationLabel(); initScoreReport(); }
From source file:com.vuze.plugin.azVPN_Helper.Checker_PIA.java
private boolean callRPCforPort(File pathPIAManagerData, InetAddress bindIP, StringBuilder sReply) { InetAddress[] resolve = null; try {/* w w w . j av a2 s .c om*/ // Let's assume the client_id.txt file is the one for port forwarding. File fileClientID = new File(pathPIAManagerData, "client_id.txt"); String clientID; if (fileClientID.isFile() && fileClientID.canRead()) { clientID = FileUtil.readFileAsString(fileClientID, -1); } else { clientID = config.getPluginStringParameter("client.id", null); if (clientID == null) { clientID = RandomUtils.generateRandomAlphanumerics(20); config.setPluginParameter("client.id", clientID); } } HttpPost post = new HttpPost(PIA_RPC_URL); String user = config.getPluginStringParameter(PluginConstants.CONFIG_USER); String pass = new String(config.getPluginByteParameter(PluginConstants.CONFIG_P, new byte[0]), "utf-8"); if (user == null || user.length() == 0 || pass == null || pass.length() == 0) { return false; } List<NameValuePair> urlParameters = new ArrayList<NameValuePair>(); urlParameters.add(new BasicNameValuePair("user", user)); urlParameters.add(new BasicNameValuePair("pass", pass)); urlParameters.add(new BasicNameValuePair("client_id", clientID)); urlParameters.add(new BasicNameValuePair("local_ip", bindIP.getHostAddress())); // Call needs to be from the VPN interface (the bindIP) RequestConfig requestConfig = RequestConfig.custom().setLocalAddress(bindIP).setConnectTimeout(15000) .build(); post.setConfig(requestConfig); post.setEntity(new UrlEncodedFormEntity(urlParameters)); CloseableHttpClient httpClient = HttpClients.createDefault(); // If Vuze has a proxy set up (Tools->Options->Connection->Proxy), then // we'll need to disable it for the URL AEProxySelector selector = AEProxySelectorFactory.getSelector(); if (selector != null) { resolve = SystemDefaultDnsResolver.INSTANCE.resolve(VPN_DOMAIN); for (InetAddress address : resolve) { selector.setProxy(new InetSocketAddress(address, 443), Proxy.NO_PROXY); } } CloseableHttpResponse response = httpClient.execute(post); BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); StringBuffer result = new StringBuffer(); String line = ""; while ((line = rd.readLine()) != null) { result.append(line); } boolean gotPort = false; // should be {"port":xyz} Map<?, ?> mapResult = JSONUtils.decodeJSON(result.toString()); if (mapResult.containsKey("port")) { Object oPort = mapResult.get("port"); if (oPort instanceof Number) { gotPort = true; Number nPort = (Number) oPort; int port = nPort.intValue(); addReply(sReply, CHAR_GOOD, "pia.port.from.rpc", new String[] { Integer.toString(port) }); changePort(port, sReply); } } if (!gotPort) { addReply(sReply, CHAR_WARN, "vpnhelper.rpc.bad", new String[] { result.toString() }); // mapResult.containsKey("error") return false; } } catch (Exception e) { e.printStackTrace(); addReply(sReply, CHAR_BAD, "vpnhelper.rpc.no.connect", new String[] { bindIP + ": " + e.getMessage() }); return false; } finally { AEProxySelector selector = AEProxySelectorFactory.getSelector(); if (selector != null && resolve != null) { for (InetAddress address : resolve) { AEProxySelectorFactory.getSelector().removeProxy(new InetSocketAddress(address, 443)); } } } return true; }
From source file:eu.databata.engine.dao.PropagationDAO.java
public boolean hasPropagationObjectEntry(String objectName, String moduleName) { String sql = "SELECT 1 FROM " + propagationObjectsTable + " WHERE object_name = ? AND module_name = ?"; try {//from ww w . ja v a 2s . co m Number number = getJdbcTemplate().queryForObject(sql, new Object[] { objectName, moduleName }, Integer.class); return (number != null ? number.intValue() : 0) == 1; } catch (EmptyResultDataAccessException e) { return false; } }
From source file:org.squale.squalecommon.enterpriselayer.facade.quality.MeasureFacade.java
/** * Ajoute une entre la table des valeurs du graphe historique * // w w w.j a v a 2s . c om * @param values la table des valeurs * @param key la cl * @param value la valeur */ private static void addHistoricValues(Map values, Date key, Object value) { if (value != null) { // Petit test faire sur le type de la note // Dans le cas ou c'est un boolen, on met alors 1 si le boolen // est true, 0 sinon // Dans le cas d'une note, on met la valeur // Initialisation 0 par dfaut Number numberToAdd = new Integer("0"); if (value instanceof Boolean) { // boolen valant "true" if (((Boolean) value).booleanValue()) { numberToAdd = new Integer("1"); } // else boolen valant false, rien faire car valeur par dfaut } else if (value.toString().matches("[0-9]+(\\.[0-9]+)?")) { // Rcupre directement le nombre numberToAdd = (Number) value; } if (numberToAdd.intValue() != -1) { values.put(key, numberToAdd); } } }
From source file:com.prowidesoftware.swift.model.field.Field105.java
/** * Set the component1 from a Number object. * <br />//from w ww . j a v a 2 s.co m * <em>If the component being set is a fixed length number, the argument will not be * padded.</em> It is recommended for these cases to use the setComponent1(String) * method. * * @see #setComponent1(String) * * @param component1 the Number with the component1 content to set */ public Field105 setComponent1(java.lang.Number component1) { if (component1 != null) { setComponent(1, "" + component1.intValue()); } return this; }
From source file:com.prowidesoftware.swift.model.field.Field120.java
/** * Set the component1 from a Number object. * <br />/* ww w.ja v a 2 s. c o m*/ * <em>If the component being set is a fixed length number, the argument will not be * padded.</em> It is recommended for these cases to use the setComponent1(String) * method. * * @see #setComponent1(String) * * @param component1 the Number with the component1 content to set */ public Field120 setComponent1(java.lang.Number component1) { if (component1 != null) { setComponent(1, "" + component1.intValue()); } return this; }
From source file:com.prowidesoftware.swift.model.field.Field125.java
/** * Set the component1 from a Number object. * <br />// w ww . j a v a 2s.c o m * <em>If the component being set is a fixed length number, the argument will not be * padded.</em> It is recommended for these cases to use the setComponent1(String) * method. * * @see #setComponent1(String) * * @param component1 the Number with the component1 content to set */ public Field125 setComponent1(java.lang.Number component1) { if (component1 != null) { setComponent(1, "" + component1.intValue()); } return this; }