List of usage examples for java.lang Long valueOf
@HotSpotIntrinsicCandidate public static Long valueOf(long l)
From source file:com.threadswarm.imagefeedarchiver.FeedUtils.java
/** * Returns a <code>long</code> with the best expected content-length value or -1 if no value could be calculated. * The value of the 'Content-Length' header, if available from the <code>HttpResponse</code> object is preferred * over the file-size specified by the <code>RssMediaContent</code> object argument. However, if the former is * unavailable than the latter is used. If no value can be calculated than -1 is returned to the caller. * /* w w w. j a va 2 s . co m*/ * @param httpResponse the <code>HttpResponse</code> object from which the 'Content-Length' header will be examined * @param mediaContent the <code>RssMediaContent</code> object from which the <code>getFileSize()</code> method will be called * @return the best content-length value given the two argument sources */ public static long calculateBestExpectedContentLength(HttpResponse httpResponse, RssMediaContent mediaContent) { Long mediaContentFileSize = mediaContent.getFileSize(); long expectedContentLength = (mediaContentFileSize != null) ? mediaContent.getFileSize() : -1; Header contentLengthHeader = httpResponse.getFirstHeader(HttpHeaders.CONTENT_LENGTH); if (contentLengthHeader != null) { long headerContentLength = Long.valueOf(contentLengthHeader.getValue()); if (expectedContentLength == -1 || headerContentLength != expectedContentLength) { expectedContentLength = headerContentLength; } } return expectedContentLength; }
From source file:com.clustercontrol.monitor.run.util.ParallelExecution.java
/** * /*from w w w . j a v a 2s .c o m*/ */ private ParallelExecution() { log.debug("init()"); int m_maxThreadPool = HinemosPropertyUtil .getHinemosPropertyNum("monitor.common.thread.pool", Long.valueOf(10)).intValue(); log.info("monitor.common.thread.pool: " + m_maxThreadPool); es = new MonitoredThreadPoolExecutor(m_maxThreadPool, m_maxThreadPool, 0L, TimeUnit.MICROSECONDS, new LinkedBlockingQueue<Runnable>(), new ThreadFactory() { private volatile int _count = 0; @Override public Thread newThread(Runnable r) { return new Thread(r, "MonitorWorker-" + _count++); } }, new ThreadPoolExecutor.AbortPolicy()); log.debug("ParallelExecution() ExecutorService is " + es.getClass().getCanonicalName()); log.debug("ParallelExecution() securityManager is " + System.getSecurityManager()); }
From source file:org.tec.webapp.jdbc.entity.support.IdentifierCallback.java
/** {@inheritDoc} */ @Override()/* www .ja v a 2 s .c o m*/ public Long doInPreparedStatement(PreparedStatement ps) throws SQLException, DataAccessException { ResultSet generatedKeys = null; try { ps.execute(); generatedKeys = ps.getGeneratedKeys(); if (generatedKeys.next()) { return Long.valueOf(generatedKeys.getLong(1)); } else { throw new SQLException("Unable to insert new record " + ps.toString()); } } finally { if (generatedKeys != null) { generatedKeys.close(); } } }
From source file:core.controller.KategoriController.java
@RequestMapping(value = "/delete", method = RequestMethod.GET) public String delete(HttpServletRequest request) { long id = Long.valueOf(request.getParameter("id")); kategoriDAO.delete(kategoriDAO.getById(id)); return "redirect:/kategori"; }
From source file:de.hybris.platform.acceleratorservices.dataimport.batch.FileOrderComparator.java
@Override public int compare(final File file, final File otherFile) { // invert priority setting so files with higher priority go first int result = getPriority(otherFile).compareTo(getPriority(file)); if (result == 0) { result = Long.valueOf(file.lastModified()).compareTo(Long.valueOf(otherFile.lastModified())); }//from w ww . ja v a 2 s . c om return result; }
From source file:com.scvngr.levelup.core.model.factory.json.AccessTokenJsonFactoryTest.java
@SmallTest public void testJsonParse_singleObject() throws JSONException { final AccessTokenJsonFactory factory = new AccessTokenJsonFactory(); final JSONObject object = AccessTokenFixture.getFullJsonObject(); final AccessToken token = factory.from(object); assertEquals(object.get(AccessTokenJsonFactory.JsonKeys.TOKEN), token.getAccessToken()); assertEquals(Long.valueOf(object.getLong(AccessTokenJsonFactory.JsonKeys.MERCHANT_ID)), token.getMerchantId());/* ww w . j a v a 2 s . c o m*/ assertEquals(Long.valueOf(object.getLong(AccessTokenJsonFactory.JsonKeys.USER_ID)), token.getUserId()); }
From source file:com.qumoon.commons.TaobaoUtils.java
/** * ?? url ? num iid/*from www . j ava 2 s. c o m*/ */ public static Long getItemUrlNumIid(String url) { Matcher matcher = ITEM_NUM_IID_PATTERN.matcher(url); if (matcher.find() && matcher.groupCount() > 1) { String numIidStr = matcher.group(2); if (NumberUtils.isNumber(numIidStr)) { return Long.valueOf(numIidStr); } else { return null; } } return null; }
From source file:JavaCloud.Models.Image.java
public Image(String address, String token, JSONObject image_dict) { this.address = address; this.token = token; id = Integer.parseInt(image_dict.get("id").toString()); name = image_dict.get("name").toString(); description = image_dict.get("description").toString(); state = image_dict.get("state").toString(); type = image_dict.get("type").toString(); size = Long.valueOf(image_dict.get("size").toString()); format = image_dict.get("format").toString(); // TODO: New variables }
From source file:it.nicola_amatucci.util.Json.java
public static <T> T object_from_json(JSONObject json, Class<T> objClass) throws Exception { T t = null;// w w w. j a v a 2 s. co m Object o = null; try { //create new object instance t = objClass.newInstance(); //object fields Field[] fields = objClass.getFields(); for (Field field : fields) { //field name o = json.get(field.getName()); if (o.equals(null)) continue; //field value try { String typeName = field.getType().getSimpleName(); if (typeName.equals("String")) { o = json.getString(field.getName()); //String } else if (typeName.equals("boolean")) { o = Integer.valueOf(json.getInt(field.getName())); //boolean } else if (typeName.equals("int")) { o = Integer.valueOf(json.getInt(field.getName())); //int } else if (typeName.equals("long")) { o = Long.valueOf(json.getLong(field.getName())); //long } else if (typeName.equals("double")) { o = Double.valueOf(json.getDouble(field.getName())); //double } else if (typeName.equals("Date")) { o = new SimpleDateFormat(Json.DATA_FORMAT).parse(o.toString()); //data } else if (field.getType().isArray()) { JSONArray arrayJSON = new JSONArray(o.toString()); T[] arrayOfT = (T[]) null; try { //create object array Class c = Class.forName(field.getType().getName()).getComponentType(); arrayOfT = (T[]) Array.newInstance(c, arrayJSON.length()); //parse objects for (int i = 0; i < json.length(); i++) arrayOfT[i] = (T) object_from_json(arrayJSON.getJSONObject(i), c); } catch (Exception e) { throw e; } o = arrayOfT; } else { o = object_from_json(new JSONObject(o.toString()), field.getType()); //object } } catch (Exception e) { throw e; } t.getClass().getField(field.getName()).set(t, o); } } catch (Exception e) { throw e; } return t; }
From source file:data.services.ValueRangeService.java
public ValueRange getParam(Object uid, Object valMin, Object valMax, Object amin, Object amax) { ValueRange vr = new ValueRange(); vr.setUid(StringAdapter.getString(uid).trim()); vr.setAmax(Long.valueOf(getZeroInNullAndTrim(amax).trim())); vr.setAmin(Long.valueOf(getZeroInNullAndTrim(amin).trim())); vr.setValueMax(Long.valueOf(getZeroInNullAndTrim(valMax).trim())); vr.setValueMin(Long.valueOf(getZeroInNullAndTrim(valMin).trim())); //validate(vr); return vr;/*from ww w. j a v a 2 s. c om*/ }