List of usage examples for java.lang Number intValue
public abstract int intValue();
From source file:edu.uci.ics.jung.io.TestGraphMLWriter.java
@SuppressWarnings("unchecked") public void testBasicWrite() throws IOException, ParserConfigurationException, SAXException { Graph<String, Number> g = TestGraphs.createTestGraph(true); GraphMLWriter<String, Number> gmlw = new GraphMLWriter<String, Number>(); Transformer<Number, String> edge_weight = new Transformer<Number, String>() { public String transform(Number n) { return String.valueOf(n.intValue()); }/* w w w . j av a2 s . c o m*/ }; Transformer<String, String> vertex_name = TransformerUtils.nopTransformer(); gmlw.addEdgeData("weight", "integer value for the edge", Integer.toString(-1), edge_weight); gmlw.addVertexData("name", "identifier for the vertex", null, vertex_name); gmlw.setEdgeIDs(edge_weight); gmlw.setVertexIDs(vertex_name); gmlw.save(g, new FileWriter("src/test/resources/testbasicwrite.graphml")); // TODO: now read it back in and compare the graph connectivity // and other metadata with what's in TestGraphs.pairs[], etc. // Factory<String> vertex_factory = null; // Factory<Object> edge_factory = FactoryUtils.instantiateFactory(Object.class); // GraphMLReader<Graph<String, Object>, String, Object> gmlr = // new GraphMLReader<Graph<String, Object>, String, Object>( // vertex_factory, edge_factory); GraphMLReader<Graph<String, Object>, String, Object> gmlr = new GraphMLReader<Graph<String, Object>, String, Object>(); Graph<String, Object> g2 = new DirectedSparseGraph<String, Object>(); gmlr.load("src/test/resources/testbasicwrite.graphml", g2); Map<String, GraphMLMetadata<Object>> edge_metadata = gmlr.getEdgeMetadata(); Transformer<Object, String> edge_weight2 = edge_metadata.get("weight").transformer; validateTopology(g, g2, edge_weight, edge_weight2); // TODO: delete graph file when done File f = new File("src/test/resources/testbasicwrite.graphml"); f.delete(); }
From source file:au.com.onegeek.lambda.core.provider.WebDriverBackedSeleniumProvider.java
public void clickAndWait(String id, String seconds) throws ParseException { NumberFormat format = NumberFormat.getInstance(Locale.ENGLISH); Number number = format.parse(seconds); this.click(id); this.waitForPageToLoad(String.valueOf(number.intValue() * 1000)); }
From source file:com.pet.demo.repository.jdbc.JdbcPetRepositoryImpl.java
public void save(Pet pet) throws DataAccessException { if (pet.isNew()) { Number newKey = this.insertPet.executeAndReturnKey(createPetParameterSource(pet)); pet.setId(newKey.intValue()); } else {/* w ww.ja v a2 s . c o m*/ this.namedParameterJdbcTemplate .update("UPDATE pets SET name=:name, birth_date=:birth_date, type_id=:type_id, " + "owner_id=:owner_id WHERE id=:id", createPetParameterSource(pet)); } }
From source file:cz.cvut.kbss.jsonld.jackson.serialization.JacksonJsonWriter.java
@Override public void writeNumber(Number number) throws IOException { if (number instanceof Integer) { jsonGenerator.writeNumber(number.intValue()); } else if (number instanceof Long) { jsonGenerator.writeNumber(number.longValue()); } else if (number instanceof Float) { jsonGenerator.writeNumber(number.floatValue()); } else if (number instanceof Double) { jsonGenerator.writeNumber(number.doubleValue()); } else if (number instanceof BigInteger) { jsonGenerator.writeNumber((BigInteger) number); } else if (number instanceof BigDecimal) { jsonGenerator.writeNumber((BigDecimal) number); } else if (number instanceof Short) { jsonGenerator.writeNumber(number.shortValue()); } else if (number instanceof Byte) { jsonGenerator.writeNumber(number.byteValue()); } else {//w w w. j av a 2s . c o m throw new IllegalArgumentException( "Unable to write number " + number + " of type " + number.getClass()); } }
From source file:net.sf.zekr.common.util.VelocityUtils.java
public int intAdd(Object num1, Object num2) { Number n1 = toInteger(num1); Number n2 = toInteger(num2);/*from w w w .ja va 2 s . co m*/ return n1.intValue() + n2.intValue(); }
From source file:MutableInteger.java
/** Compares this number to another number. * * @param number The other number. *///from w w w . j ava 2 s.c om public int compareTo(Number number) { return doCompare(mutableInteger, number.intValue()); }
From source file:org.iwethey.forums.db.JdbcAdminManager.java
/** * <p>Retrieve the number of quotes in the database.</p> *//* ww w . j a v a 2s .com*/ public int getLRPDCount() { Query query = getSession().createQuery(COUNT_LRPDS_SQL); Number result = (Number) query.uniqueResult(); return result.intValue(); }
From source file:com.amazonaws.util.TimingInfoFullSupport.java
@Override public void incrementCounter(String key) { int count = 0; Number counter = getCounter(key); if (counter != null) { count = counter.intValue(); }/* w ww. jav a 2 s. c o m*/ setCounter(key, ++count); }
From source file:com.aw.core.dao.AWQueryRunner.java
public int findCountRows(Connection con, String sqlFromWhere, Object[] filterKeys) { List results = findListOfMaps(con, "select count(*) as numRows " + sqlFromWhere, filterKeys); Number num = results.size() > 0 ? (Number) ((Map) results.get(0)).get("numRows") : null; return num == null ? 0 : num.intValue(); }
From source file:com.floreantpos.model.dao.ShopFloorDAO.java
public boolean hasFloor() { Number result = (Number) getSession().createCriteria(getReferenceClass()) .setProjection(Projections.rowCount()).uniqueResult(); return result.intValue() != 0; }