List of usage examples for java.lang Number intValue
public abstract int intValue();
From source file:ch.opentrainingcenter.charts.bar.OTCCategoryChartViewerTest.java
@Test public void testUpdateData_Herz() { final List<ITraining> data = new ArrayList<>(); final ITraining simpleTraining = mock(ITraining.class); final Integer heart = Integer.valueOf(170); when(simpleTraining.getAverageHeartBeat()).thenReturn(heart); when(simpleTraining.getDatum()).thenReturn(1000L); final List<PastTraining> arrayList = new ArrayList<>(); arrayList.add(new PastTraining(1, data)); data.add(simpleTraining);/*from w w w . j a va 2s . c o m*/ viewer.updateData(data, arrayList, XAxisChart.DAY, TrainingChart.HERZ, false); final DefaultCategoryDataset dataset = viewer.getDataset(); final Number value = dataset.getValue("0", "1"); assertEquals(170, value.intValue()); }
From source file:edu.uci.ics.jung.algorithms.flows.TestEdmondsKarpMaxFlow.java
public void testSimpleFlow() { DirectedGraph<Number, Number> graph = new DirectedSparseMultigraph<Number, Number>(); Factory<Number> edgeFactory = new Factory<Number>() { int count = 0; public Number create() { return count++; }//from w w w. j av a 2 s . c o m }; Map<Number, Number> edgeCapacityMap = new HashMap<Number, Number>(); for (int i = 0; i < 6; i++) { graph.addVertex(i); } Map<Number, Number> edgeFlowMap = new HashMap<Number, Number>(); graph.addEdge(edgeFactory.create(), 0, 1, EdgeType.DIRECTED); edgeCapacityMap.put(0, 16); graph.addEdge(edgeFactory.create(), 0, 2, EdgeType.DIRECTED); edgeCapacityMap.put(1, 13); graph.addEdge(edgeFactory.create(), 1, 2, EdgeType.DIRECTED); edgeCapacityMap.put(2, 6); graph.addEdge(edgeFactory.create(), 1, 3, EdgeType.DIRECTED); edgeCapacityMap.put(3, 12); graph.addEdge(edgeFactory.create(), 2, 4, EdgeType.DIRECTED); edgeCapacityMap.put(4, 14); graph.addEdge(edgeFactory.create(), 3, 2, EdgeType.DIRECTED); edgeCapacityMap.put(5, 9); graph.addEdge(edgeFactory.create(), 3, 5, EdgeType.DIRECTED); edgeCapacityMap.put(6, 20); graph.addEdge(edgeFactory.create(), 4, 3, EdgeType.DIRECTED); edgeCapacityMap.put(7, 7); graph.addEdge(edgeFactory.create(), 4, 5, EdgeType.DIRECTED); edgeCapacityMap.put(8, 4); EdmondsKarpMaxFlow<Number, Number> ek = new EdmondsKarpMaxFlow<Number, Number>(graph, 0, 5, MapTransformer.<Number, Number>getInstance(edgeCapacityMap), edgeFlowMap, edgeFactory); ek.evaluate(); assertTrue(ek.getMaxFlow() == 23); Set<Number> nodesInS = ek.getNodesInSourcePartition(); assertEquals(4, nodesInS.size()); for (Number v : nodesInS) { Assert.assertTrue(v.intValue() != 3 && v.intValue() != 5); } Set<Number> nodesInT = ek.getNodesInSinkPartition(); assertEquals(2, nodesInT.size()); for (Number v : nodesInT) { Assert.assertTrue(v.intValue() == 3 || v.intValue() == 5); } Set<Number> minCutEdges = ek.getMinCutEdges(); int maxFlow = 0; for (Number e : minCutEdges) { Number flow = edgeFlowMap.get(e); maxFlow += flow.intValue(); } Assert.assertEquals(23, maxFlow); Assert.assertEquals(3, minCutEdges.size()); }
From source file:javadz.beanutils.locale.converters.IntegerLocaleConverter.java
/** * Convert the specified locale-sensitive input object into an output object of the * specified type. This method will return Integer type. * * @param value The input object to be converted * @param pattern The pattern is used for the convertion * @return The converted value/*from ww w . j av a2 s . co m*/ * * @exception ConversionException if conversion cannot be performed * successfully * @throws ParseException if an error occurs parsing a String to a Number */ protected Object parse(Object value, String pattern) throws ParseException { final Number parsed = (Number) super.parse(value, pattern); if (parsed.longValue() != parsed.intValue()) { throw new ConversionException("Suplied number is not of type Integer: " + parsed.longValue()); } return new Integer(parsed.intValue()); // unlike superclass it will return proper Integer }
From source file:net.duckling.ddl.service.resource.dao.StarmarkDAOImpl.java
@Override public int create(final Starmark starmark) { GeneratedKeyHolder keyHolder = new GeneratedKeyHolder(); this.getJdbcTemplate().update(new PreparedStatementCreator() { @Override//ww w. ja va2s .c om public PreparedStatement createPreparedStatement(Connection conn) throws SQLException { PreparedStatement ps = null; ps = conn.prepareStatement(SQL_CREATE, PreparedStatement.RETURN_GENERATED_KEYS); int i = 0; ps.setInt(++i, starmark.getRid()); ps.setInt(++i, starmark.getTid()); ps.setString(++i, starmark.getUid()); ps.setTimestamp(++i, new Timestamp(starmark.getCreateTime().getTime())); return ps; } }, keyHolder); Number key = keyHolder.getKey(); return (key == null) ? -1 : key.intValue(); }
From source file:com.ruihu.easyshop.order.dao.OrderDao.java
private PageBean<Order> findByCriteria(List<Expression> exprList, int pc) throws SQLException { int ps = PageConstants.ORDER_PAGE_SIZE;//get records in a page /*// w w w.j av a 2 s. c o m * 2. where by using exprList */ StringBuilder whereSql = new StringBuilder(" where 1=1"); List<Object> params = new ArrayList<Object>(); for (Expression expr : exprList) { whereSql.append(" and ").append(expr.getName()).append(" ").append(expr.getOperator()).append(" "); // where 1=1 and bid = ? if (!expr.getOperator().equals("is null")) { whereSql.append("?"); params.add(expr.getValue()); } } /* * 3. totally records */ String sql = "select count(*) from t_order" + whereSql; Number number = (Number) qr.query(sql, new ScalarHandler(), params.toArray()); int tr = number.intValue();//get all totally records /* * 4.get current records through beanlist */ sql = "select * from t_order" + whereSql + " order by ordertime desc limit ?,?"; params.add((pc - 1) * ps);// index of current page params.add(ps);//search how many records in a page List<Order> beanList = qr.query(sql, new BeanListHandler<Order>(Order.class), params.toArray()); // load every items in each order list for (Order order : beanList) { loadOrderItem(order); } /* * 5. create PageBean */ PageBean<Order> pb = new PageBean<Order>(); pb.setBeanList(beanList); pb.setPc(pc); pb.setPs(ps); pb.setTr(tr); return pb; }
From source file:com.newatlanta.bluedragon.CategoryItemLabelGenerator.java
protected Object[] createItemArray(CategoryDataset dataset, int row, int column) { Object[] result = new Object[5]; result[0] = dataset.getRowKey(row).toString(); result[1] = dataset.getColumnKey(column).toString(); Number value = dataset.getValue(row, column); if (value != null) { if (yAxisSymbols != null) { int intValue = value.intValue(); if (intValue < yAxisSymbols.length) result[2] = yAxisSymbols[intValue]; else//from ww w . j av a2 s .c o m result[2] = "???"; } else if (this.getNumberFormat() != null) { result[2] = this.getNumberFormat().format(value); } else if (this.getDateFormat() != null) { result[2] = this.getDateFormat().format(value); } } else { result[2] = "-"; // this.nullValueString; } if (value != null) { double total = DataUtilities.calculateRowTotal(dataset, row); double percent = value.doubleValue() / total; result[3] = NumberFormat.getPercentInstance().format(percent); if (this.getNumberFormat() != null) { result[4] = this.getNumberFormat().format(total); } else if (this.getDateFormat() != null) { // result[4] = this.getDateFormat().format(total); } } return result; }
From source file:eu.dasish.annotation.backend.dao.impl.JdbcCachedRepresentationDaoTest.java
/** * Test of getInternalId method, of class JdbcCachedRepresentationDao. * public Number getInternalId(UUID externalID); *//*from w w w . j av a 2 s .co m*/ @Test public void testGetInternalId() throws NotInDataBaseException { System.out.println("test getInternalID"); UUID externalID = UUID.fromString("00000000-0000-0000-0000-000000000051"); Number result = jdbcCachedRepresentationDao.getInternalID(externalID); assertEquals(1, result.intValue()); }
From source file:eu.dasish.annotation.backend.dao.impl.JdbcCachedRepresentationDaoTest.java
/** * Test of getInternalIDFromURI method,// w w w . jav a 2 s.c om * public Number getInternalIDFromURI(UUID externalID); */ @Test public void testGetInternalIDFRomURI() throws NotInDataBaseException { System.out.println("test getInternalIDFromURI"); jdbcCachedRepresentationDao.setResourcePath("/api/cached/"); String uri = "/api/cached/00000000-0000-0000-0000-000000000051"; Number result = jdbcCachedRepresentationDao.getInternalIDFromHref(uri); assertEquals(1, result.intValue()); }
From source file:com.espertech.esper.epl.core.OrderByProcessorRowLimit.java
/** * Applys the limiting function to outgoing events. * @param outgoingEvents unlimited// w ww .j a v a 2s . c o m * @return limited */ protected EventBean[] applyLimit(EventBean[] outgoingEvents) { if (outgoingEvents == null) { return null; } if (numRowsVariableReader != null) { Number varValue = (Number) numRowsVariableReader.getValue(); if (varValue != null) { currentRowLimit = varValue.intValue(); } else { currentRowLimit = Integer.MAX_VALUE; } if (currentRowLimit < 0) { currentRowLimit = Integer.MAX_VALUE; } } if (offsetVariableReader != null) { Number varValue = (Number) offsetVariableReader.getValue(); if (varValue != null) { currentOffset = varValue.intValue(); } else { currentOffset = 0; } if (currentOffset < 0) { currentOffset = 0; } } // no offset if (currentOffset == 0) { if ((outgoingEvents.length <= currentRowLimit)) { return outgoingEvents; } if (currentRowLimit == 0) { return null; } EventBean[] limited = new EventBean[currentRowLimit]; System.arraycopy(outgoingEvents, 0, limited, 0, currentRowLimit); return limited; } // with offset else { int maxInterested = currentRowLimit + currentOffset; if (currentRowLimit == Integer.MAX_VALUE) { maxInterested = Integer.MAX_VALUE; } // more rows then requested if (outgoingEvents.length > maxInterested) { EventBean[] limited = new EventBean[currentRowLimit]; System.arraycopy(outgoingEvents, currentOffset, limited, 0, currentRowLimit); return limited; } // less or equal rows to offset if (outgoingEvents.length <= currentOffset) { return null; } int size = outgoingEvents.length - currentOffset; EventBean[] limited = new EventBean[size]; System.arraycopy(outgoingEvents, currentOffset, limited, 0, size); return limited; } }
From source file:eu.dasish.annotation.backend.dao.impl.JdbcPrincipalDaoTest.java
/** * Test of getInternalID method, of class JdbcPrincipalDao. Number * getInternalID(UUID UUID);// w w w . ja v a 2 s .c om */ @Test public void testGetInternalID() throws NotInDataBaseException { Number testOne = jdbcPrincipalDao.getInternalID(UUID.fromString("00000000-0000-0000-0000-000000000113")); assertEquals(3, testOne.intValue()); try { Number testTwo = jdbcPrincipalDao .getInternalID(UUID.fromString("00000000-0000-0000-0000-000000000ccc")); assertEquals(null, testTwo); } catch (NotInDataBaseException e) { System.out.println(e); } }