List of usage examples for java.lang Long valueOf
@HotSpotIntrinsicCandidate public static Long valueOf(long l)
From source file:cherry.foundation.crypto.SecureLongEncoderTest.java
@Test public void testSecureLong() throws Exception { SecureLong.setEncoder(createSecureLongEncoder()); for (int i = 0; i < 100; i++) { Long plain = Long.valueOf(random.nextInt()); SecureLong ss0 = SecureLong.plainValueOf(plain); assertThat(ss0.plain(), is(plain)); assertThat(ss0.crypto(), is(not(plain.toString()))); SecureLong ss1 = SecureLong.cryptoValueOf(ss0.crypto()); assertThat(ss1.plain(), is(plain)); assertThat(ss1.crypto(), is(ss0.crypto())); SecureLong ss2 = SecureLong.plainValueOf(ss1.plain()); assertThat(ss2.plain(), is(plain)); assertThat(ss2.crypto(), is(ss0.crypto())); SecureLong ss3 = SecureLong.cryptoValueOf(ss2.crypto()); assertThat(ss3.plain(), is(plain)); assertThat(ss3.crypto(), is(ss0.crypto())); }/*from w w w.j a v a 2 s . c o m*/ }
From source file:com.glaf.activiti.util.ExtensionUtils.java
public static List<Object> getValues(Map<String, Object> paramMap, ExtensionEntity extension) { java.util.Date now = new java.util.Date(); List<Object> values = new java.util.ArrayList<Object>(); List<ExtensionParamEntity> x_params = extension.getParams(); Iterator<ExtensionParamEntity> iterator = x_params.iterator(); while (iterator.hasNext()) { ExtensionParamEntity param = iterator.next(); String key = param.getValue(); Object value = param.getValue(); if (key != null && value != null) { String tmp = param.getValue(); if (StringUtils.isNotEmpty(tmp)) { if (tmp.equals("now()")) { value = new java.sql.Date(now.getTime()); } else if (tmp.equals("date()")) { value = new java.sql.Date(now.getTime()); } else if (tmp.equals("time()")) { value = new java.sql.Time(now.getTime()); } else if (tmp.equals("timestamp()")) { value = new java.sql.Timestamp(now.getTime()); } else if (tmp.equals("dateTime()")) { value = new java.sql.Timestamp(now.getTime()); } else if (tmp.equals("currentTimeMillis()")) { value = Long.valueOf(System.currentTimeMillis()); } else if (tmp.equals("#{businessKey}")) { value = ParamUtils.getString(paramMap, "businessKey"); } else if (tmp.equals("#{processInstanceId}")) { value = ParamUtils.getString(paramMap, "processInstanceId"); } else if (tmp.equals("#{processName}")) { value = ParamUtils.getString(paramMap, "processName"); } else if (tmp.equals("#{status}")) { value = paramMap.get("status"); } else if (tmp.startsWith("#P{") && tmp.endsWith("}")) { tmp = StringTools.replaceIgnoreCase(tmp, "#P{", ""); tmp = StringTools.replaceIgnoreCase(tmp, "}", ""); value = paramMap.get(tmp); } else if (tmp.startsWith("#{") && tmp.endsWith("}")) { value = Mvel2ExpressionEvaluator.evaluate(tmp, paramMap); }/* www . ja va2 s . c o m*/ } } values.add(value); } return values; }
From source file:Main.java
public static String getPath(final Context context, final Uri uri) { final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; // DocumentProvider if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) { // ExternalStorageProvider if (isExternalStorageDocument(uri)) { final String docId = DocumentsContract.getDocumentId(uri); final String[] split = docId.split(":"); final String type = split[0]; if ("primary".equalsIgnoreCase(type)) { return Environment.getExternalStorageDirectory() + "/" + split[1]; }/*from w w w .j a v a 2 s . c o m*/ // TODO handle non-primary volumes } // DownloadsProvider else if (isDownloadsDocument(uri)) { final String id = DocumentsContract.getDocumentId(uri); final Uri contentUri = ContentUris .withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id)); return getDataColumn(context, contentUri, null, null); } // MediaProvider else if (isMediaDocument(uri)) { final String docId = DocumentsContract.getDocumentId(uri); final String[] split = docId.split(":"); final String type = split[0]; Uri contentUri = null; if ("image".equals(type)) { contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; } else if ("video".equals(type)) { contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; } else if ("audio".equals(type)) { contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; } final String selection = "_id=?"; final String[] selectionArgs = new String[] { split[1] }; return getDataColumn(context, contentUri, selection, selectionArgs); } } // MediaStore (and general) else if ("content".equalsIgnoreCase(uri.getScheme())) { return getDataColumn(context, uri, null, null); } // File else if ("file".equalsIgnoreCase(uri.getScheme())) { return uri.getPath(); } } return null; }
From source file:com.greenline.guahao.biz.manager.helpcenter.impl.HelpCenterManagerImpl.java
@Override public HelpCenterArticleDO getArticleById(String id) { if (StringUtils.isBlank(id)) { return null; }//w w w . ja v a 2 s .co m return helpCenterDAO.getArticleById(Long.valueOf(id)); }
From source file:me.repository.office.OfficeDao.java
public List<Office> findOfficesBy(String id) { DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Office.class); if (!StringUtils.isEmpty(id)) { detachedCriteria.add(Restrictions.eq("parentId", Long.valueOf(id))); } else {//from www .jav a 2s. c o m detachedCriteria.add(Restrictions.isNull("parentId")); } return find(detachedCriteria); }
From source file:com.grass.caishi.cc.utils.CommonUtils.java
public static String formatTime(long t) { if (String.valueOf(t).length() < 11) { t = Long.valueOf(t + "000"); }/*from w w w . java 2 s . c o m*/ long delta = new Date().getTime() - t; if (delta < 1L * ONE_MINUTE) { long seconds = toSeconds(delta); return (seconds <= 0 ? 1 : seconds) + ONE_SECOND_AGO; } if (delta < 45L * ONE_MINUTE) { long minutes = toMinutes(delta); return (minutes <= 0 ? 1 : minutes) + ONE_MINUTE_AGO; } if (delta < 24L * ONE_HOUR) { long hours = toHours(delta); return (hours <= 0 ? 1 : hours) + ONE_HOUR_AGO; } if (delta < 48L * ONE_HOUR) { return ""; } if (delta < 30L * ONE_DAY) { long days = toDays(delta); return (days <= 0 ? 1 : days) + ONE_DAY_AGO; } if (delta < 12L * 4L * ONE_WEEK) { long months = toMonths(delta); return (months <= 0 ? 1 : months) + ONE_MONTH_AGO; } else { long years = toYears(delta); return (years <= 0 ? 1 : years) + ONE_YEAR_AGO; } }
From source file:com.doculibre.constellio.wicket.panels.results.WebSearchResultPanel.java
public WebSearchResultPanel(String id, SolrDocument doc, final SearchResultsDataProvider dataProvider) { super(id, doc, dataProvider); String contentLength = (String) doc.getFieldValue("contentLength"); String type = (String) doc.getFieldValue("subType"); String contentLengthKBStr;// www .jav a 2 s . co m if (StringUtils.isNotBlank(contentLength)) { long contentLengthBytes; try { contentLengthBytes = Long.valueOf(contentLength); } catch (NumberFormatException e) { contentLengthBytes = -1; } double contentLengthKB = (double) contentLengthBytes / 1000; DecimalFormat contentLengthKBFormatter = new DecimalFormat(); contentLengthKBFormatter.setMinimumFractionDigits(0); contentLengthKBFormatter.setMaximumFractionDigits(0); contentLengthKBStr = contentLengthKBFormatter.format(contentLengthKB); if ("0".equals(contentLengthKBStr)) { contentLengthKBStr = null; } } else { contentLengthKBStr = null; } add(new Label("contentLength", contentLengthKBStr + " KB").setVisible(contentLengthKBStr != null)); add(new Label("type", type).setVisible(StringUtils.isNotBlank(type))); }
From source file:com.multimedia.service.counter.CmsCounterServiceImpl.java
@Override public Counter getInsertBean(Counter obj) { if (obj == null) obj = new Counter(); Long sort = (Long) service.getSinglePropertyU("max(sort)"); if (sort == null) sort = Long.valueOf(0); else//from www . ja va 2 s .c o m sort++; obj.setSort(sort); return obj; }
From source file:com.acc.storefront.controllers.pages.SearchPageControllerUnitTest.java
@Test public void testPagedDataFlagsCallShowAllOver100ResultsOneDefaultPage() { BDDMockito.given(Integer.valueOf(searchPageData.getPagination().getNumberOfPages())) .willReturn(Integer.valueOf(2)); BDDMockito.given(Long.valueOf(searchPageData.getPagination().getTotalNumberOfResults())) .willReturn(Long.valueOf(AbstractSearchPageController.MAX_PAGE_LIMIT + 1)); BDDMockito.given(Integer.valueOf(searchPageData.getPagination().getPageSize())) .willReturn(Integer.valueOf(DEFAULT_PAGE_SIZE)); controller.populateModel(model, searchPageData, ShowMode.Page); Mockito.verify(model).addAttribute("searchPageData", searchPageData); Mockito.verify(model).addAttribute("isShowAllAllowed", Boolean.FALSE); Mockito.verify(model).addAttribute("isShowPageAllowed", Boolean.FALSE); }
From source file:restApp.QuoteService.java
public ResponseIF listAuthors() { List<Author> list;//from w w w .j a va2 s . c om try { list = authorDAO.findAll(); } catch (RuntimeException ex) { return new ErrorResponse(ErrorCode.INTERNAL_SERVER_ERROR); } return new SuccessListResponse(list, Long.valueOf((long) list.size())); }