List of usage examples for java.lang Long Long
@Deprecated(since = "9") public Long(String s) throws NumberFormatException
From source file:Main.java
/** * Sums an array of numbers together while using the correct class type. * * @param numbers//from w w w .j a va2s .c o m * * @return the sum contained in the most appropriate number class */ static Number sum(Number[] numbers) { Number newSum = (Number) getObject(numbers); if (newSum == null) { return null; } //Integer, Long, Float, Double if (newSum instanceof Integer) { int sum = 0; int nextValue; for (int i = 0; i < numbers.length; i++) { nextValue = numbers[i].intValue(); sum += nextValue; } newSum = new Integer(sum); } else if (newSum instanceof Long) { long sum = 0; long nextValue; for (int i = 0; i < numbers.length; i++) { nextValue = numbers[i].longValue(); sum += nextValue; } newSum = new Long(sum); } else if (newSum instanceof Float) { float sum = 0; float nextValue; for (int i = 0; i < numbers.length; i++) { nextValue = numbers[i].floatValue(); sum += nextValue; } newSum = new Float(sum); } else if (newSum instanceof Double) { double sum = 0; double nextValue; for (int i = 0; i < numbers.length; i++) { nextValue = numbers[i].doubleValue(); sum += nextValue; } newSum = new Double(sum); } else { return null; } return newSum; }
From source file:com.muni.fi.pa165.survive.rest.client.utils.DtoBuilder.java
public static WeaponDto getWeaponDto(CommandLine line) { WeaponDto dto = new WeaponDto(); //name//from w ww.j a v a 2 s. c o m if (line.hasOption("n")) { dto.setName(line.getOptionValue("n")); } //caliber if (line.hasOption("m")) { dto.setCaliber(new Double(line.getOptionValue("m"))); } //range if (line.hasOption("g")) { dto.setRange(new Integer(line.getOptionValue("g"))); } //rounds if (line.hasOption("r")) { dto.setRounds(new Integer(line.getOptionValue("r"))); } //index if (line.hasOption("i")) { dto.setId(new Long(line.getOptionValue("i"))); } //type if (line.hasOption("t")) { dto.setWeaponType(WeaponType.valueOf(line.getOptionValue("t").toUpperCase())); } //class if (line.hasOption("c")) { dto.setWeaponClass(WeaponClass.valueOf(line.getOptionValue("c").toUpperCase())); } //desc if (line.hasOption("d")) { dto.setDescription(line.getOptionValue("d")); } return dto; }
From source file:net.sf.morph.util.TestClass.java
/** * Returns an instance of this class with some fields populated *//* www . j a va 2 s . co m*/ public static TestClass getPartialObject() { TestClass partialObject = new TestClass(); partialObject.setAnObject(new Long(14)); partialObject.setMyInteger(4); partialObject.setMyMap(null); partialObject.setMyLongValue(new Long(13)); return partialObject; }
From source file:controllers.services.ServicesApp.java
/** * ?//from ww w . jav a2 s . c o m */ @Transactional(readOnly = true) public static Result index() { DynamicForm requestData = Form.form().bindFromRequest(); ListOrderedMap cts = SkillTag.getCacheCategory(); Integer page = StringUtils.isBlank(requestData.get("page")) ? 1 : new Integer(requestData.get("page")); Integer pageSize = StringUtils.isBlank(requestData.get("pageSize")) ? 10 : new Integer(requestData.get("pageSize")); Long categoryId = StringUtils.isBlank(requestData.get("categoryId")) ? (Long) cts.asList().get(0) : new Long(requestData.get("categoryId")); String type = requestData.get("type") == null ? "html" : requestData.get("type"); Page<ServiceListVO> returnPage = Service.queryServiceByPage(page, pageSize, categoryId); if (!type.equals("json")) { return ok(views.html.services.index.render(returnPage, cts, categoryId)); } return ok(play.libs.Json.toJson(returnPage)); }
From source file:controllers.require.RequireApp.java
/** * /*from ww w . j av a 2 s .co m*/ */ @Transactional(readOnly = true) public static Result index() { DynamicForm requestData = Form.form().bindFromRequest(); ListOrderedMap cts = SkillTag.getCacheCategory(); Integer page = StringUtils.isBlank(requestData.get("page")) ? 1 : new Integer(requestData.get("page")); Integer pageSize = StringUtils.isBlank(requestData.get("pageSize")) ? 10 : new Integer(requestData.get("pageSize")); Long categoryId = StringUtils.isBlank(requestData.get("categoryId")) ? (Long) cts.asList().get(0) : new Long(requestData.get("categoryId")); String type = requestData.get("type") == null ? "html" : requestData.get("type"); Page<RequireListVO> returnPage = Require.queryRequireByPage(page, pageSize, categoryId); if (!type.equals("json")) { return ok(views.html.require.index.render(returnPage, cts, categoryId)); } return ok(play.libs.Json.toJson(returnPage)); }
From source file:fr.amapj.service.services.authentification.PasswordManager.java
public static void main(String[] args) { TestTools.init();/* w w w . j a v a 2 s .c o m*/ new PasswordManager().setUserPassword(new Long(1052), "a"); //new PasswordManager().setUserPassword(new Long(1052), "e"); //String str = new PasswordManager().generateResetPaswordSalt(); //System.out.println("str="+str); }
From source file:de.odysseus.calyxo.base.util.ParseUtils.java
private static Object nullValue(Class type) { if (type.isPrimitive()) { if (type == boolean.class) return Boolean.FALSE; if (type == byte.class) return new Byte((byte) 0); if (type == char.class) return new Character((char) 0); if (type == short.class) return new Short((short) 0); if (type == int.class) return new Integer(0); if (type == long.class) return new Long(0); if (type == float.class) return new Float(0); if (type == double.class) return new Double(0); }//from w w w.j av a 2 s . c o m return null; }
From source file:net.primeranks.fs_viewer.fs_replay.JSONUserParser.java
public static List<User> parseData(InputStream json) throws Exception { // The Android relies that the entire JSON object is in the memory already, read it into a buffer BufferedReader reader = new BufferedReader(new InputStreamReader(json)); StringBuilder sb = new StringBuilder(); try {// w w w.j a v a2s. c o m String line = reader.readLine(); while (line != null) { sb.append(line); line = reader.readLine(); } } catch (IOException e) { throw e; } finally { reader.close(); } JSONObject all = new JSONObject(sb.toString()); JSONArray json_list = (JSONArray) all.get("user"); List<User> l = new ArrayList<User>(); for (int i = 0; i < json_list.length(); ++i) { JSONObject c = (JSONObject) json_list.get(i); User u = new User(); u.setId(new Long(c.getInt("id"))); u.setDomain(c.getString("domain")); u.setName(c.getString("name")); l.add(u); } return l; }
From source file:gov.nih.nci.lv.util.LVUtils.java
/** * converts a ids seperated by a comma to a set. * @param ids ids//from ww w. j av a 2s .c o m * @param delimiter delimiter * @return Set */ public static Set<Long> convertStringToSet(String ids, String delimiter) { Set<Long> labs = new HashSet<Long>(); if (StringUtils.isEmpty(ids)) { return labs; } StringTokenizer st = new StringTokenizer(ids, delimiter); while (st.hasMoreTokens()) { labs.add(new Long(st.nextElement().toString())); } return labs; }
From source file:com.intel.cosbench.client.amplistor.AmpliUtils.java
public static HttpRequest policyToRequest(HttpRequest request, AmpliPolicy policy) { request.setHeader(AmpliPolicy.SPREAD_WIDTH, new Long(policy.spread_Width).toString()); request.setHeader(AmpliPolicy.SAFETY, new Long(policy.safety).toString()); request.setHeader(AmpliPolicy.HIERARYCHY_RULES, fold(policy.hierarchy_Rules)); request.setHeader(AmpliPolicy.MAX_SUPERBLOCK_SIZE, new Long(policy.max_Superblock_Size).toString()); request.setHeader(AmpliPolicy.SAFETY_STRATEGY, fold(policy.safety_Strategy)); request.setHeader(AmpliPolicy.N_MESSAGES, new Long(policy.n_Messages).toString()); return request; }