List of usage examples for java.lang Long valueOf
@HotSpotIntrinsicCandidate public static Long valueOf(long l)
From source file:Main.java
@SuppressLint("NewApi") public static String getRealPath(Context context, Uri uri) { final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) { if (URI_EXTERNAL_DOCUMENTS.equals(uri.getAuthority())) { 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]; }// ww w .j a v a2 s . co m } else if (URI_DOWNLOAD_DOCUMENTS.equals(uri.getAuthority())) { 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); } else if (URI_MEDIA_DOCUMENTS.equals(uri.getAuthority())) { 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); } } else if ("content".equalsIgnoreCase(uri.getScheme())) { if (URI_GOOGLE_PHOTOS.equals(uri.getAuthority())) return uri.getLastPathSegment(); return getDataColumn(context, uri, null, null); } else if ("file".equalsIgnoreCase(uri.getScheme())) { return uri.getPath(); } return null; }
From source file:org.vader.common.spring.redis.LongRedisSerializer.java
@Override public Long deserialize(byte[] bytes) throws SerializationException { return bytes == null ? null : Long.valueOf(stringRedisSerializer.deserialize(bytes)); }
From source file:com.player.lib.protocol.transfer.FileTransferInfo.java
/** * @fn parse(String data)/* w ww.j av a2 s. c o m*/ * @brief Obtengo a partir de un string la informacion solicitada * @param data * @return FileTransferInfo */ public static FileTransferInfo parse(String data) { try { //Creo un objeto FileTransferInfo info = new FileTransferInfo(); String[] components = data.split(SEPARATOR); if (components.length <= 3 && components.length != 0) { for (String component : components) { String key = component.substring(0, component.indexOf("=")); switch (key) { case ID: info.id = Long.valueOf(component.substring(component.indexOf("=") + 1, component.length())); break; case INDEX: info.index = Long .valueOf(component.substring(component.indexOf("=") + 1, component.length())); break; case BYTES_TO_READ: info.bytesToRead = Long .valueOf(component.substring(component.indexOf("=") + 1, component.length())); break; } } } return info; } catch (Exception e) { System.out.println("FileTransferInfo.parse.error: " + e.getMessage()); } return null; }
From source file:de.u808.simpleinquest.web.usermanagement.UserEditController.java
@Override protected Object formBackingObject(HttpServletRequest request) throws Exception { if (StringUtils.isNotEmpty(request.getParameter("id"))) { return userManager.fetchUser(Long.valueOf(request.getParameter("id"))); } else/*from w w w .j a v a2s . c o m*/ return super.formBackingObject(request); }
From source file:com.thoughtworks.studios.journey.jql.conditions.IntValue.java
public IntValue(String val) { this.val = Long.valueOf(val); }
From source file:br.com.ingenieux.mojo.jbake.WatchMojo.java
public void executeInternal() throws MojoExecutionException { reRender();/* w w w. ja v a 2s . c om*/ Long lastProcessed = Long.valueOf(System.currentTimeMillis()); getLog().info("Now listening for changes on path " + inputDirectory.getPath()); initServer(); DirWatcher dirWatcher = null; try { dirWatcher = new DirWatcher(inputDirectory); final AtomicBoolean done = new AtomicBoolean(false); final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); (new Thread() { @Override public void run() { try { getLog().info("Running. Enter a blank line to finish. Anything else forces re-rendering."); while (true) { String line = reader.readLine(); if (isBlank(line)) { break; } reRender(); } } catch (Exception exc) { getLog().info("Ooops", exc); } finally { done.set(true); } } }).start(); dirWatcher.start(); do { Long result = dirWatcher.processEvents(); if (null == result) { // do nothing on purpose } else if (result >= lastProcessed) { getLog().info("Refreshing"); super.reRender(); lastProcessed = Long.valueOf(System.currentTimeMillis()); } } while (!done.get()); } catch (Exception exc) { getLog().info("Oops", exc); throw new MojoExecutionException("Oops", exc); } finally { getLog().info("Finishing"); if (null != dirWatcher) dirWatcher.stop(); stopServer(); } }
From source file:Main.java
@SuppressLint("NewApi") public static String getRealPathFromURI_API11_And_Above(final Context context, final Uri uri) { final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; // DocumentProvider 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.ja 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 the remote address if (isGooglePhotosUri(uri)) return uri.getLastPathSegment(); return getDataColumn(context, uri, null, null); } // File else if ("file".equalsIgnoreCase(uri.getScheme())) { return uri.getPath(); } return null; }
From source file:org.syncope.core.util.EntitlementUtil.java
public static Long getRoleId(final String entitlementName) { Long result = null;/*from w ww .jav a 2 s. com*/ if (isRoleEntitlement(entitlementName)) { try { result = Long.valueOf(entitlementName.substring(entitlementName.indexOf("_") + 1)); } catch (Throwable t) { } } return result; }
From source file:com.acc.fulfilmentprocess.strategy.impl.SplitByAvailableCount.java
@Override public Object getGroupingObject(final AbstractOrderEntryModel orderEntry) { if (orderEntry.getDeliveryPointOfService() != null) { final Long stock = getCommerceStockService().getStockLevelForProductAndPointOfService( orderEntry.getProduct(), orderEntry.getDeliveryPointOfService()); return Boolean.valueOf(stock == null || stock.longValue() >= orderEntry.getQuantity().longValue()); } else {/*from ww w. j a va2 s . c o m*/ Long stock = Long.valueOf(0); if (orderEntry.getOrder().getStore() != null) { stock = getCommerceStockService().getStockLevelForProductAndBaseStore(orderEntry.getProduct(), orderEntry.getOrder().getStore()); } return Boolean.valueOf(stock == null || stock.longValue() >= orderEntry.getQuantity().longValue()); } }
From source file:csns.web.editor.UserPropertyEditor.java
@Override public void setAsText(String text) throws IllegalArgumentException { if (StringUtils.hasText(text)) setValue(userDao.getUser(Long.valueOf(text))); }