List of usage examples for java.lang Long Long
@Deprecated(since = "9") public Long(String s) throws NumberFormatException
From source file:hu.vpmedia.media.red5.bwcheck.BandwidthDetection.java
public void calculateClientBw(IConnection p_client) { for (int i = 0; i < 1200; i++) { payload[i] = Math.random(); }//from w w w . ja va2s. c om p_client.setAttribute("payload", payload); for (int i = 0; i < 12000; i++) { payload_1[i] = Math.random(); } p_client.setAttribute("payload_1", payload_1); for (int i = 0; i < 12000; i++) { payload_2[i] = Math.random(); } p_client.setAttribute("payload_2", payload_2); final IStreamCapableConnection beginningStats = this.getStats(); final Long start = new Long(System.nanoTime() / 1000000); //new Long(System.currentTimeMillis()); this.client = p_client; beginningValues = new HashMap<String, Long>(); beginningValues.put("b_down", beginningStats.getWrittenBytes()); beginningValues.put("b_up", beginningStats.getReadBytes()); beginningValues.put("time", start); this.pakSent.add(start); this.sent++; log.info("Starting bandwidth check at " + start); this.callBWCheck(""); }
From source file:Main.java
/** * Divides num1 by num2, and return the result in the correct number class. * //from www .j av a 2s . co m * @param num1 numerator * @param num2 denominator * @return num1/num2 in the most appropriate class */ static Number divide(Number num1, Number num2) { Number[] both = new Number[2]; both[0] = num1; both[1] = num2; Number division = (Number) getObject(both); if (division == null) { return null; } //Integer, Long, Float, Double if (division instanceof Integer) { //we've got 2 integers, but we're going to use double anyways return new Double(num1.doubleValue() / num2.doubleValue()); } else if (division instanceof Long) { return new Long(num1.longValue() / num2.longValue()); } else if (division instanceof Float) { return new Float(num1.floatValue() / num2.floatValue()); } else if (division instanceof Double) { return new Double(num1.doubleValue() / num2.doubleValue()); } else { return null; } }
From source file:it.jugpadova.controllers.BinController.java
/** * Produce the JUG Logo from the database, or the default no logo image. *//* w w w.j av a2s .c om*/ @RequestMapping public void jugLogo(HttpServletRequest req, HttpServletResponse res) throws IOException { Long id = new Long(req.getParameter("id")); byte[] jugLogo = jugBo.retrieveJugLogo(id); flushResponse(jugLogo, "JugLogo", "noJugLogo", res); }
From source file:net.sf.morph.util.TestClass.java
/** * Returns an instance of this class with all fields populated *//*w w w. java 2 s.c o m*/ public static TestClass getFullObject() { TestClass fullObject = new TestClass(); fullObject.setAnObject(new Long(14)); fullObject.setMyInteger(4); fullObject.setMyMap(getMyMapProperty()); fullObject.setMyLongValue(new Long(13)); fullObject.setArray(new Object[] { "hi" }); fullObject.setBigDecimal(new BigDecimal(3.5)); fullObject.setNumberArray(NUMBER_ARRAY); fullObject.setFunkyArray(NUMBER_ARRAY); fullObject.setString("string"); return fullObject; }
From source file:com.addthis.metrics3.reporter.config.prometheus.MetricRegistryDecorator.java
public MetricFamilySamples fromCounter(String name, Counter counter) { Sample sample = new Sample(name, labelNames, labelValues, new Long(counter.getCount()).doubleValue()); return new MetricFamilySamples(name, Type.GAUGE, getHelpMessage(name, counter), Arrays.asList(sample)); }
From source file:gt.dakaik.common.Common.java
public static boolean validSession(String token, Long idUser) { Long i = activeSession.getOrDefault(token, new Long(-1)); if (Objects.equals(i, idUser)) { activeTimeSession.replace(token, minsSession); return true; } else {/*from w w w. ja v a2 s . co m*/ return false; } }
From source file:test.gov.nih.nci.cacoresdk.domain.other.primarykey.LongKeyResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set/*ww w . ja va 2 s.c om*/ * Verifies that none of the attributes are null * * @throws Exception */ public void testGet() throws Exception { try { LongKey searchObject = new LongKey(); Collection results = getApplicationService() .search("gov.nih.nci.cacoresdk.domain.other.primarykey.LongKey", searchObject); String id = ""; if (results != null && results.size() > 0) { LongKey obj = (LongKey) ((List) results).get(0); Long idVal = obj.getId(); id = new Long(idVal).toString(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/LongKey/" + id; WebClient client = WebClient.create(url); client.type("application/xml").accept("application/xml"); Response response = client.get(); if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } File myFile = new File("LongKey" + "XML.xml"); System.out.println("writing data to file " + myFile.getAbsolutePath()); FileWriter myWriter = new FileWriter(myFile); BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity()))); String output; System.out.println("Output from Server .... \n"); while ((output = br.readLine()) != null) { myWriter.write(output); System.out.println(output); } myWriter.flush(); myWriter.close(); } catch (Exception e) { e.printStackTrace(); throw e; } }
From source file:cz.muni.fi.pa165.rentalofconstructionmachinery.dao.RentalDAOTest.java
@Test public void testCreateRentalWithID() { Long id = new Long(666); rental.setId(id);/*from ww w .ja v a2 s. c om*/ boolean failed = false; try { rentalDAO.createRental(rental); } catch (Exception e) { failed = true; } if (!failed) { assertFalse(rental.getId().equals(id)); } }
From source file:com.appleframework.jmx.core.util.CoreUtils.java
public static Number valueOf(String value, String dataType) { if (dataType.equals("java.lang.Integer") || dataType.equals("int")) { return new Integer(value); }/*from w w w .ja va 2s .c o m*/ if (dataType.equals("java.lang.Double") || dataType.equals("double")) { return new Double(value); } if (dataType.equals("java.lang.Long") || dataType.equals("long")) { return new Long(value); } if (dataType.equals("java.lang.Float") || dataType.equals("float")) { return new Double(value); } if (dataType.equals("java.lang.Short") || dataType.equals("short")) { return new Short(value); } if (dataType.equals("java.lang.Byte") || dataType.equals("byte")) { return new Byte(value); } if (dataType.equals("java.math.BigInteger")) { return new BigInteger(value); } if (dataType.equals("java.math.BigDecimal")) { return new BigDecimal(value); } return null; }