Example usage for java.lang Long valueOf

List of usage examples for java.lang Long valueOf

Introduction

In this page you can find the example usage for java.lang Long valueOf.

Prototype

@HotSpotIntrinsicCandidate
public static Long valueOf(long l) 

Source Link

Document

Returns a Long instance representing the specified long value.

Usage

From source file:Main.java

/**
 * Get a file path from a Uri. This will get the the path for Storage Access
 * Framework Documents, as well as the _data field for the MediaStore and
 * other file-based ContentProviders./*from  ww  w  . j ava  2 s  .c  o m*/
 * https://stackoverflow.com/questions/20067508/get-real-path-from-uri-android-kitkat-new-storage-access-framework/20402190?noredirect=1#comment30507493_20402190
 *
 * @param context The context.
 * @param uri The Uri to query.
 */
@TargetApi(19)
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];
            }

            // 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;
            switch (type) {
            case "image":
                contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
                break;
            case "video":
                contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
                break;
            case "audio":
                contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
                break;
            }

            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:me.xiaopan.android.gohttp.header.ContentLength.java

public long getLength() {
    return Long.valueOf(getValue());
}

From source file:com.devnexus.ting.web.converter.StringToSkillLevel.java

@Override
public SkillLevel convert(String source) {

    if (StringUtils.isEmpty(source) || !StringUtils.isNumeric(source)) {
        return null;
    } else {/*w  w  w . j a v a  2  s. c  o  m*/
        return SkillLevel.fromId(Long.valueOf(source));
    }

}

From source file:io.github.sparta.helpers.date.DateUtil.java

/**
 * get the time in long format : "yyyyMMddHHmmss".
 * //from   w  ww  .j a  v  a 2s .c  o m
 * @param date
 *            date to be format
 * @return time time in format of long type
 */
public static long getCollectTimeInLong(Date date) {
    SimpleDateFormat collectTimeFormat = new SimpleDateFormat("yyyyMMddHHmmss");
    return Long.valueOf(collectTimeFormat.format(date));
}

From source file:com.nebhale.cyclinglibrary.web.json.CollectionJsonSerializerTest.java

@Override
protected Collection getValue() {
    return new Collection(Long.valueOf(0), Long.valueOf(1), "test-name", "test-short-name", Long.valueOf(2),
            Long.valueOf(3));//from   ww  w.j a  va  2 s  . c o m
}

From source file:core.controller.KategoriController.java

@RequestMapping(value = "/update", method = RequestMethod.POST)
public String update(HttpServletRequest request) {
    long id = Long.valueOf(request.getParameter("txtId"));
    String kode = request.getParameter("txtKode");
    String nama = request.getParameter("txtNama");
    Kategori kat = new Kategori();
    kat.setId(id);//from   w  w w  .java 2  s . com
    kat.setKode(kode);
    kat.setNama(nama);
    kategoriDAO.update(kat);
    return "redirect:/kategori";
}

From source file:com.nebhale.cyclinglibrary.web.json.TaskJsonSerializerTest.java

@Override
protected Task getValue() {
    return new Task(Long.valueOf(0), Status.IN_PROGRESS, "test-message");
}

From source file:org.dswarm.graph.json.Node.java

@JsonCreator
public Node(@JsonProperty("id") final long idArg) {

    id = Long.valueOf(idArg);
    type = NodeType.BNode;
}

From source file:com.best.otp.CLeglegGeometry.java

void getLegGeometry() {
    if (m_legJsonObject != null) {
        legLegGeometryObject = m_legJsonObject.get("legGeometry");
        if (legLegGeometryObject != null) {
            JSONObject legLegGeometryJsonObject = (JSONObject) legLegGeometryObject;
            if (legLegGeometryJsonObject.get("points") != null)
                legLegGeometryPoints = legLegGeometryJsonObject.get("points").toString();
            legLegGeometrylevels = legLegGeometryJsonObject.get("levels");
            if (legLegGeometryJsonObject.get("length") != null)
                legLegGeometrylength = Long.valueOf(legLegGeometryJsonObject.get("length").toString());
        }//from   w  w  w . j  av  a  2s  .  co  m
    }
}

From source file:com.devnexus.ting.web.converter.StringToSponsorLevel.java

@Override
public SponsorLevel convert(String source) {
    if (StringUtils.isEmpty(source) || !StringUtils.isNumeric(source)) {
        return null;
    } else {//from   w w w.j  ava  2s.co  m
        return SponsorLevel.fromId(Long.valueOf(source));
    }
}