List of usage examples for java.lang Long Long
@Deprecated(since = "9") public Long(String s) throws NumberFormatException
From source file:edu.kit.trufflehog.model.network.MacAddress.java
public MacAddress(long address) throws InvalidMACAddress { this.address = address; if (this.address > 0xFFFFFFFFFFFFL || this.address < 0) { throw new InvalidMACAddress(address); }/*from w w w . j av a 2 s.c om*/ hashcode = (new Long(address)).hashCode(); // transform to byte array final byte[] extractedBytes = ByteBuffer.allocate(8).putLong(address).array(); bytes = Arrays.copyOfRange(extractedBytes, 2, 8); // set multicast bit isMulticast = (bytes[0] & 1) == 1; // set string representation final List<Byte> bytes = Arrays.asList(ArrayUtils.toObject(toByteArray())); addressString = bytes.stream().map(b -> String.format("%02x", b)).collect(Collectors.joining(":")); }
From source file:org.sakaiproject.tool.tasklist.impl.TaskRowMapper.java
public Object mapRow(ResultSet rs, int rowNum) throws SQLException { Task task = new TaskImpl(); task.setId(new Long(rs.getLong(TASK_ID))); task.setOwner(rs.getString(TASK_OWNER)); task.setSiteId(rs.getString(TASK_SITE_ID)); task.setCreationDate(rs.getDate(TASK_CREATION_DATE)); task.setTask(rs.getString(TASK_TEXT)); return task;//w w w . ja v a2 s .c o m }
From source file:com.cemeterylistingswebtest.test.rest.DisplayDeceasedControllerTest.java
@Test(enabled = false) public void testCreate() { System.out.println("PublishListingService Testing"); Long subID = new Long(17); List<PersonOtherNames> names = null; PublishedDeceasedListing newListing = new PublishedDeceasedListing.Builder().setFirstName("Hendrika") .setSurname("Fourie").setMaidenName("Gerber").setGender("Female").setDateOfBirth("08/06/1969") .setDateOfDeath("14/02/2005").setGraveInscription("Hippiest person eva").setGraveNumber("2456") .setImageOfBurialSite("/images/001.jpg").setLastKnownContactName("Berry") .setLastKnownContactNumber("0725576482").setSubscriberSubmitID(subID).setNames(names).build(); HttpEntity<PublishedDeceasedListing> requestEntity = new HttpEntity<>(newListing, getContentType()); // Make the HTTP POST request, marshaling the request to JSON, and the response to a String ResponseEntity<String> responseEntity = restTemplate.exchange(URL + "api/DeceasedListing/create", HttpMethod.POST, requestEntity, String.class); System.out.println(" THE RESPONSE BODY " + responseEntity.getBody()); System.out.println(" THE RESPONSE STATUS CODE " + responseEntity.getStatusCode()); System.out.println(" THE RESPONSE IS HEADERS " + responseEntity.getHeaders()); Assert.assertEquals(responseEntity.getStatusCode(), HttpStatus.OK); id = newListing.getPublishedListingID(); }
From source file:org.hdiv.idGenerator.RandomUidGenerator.java
public Serializable generateUid() { long uid = this.random.nextLong(); if (uid < 0) { uid = uid * -1;//Hacerlo positivo }//from w w w .j a v a 2 s . c o m return new Long(uid).toString(); }
From source file:com.processpuzzle.fundamental_types.domain.ParameterValue.java
public static ParameterValue parse(String definitionText) throws ClassNotFoundException, InstantiationException, IllegalAccessException { ParameterDefinition definition = ParameterDefinition.parse(definitionText); Pattern valuePattern = Pattern.compile("=([^/]+)/{0,2}"); Matcher valueFinder = valuePattern.matcher(definitionText); String valueString = null;//w w w. j ava 2s.c om if (valueFinder.find()) { int valueStringLength = valueFinder.group().contains("//") ? valueFinder.group().length() - 2 : valueFinder.group().length(); valueString = StringUtils.strip(valueFinder.group().substring(1, valueStringLength)); } Object valueObject = null; if (definition.getType().equals(String.class)) valueObject = new String(valueString); else if (definition.getType().equals(Integer.class)) valueObject = new Integer(valueString); else if (definition.getType().equals(Long.class)) valueObject = new Long(valueString); else if (definition.getType().equals(Double.class)) valueObject = new Double(valueString); return new ParameterValue(definition, valueObject); }
From source file:com.zving.platform.SysInfo.java
public static void list1DataBind(DataListAction dla) { DataTable dt = new DataTable(); dt.insertColumn("Name"); dt.insertColumn("Value"); dt.insertRow(new Object[] { "???", Config.getAppCode() + "(" + Config.getAppName() + ")" }); dt.insertRow(/*from w w w. j av a2 s. co m*/ new Object[] { "?", Config.getMainVersion() + "." + Config.getMinorVersion() }); dt.insertRow(new Object[] { "?", DateUtil .toString(new Date(Long.parseLong(Config.getValue("App.Uptime"))), "yyyy-MM-dd HH:mm:ss") }); dt.insertRow(new Object[] { "?", new Long(Config.getLoginUserCount()) }); dt.insertRow(new Object[] { "??", Config.getValue("App.DebugMode") }); dt.insertRow(new Object[] { "???", Config.getValue("System.OSName") }); dt.insertRow(new Object[] { "?", Config.getValue("System.OSVersion") }); dt.insertRow(new Object[] { "??", Config.getValue("System.OSPatchLevel") }); dt.insertRow(new Object[] { "JDK", Config.getValue("System.JavaVendor") }); dt.insertRow(new Object[] { "JDK", Config.getValue("System.JavaVersion") }); dt.insertRow(new Object[] { "JDK", Config.getValue("System.JavaHome") }); dt.insertRow(new Object[] { "Servlet??", Config.getValue("System.ContainerInfo") }); dt.insertRow(new Object[] { "?Servlet??", Config.getValue("System.OSUserName") }); dt.insertRow(new Object[] { "JDK/?", (Runtime.getRuntime().totalMemory() / 1024L / 1024L) + "M/" + (Runtime.getRuntime().maxMemory() / 1024L / 1024L) + "M" }); dt.insertRow(new Object[] { "?", Config.getFileEncode() }); dla.bindData(dt); }
From source file:dao.HdprofileUpdateQuery.java
public void run(Connection conn, int pm, int bb, int fd, String loginid) throws BaseDaoException { Long myloginid = new Long(loginid); try {/*from w w w . j a v a2 s . c o m*/ PreparedStatement stmt = conn.prepareStatement("update hdprofile set informpm=" + pm + ", informbb=" + bb + ", informfd=" + fd + " where loginid=" + myloginid + ""); stmt.executeUpdate(); } catch (Exception e) { logger.warn("Error occured while executing hdprofile update query ", e); throw new BaseDaoException("Error occured while executing hdprofile update query ", e); } }
From source file:com.loy.MicroServiceConsole.java
@SuppressWarnings("rawtypes") static void init() { ClassPathResource classPathResource = new ClassPathResource("application.yml"); Yaml yaml = new Yaml(); Map result = null;/*from w w w . j av a 2 s . com*/ try { result = (Map) yaml.load(classPathResource.getInputStream()); } catch (IOException e1) { e1.printStackTrace(); } String platformStr = result.get("platform").toString(); String version = result.get("version").toString(); String jvmOption = result.get("jvmOption").toString(); @SuppressWarnings("unchecked") List<String> projects = (List<String>) result.get("projects"); platform = Platform.valueOf(platformStr); final Runtime runtime = Runtime.getRuntime(); File pidsForder = new File("./pids"); if (!pidsForder.exists()) { pidsForder.mkdir(); } else { File[] files = pidsForder.listFiles(); if (files != null) { for (File f : files) { f.deleteOnExit(); String pidStr = f.getName(); try { Long pid = new Long(pidStr); if (Processes.isProcessRunning(platform, pid)) { if (Platform.Windows == platform) { Processes.tryKillProcess(null, platform, new NullProcessor(), pid); } else { Processes.killProcess(null, platform, new NullProcessor(), pid); } } } catch (Exception ex) { } } } } File currentForder = new File(""); String root = currentForder.getAbsolutePath(); root = root.replace(File.separator + "build" + File.separator + "libs", ""); root = root.replace(File.separator + "e-example-ms-start", ""); final String rootPath = root; new Thread(new Runnable() { @Override public void run() { int size = projects.size(); int index = 1; for (String value : projects) { String path = value; String[] values = value.split("/"); value = values[values.length - 1]; value = rootPath + "/" + path + "/build/libs/" + value + "-" + version + ".jar"; final String command = value; try { Process process = runtime .exec("java " + jvmOption + " -Dfile.encoding=UTF-8 -jar " + command); Long pid = Processes.processId(process); pids.add(pid); File pidsFile = new File("./pids", pid.toString()); pidsFile.createNewFile(); new WriteLogThread(process.getInputStream()).start(); } catch (IOException e) { e.printStackTrace(); } synchronized (lock) { try { if (index < size) { lock.wait(); } else { index++; } } catch (InterruptedException e) { e.printStackTrace(); } } } } }).start(); }
From source file:fr.keemto.spikes.ScheduledTaskRegistrarIT.java
@Test @Ignore//from w w w . jav a 2 s. c o m public void registerAScheduledTaskWithRegistrar() throws Exception { CountDownTask task = new CountDownTask(); Map<Runnable, Long> fixedDelayTasks = new HashMap<Runnable, Long>(); fixedDelayTasks.put(task, new Long(100)); registrar.setFixedDelayTasks(fixedDelayTasks); registrar.afterPropertiesSet(); latch.await(2000, TimeUnit.MILLISECONDS); assertThat(latch.getCount(), equalTo((long) 0)); }
From source file:net.fenyo.mail4hotspot.web.GMailOAuthStep1Servlet.java
private String now() { return new Long(new java.util.Date().getTime() / 1000).toString(); }