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 getPath(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]; }// w ww.j a va 2 s . com // 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:com.gst.infrastructure.core.api.ApiParameterHelper.java
public static Long commandId(final MultivaluedMap<String, String> queryParams) { Long id = null;//from ww w . java 2 s . c om if (queryParams.getFirst("commandId") != null) { final String value = queryParams.getFirst("commandId"); if (StringUtils.isNotBlank(value)) { id = Long.valueOf(value); } } return id; }
From source file:org.zht.framework.util.ZBeanUtil.java
public static Long parseLong(Object value) { try {// www . j a va 2 s. co m return Long.valueOf("" + value); } catch (Exception e) { return null; } }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.KITKAT) public static String getFilePath(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 ("com.android.externalStorage.documents".equalsIgnoreCase(uri.getAuthority())) { final String docId = DocumentsContract.getDocumentId(uri); final String[] split = docId.split(":"); final String type = split[0]; if ("primary".equalsIgnoreCase(type) || "content".equalsIgnoreCase(uri.getScheme())) { return Environment.getExternalStorageDirectory() + "/" + split[1]; }/* w ww. ja va 2s. c o m*/ } // DownloadsProvider else if ("com.android.providers.downloads.documents".equalsIgnoreCase(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); } // MediaProvider else if ("com.android.providers.media.documents".equalsIgnoreCase(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); } } // 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 ""; }
From source file:mtmo.test.mediadrm.Utils.java
public static String accountIdToMarlinFormat(final String accountId) { ByteBuffer accountIdBuf = ByteBuffer.allocate(BYTES_OF_ACCOUNT_ID); try {/*from ww w . j av a 2 s . c om*/ accountIdBuf.putLong(Long.valueOf(accountId)); } catch (Exception e) { return null; } accountIdBuf.order(ByteOrder.LITTLE_ENDIAN); return String.format(Locale.US, "%016x", accountIdBuf.getLong(0)); }
From source file:jp.co.nemuzuka.utils.ConvertUtils.java
/** * String?Long??./* ww w . j av a 2s . c o m*/ * @param targets ?? * @return ?Long?(???null???0??) */ public static Long[] convert(String[] targets) { if (targets == null) { return new Long[0]; } List<Long> list = new ArrayList<Long>(); for (String target : targets) { list.add(Long.valueOf(target)); } return list.toArray(new Long[0]); }
From source file:com.marc.lastweek.extractionengine.adapters.EbayAdAdapter.java
public final static NewExternalClassifiedAdTO adapt(EbayAd ebayAd) { long categoryId = EBAY_PISOS_CATEGORIES_TO_LASTWEEK_CATEGORIES[ArrayUtils.indexOf(EBAY_PISOS_CATEGORIES, ebayAd.getCategory().trim())]; Double price = null;/* w w w . j a v a2 s.c om*/ try { price = Double.valueOf(ebayAd.getPrice().replaceFirst("EUR", "")); } catch (Exception e) { price = Double.valueOf(0); } Long provinceId = Long.valueOf(1); return new NewExternalClassifiedAdTO(Long.valueOf(categoryId), null, price, ebayAd.getTitle(), ebayAd.getDescription(), null, null, provinceId, Integer.valueOf(ClassifiedAd.SOURCE_EBAY), ebayAd.getUrl(), Integer.valueOf(0), Integer.valueOf(ClassifiedAd.STATE_ACTIVE)); }
From source file:Main.java
/** * Get the file path from the given Uri. * * @param context The context of the calling activity. * @param uri The Uri whose file path is returned. *//*from ww w.ja v a 2s.co m*/ @TargetApi(Build.VERSION_CODES.KITKAT) public static String getFilePathFromUri(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]; } } // 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.alibaba.doris.admin.service.impl.ValueParseUtil.java
/** * ?,?,/*from w w w .j a v a 2s .c o m*/ * * @param clazz * @return */ @SuppressWarnings("unchecked") private static <T> T getInternalDefaultValue(Class<T> clazz) { if (!clazz.isPrimitive()) { return null; } if (Short.TYPE.equals(clazz)) { return (T) Short.valueOf((short) 0); } if (Integer.TYPE.equals(clazz)) { return (T) Integer.valueOf(0); } if (Long.TYPE.equals(clazz)) { return (T) Long.valueOf(0); } if (Boolean.TYPE.equals(clazz)) { return (T) Boolean.valueOf(false); } if (Float.TYPE.equals(clazz)) { return (T) Float.valueOf(0); } if (Double.TYPE.equals(clazz)) { return (T) Double.valueOf(0); } if (Byte.TYPE.equals(clazz)) { return (T) Byte.valueOf((byte) 0); } if (Character.TYPE.equals(clazz)) { return (T) Character.valueOf('\0'); } return null; }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.KITKAT) public static String getPath(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]; }//w w w. j ava 2s . co 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; }