List of usage examples for java.lang Long Long
@Deprecated(since = "9") public Long(String s) throws NumberFormatException
From source file:com.mirth.connect.connectors.js.JavaScriptMessageReceiver.java
public JavaScriptMessageReceiver(UMOConnector connector, UMOComponent component, UMOEndpoint endpoint) throws InitialisationException { super(connector, component, endpoint, new Long(((JavaScriptConnector) connector).getPollingFrequency())); if (((JavaScriptConnector) connector).getPollingType().equals(JavaScriptConnector.POLLING_TYPE_TIME)) setTime(((JavaScriptConnector) connector).getPollingTime()); else//from w w w . ja va 2 s . c o m setFrequency(((JavaScriptConnector) connector).getPollingFrequency()); this.connector = (JavaScriptConnector) connector; monitoringController.updateStatus(connector, connectorType, Event.INITIALIZED); }
From source file:com.wsl.marketconsolescraper.ScraperConfiguration.java
/** @return delay before scraping the Market console for the first time, in milliseconds */ public long getDelay() { return new Long(properties.getProperty("delay")); }
From source file:Urls.java
/** * Returns the time when the document should be considered expired. * The time will be zero if the document always needs to be revalidated. * It will be <code>null</code> if no expiration time is specified. *///from w w w. j a v a 2 s.c o m public static Long getExpiration(URLConnection connection, long baseTime) { String cacheControl = connection.getHeaderField("Cache-Control"); if (cacheControl != null) { StringTokenizer tok = new StringTokenizer(cacheControl, ","); while (tok.hasMoreTokens()) { String token = tok.nextToken().trim().toLowerCase(); if ("must-revalidate".equals(token)) { return new Long(0); } else if (token.startsWith("max-age")) { int eqIdx = token.indexOf('='); if (eqIdx != -1) { String value = token.substring(eqIdx + 1).trim(); int seconds; try { seconds = Integer.parseInt(value); return new Long(baseTime + seconds * 1000); } catch (NumberFormatException nfe) { logger.warning("getExpiration(): Bad Cache-Control max-age value: " + value); // ignore } } } } } String expires = connection.getHeaderField("Expires"); if (expires != null) { try { synchronized (PATTERN_RFC1123) { Date expDate = PATTERN_RFC1123.parse(expires); return new Long(expDate.getTime()); } } catch (java.text.ParseException pe) { int seconds; try { seconds = Integer.parseInt(expires); return new Long(baseTime + seconds * 1000); } catch (NumberFormatException nfe) { logger.warning("getExpiration(): Bad Expires header value: " + expires); } } } return null; }
From source file:hyldap.HyHcNewUserGroupBean.java
public List<Long> groups(String username, LdapConfig config, LdapOperations ldap, RoleProvider provider, AttributeSet attrSet) {// w ww . j ava2s.co m log.debug("groups for " + username); Set<String> groupNames = new HashSet<String>(); groupNames.addAll(attrSet.getAll(GROUP_MEMBER)); groupNames.addAll(attrSet.getAll(GROUP_OWNER)); if (groupNames.isEmpty()) { throw new ValidationException(username + " has no attributes " + GROUP_MEMBER + " or " + GROUP_OWNER); } List<Long> groups = new ArrayList<Long>(); for (String grpName : groupNames) { log.debug("grpName " + grpName); if (allowedGroups.containsKey(grpName)) { log.debug("grpName matched " + grpName); String grpOmeName = (String) allowedGroups.get(grpName); log.debug("grpName matched " + grpOmeName); groups.add(provider.createGroup(grpOmeName, null, false)); log.debug("grpName matched, adding group 'user'"); groups.add(new Long(1)); } } return groups; }
From source file:org.lamop.riche.webservices.WorkRESTWS.java
@RequestMapping(method = RequestMethod.GET, headers = "Accept=application/json") public @ResponseBody WorkEntity get(@PathParam("id") int id) { System.out.println("GET ID " + id); return serviceWork.getEntity(new Long(id)); }
From source file:cn.aozhi.songify.functional.rest.TaskRestFT.java
/** * //.//from w w w. j a va2s .c om */ @Test @Category(Smoke.class) public void createUpdateAndDeleteTask() { // create Task task = TaskData.randomTask(); URI createdTaskUri = restTemplate.postForLocation(resourceUrl, task); System.out.println(createdTaskUri.toString()); Task createdTask = restTemplate.getForObject(createdTaskUri, Task.class); assertThat(createdTask.getTitle()).isEqualTo(task.getTitle()); // update String id = StringUtils.substringAfterLast(createdTaskUri.toString(), "/"); task.setId(new Long(id)); task.setTitle(TaskData.randomTitle()); restTemplate.put(createdTaskUri, task); Task updatedTask = restTemplate.getForObject(createdTaskUri, Task.class); assertThat(updatedTask.getTitle()).isEqualTo(task.getTitle()); // delete restTemplate.delete(createdTaskUri); try { restTemplate.getForObject(createdTaskUri, Task.class); fail("Get should fail while feth a deleted task"); } catch (HttpStatusCodeException e) { assertThat(e.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); } }
From source file:com.couchbase.sqoop.mapreduce.db.CouchbaseRecordReadSerializeTest.java
@Before @Override//from ww w.j av a2 s .c o m public void setUp() throws Exception { super.setUp(); tappedStuff = new HashMap<String, ResponseMessage>(); URI uri = new URI(CouchbaseUtils.CONNECT_STRING); String user = CouchbaseUtils.COUCHBASE_USER_NAME; String pass = CouchbaseUtils.COUCHBASE_USER_PASS; try { cb = new CouchbaseClient(Arrays.asList(uri), user, pass); } catch (IOException e) { LOG.error("Couldn't connect to server" + e.getMessage()); fail(e.toString()); } this.client = new TapClient(Arrays.asList(uri), user, pass); cb.flush(); Thread.sleep(500); // set up the items we're going to deserialize Integer anint = new Integer(Integer.MIN_VALUE); cb.set(anint.toString(), 0x300, anint).get(); Long along = new Long(Long.MAX_VALUE); cb.set(along.toString(), 0, along).get(); Float afloat = new Float(Float.MAX_VALUE); cb.set(afloat.toString(), 0, afloat).get(); Double doubleBase = new Double(Double.NEGATIVE_INFINITY); cb.set(doubleBase.toString(), 0, doubleBase).get(); Boolean booleanBase = true; cb.set(booleanBase.toString(), 0, booleanBase).get(); rightnow = new Date(); // instance, needed later dateText = rightnow.toString().replaceAll(" ", "_"); cb.set(dateText, 0, rightnow).get(); Byte byteMeSix = new Byte("6"); cb.set(byteMeSix.toString(), 0, byteMeSix).get(); String ourString = "hi,there"; cb.set(ourString.toString(), 0, ourString).get(); client.tapDump("tester"); while (client.hasMoreMessages()) { ResponseMessage m = client.getNextMessage(); if (m == null) { continue; } tappedStuff.put(m.getKey(), m); } }
From source file:kr.moonlightdriver.app.server.Result.java
public Long getLong(String key) { Long result = new Long(-1); try {//from www . java 2 s. co m result = mJson.getLong(key); } catch (JSONException e) { e.printStackTrace(); } catch (NullPointerException e) { Logg.e("Parameter fault : " + key + " = null (Long)"); return null; } return result; }
From source file:org.lightadmin.core.util.NumberUtils.java
@SuppressWarnings("unchecked") public static <T extends Number> T convertNumberToTargetClass(Number number, Class<T> targetClass) throws IllegalArgumentException { Assert.notNull(number, "Number must not be null"); Assert.notNull(targetClass, "Target class must not be null"); if (targetClass.isInstance(number)) { return (T) number; } else if (targetClass.equals(byte.class)) { long value = number.longValue(); if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) { raiseOverflowException(number, targetClass); }// www . j ava 2s .co m return (T) new Byte(number.byteValue()); } else if (targetClass.equals(short.class)) { long value = number.longValue(); if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) { raiseOverflowException(number, targetClass); } return (T) new Short(number.shortValue()); } else if (targetClass.equals(int.class)) { long value = number.longValue(); if (value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) { raiseOverflowException(number, targetClass); } return (T) new Integer(number.intValue()); } else if (targetClass.equals(long.class)) { return (T) new Long(number.longValue()); } else if (targetClass.equals(float.class)) { return (T) Float.valueOf(number.toString()); } else if (targetClass.equals(double.class)) { return (T) Double.valueOf(number.toString()); } else { return org.springframework.util.NumberUtils.convertNumberToTargetClass(number, targetClass); } }
From source file:test.gov.nih.nci.cacoresdk.domain.other.primarykey.LongPrimitiveKeyResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set//from w ww. j a v a 2 s. c om * Verifies that none of the attributes are null * * @throws Exception */ public void testGet() throws Exception { try { LongPrimitiveKey searchObject = new LongPrimitiveKey(); Collection results = getApplicationService() .search("gov.nih.nci.cacoresdk.domain.other.primarykey.LongPrimitiveKey", searchObject); String id = ""; if (results != null && results.size() > 0) { LongPrimitiveKey obj = (LongPrimitiveKey) ((List) results).get(0); Long idVal = obj.getId(); id = new Long(idVal).toString(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/LongPrimitiveKey/" + 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("LongPrimitiveKey" + "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; } }