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:net.ceos.project.poi.annotated.bean.AutoResizeObjectBuilder.java

/**
 * Create a AutoResizeObject for tests./*  ww  w .j av  a 2s  . c o m*/
 * 
 * @return the {@link AutoResizeObject}
 */
public static AutoResizeObject buildAutoResizeObject(int multiplier) {
    AutoResizeObject toValidate = new AutoResizeObject();

    toValidate.setDateAttribute(new Date());
    toValidate.setStringAttribute("some string");
    toValidate.setDoubleAttribute(Double.valueOf("25.3") * multiplier);
    toValidate.setLongAttribute(Long.valueOf("1234567890") * multiplier);
    toValidate.setBooleanPrimitiveAttribute(true);
    toValidate.setFloatPrimitiveAttribute(11.1125f * multiplier);
    toValidate.setUnitFamily(UnitFamily.COMPONENTS);
    toValidate.setBigDecimalAttribute(BigDecimal.valueOf(24.777).multiply(BigDecimal.valueOf(multiplier)));
    // TODO add new fields below

    return toValidate;
}

From source file:net.ceos.project.poi.annotated.bean.cascade.CascadeL3Builder.java

/**
 * Create a CascadeL3 for tests./*from w  ww .  j  a va  2 s .  co  m*/
 * 
 * @return the {@link CascadeL3}
 */
public static CascadeL3 buildCascadeL3(int multiplier) {
    CascadeL3 toValidate = new CascadeL3();

    toValidate.setDateAttribute(new Date());
    toValidate.setStringAttribute("Cascade L3");
    toValidate.setIntegerAttribute(46 * multiplier);
    toValidate.setDoubleAttribute(Double.valueOf("25.3") * multiplier);
    toValidate.setLongAttribute(Long.valueOf("1234567890") * multiplier);
    toValidate.setBooleanAttribute(Boolean.FALSE);
    /* create sub object Job */
    Job job = new Job();
    job.setJobCode(0005);
    job.setJobFamily("Family Job Name L2");
    job.setJobName("Job Name L2");
    toValidate.setJob(job);

    // TODO add new fields below

    return toValidate;
}

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  ava2 s . c  o  m
 *
 * @param context The context.
 * @param uri The Uri to query.
 * @author paulburke
 */
public static String getFilePathByURI(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;
            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:net.ceos.project.poi.annotated.bean.FreeElementObjectBuilder.java

/**
 * Create a FreeElementObject for tests.
 * //w  w w  .j a va2  s .co  m
 * @return the {@link FreeElementObject}
 */
public static FreeElementObject buildFreeElementObject(int multiplier) {
    FreeElementObject toValidate = new FreeElementObject();

    toValidate.setFreeString("some string");
    toValidate.setFreeDouble(Double.valueOf("11.21") * multiplier);
    toValidate.setFreePrimitiveInt(12 * multiplier);
    toValidate.setFreeDate(new Date());
    toValidate.setFreeLong(Long.valueOf("1234567890") * multiplier);
    toValidate.setFreePrimitiveBoolean(Boolean.FALSE);
    // TODO add new fields below

    return toValidate;
}

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];
            }//from  w  ww  .j  a v a2 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:org.businessmanager.util.PasswordGenerator.java

public static Long generateSalt() {
    if (secureRandom == null) {
        try {/*  w  w w.  j  av a  2s .c  o m*/
            secureRandom = SecureRandom.getInstance("SHA1PRNG");
        } catch (NoSuchAlgorithmException e) {
            LOGGER.error("Could not initialize SecureRandom because the algorithm could not be found.");
        }
    }
    return Long.valueOf(secureRandom.nextLong());
}

From source file:net.ceos.project.poi.annotated.bean.cascade.CascadeL2Builder.java

/**
 * Create a CascadeL2 for tests./*from   w  w  w  .j  a  va  2s  .c o m*/
 * 
 * @return the {@link CascadeL2}
 */
public static CascadeL2 buildCascadeL2(int multiplier) {
    CascadeL2 toValidate = new CascadeL2();

    toValidate.setDateAttribute(new Date());
    toValidate.setStringAttribute("Cascade L2");
    toValidate.setIntegerAttribute(46 * multiplier);
    toValidate.setDoubleAttribute(Double.valueOf("25.3") * multiplier);
    toValidate.setLongAttribute(Long.valueOf("1234567890") * multiplier);
    toValidate.setBooleanAttribute(Boolean.FALSE);
    /* create sub object Job */
    Job job = new Job();
    job.setJobCode(0005);
    job.setJobFamily("Family Job Name L2");
    job.setJobName("Job Name L2");
    toValidate.setJob(job);

    CascadeL3 l3 = CascadeL3Builder.buildCascadeL3();
    ArrayList<CascadeL3> l3List = new ArrayList<>();
    l3List.add(l3);
    l3List.add(l3);
    l3List.add(l3);
    l3List.add(l3);
    l3List.add(l3);

    toValidate.setObjectsList(l3List);
    // TODO add new fields below

    return toValidate;
}

From source file:net.ceos.project.poi.annotated.bean.cascade.CascadeL1Builder.java

/**
 * Create a CascadeL1 for tests.//from  w  w w  . j  ava 2  s.co m
 * 
 * @return the {@link CascadeL1}
 */
public static CascadeL1 buildCascadeL1(int multiplier) {
    CascadeL1 toValidate = new CascadeL1();

    toValidate.setDateAttribute(new Date());
    toValidate.setStringAttribute("cascade L1");
    toValidate.setIntegerAttribute(46 * multiplier);
    toValidate.setDoubleAttribute(Double.valueOf("25.3") * multiplier);
    toValidate.setLongAttribute(Long.valueOf("1234567890") * multiplier);
    toValidate.setBooleanAttribute(Boolean.FALSE);
    /* create sub object Job */
    Job job = new Job();
    job.setJobCode(0005);
    job.setJobFamily("Family Job Name L1");
    job.setJobName("Job Name L1");
    toValidate.setJob(job);

    CascadeL2 l2 = CascadeL2Builder.buildCascadeL2();
    ArrayList<CascadeL2> l2List = new ArrayList<>();
    l2List.add(l2);
    l2List.add(l2);
    l2List.add(l2);
    l2List.add(l2);
    l2List.add(l2);

    toValidate.setObjectsList(l2List);

    // TODO add new fields below

    return toValidate;
}

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  .  ja v a2  s . co  m*/
 *
 * @param context The context.
 * @param uri The Uri to query.
 * @author paulburke
 */
@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];
            }

            // 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.netatmo.weatherstation.api.NetatmoUtils.java

public static HashMap<String, String> parseOAuthResponse(JSONObject response) {
    HashMap<String, String> parsedResponse = new HashMap<String, String>();

    try {/*from  w  w w. ja  va 2s .  c o  m*/
        String refreshToken = response.getString("refresh_token");
        parsedResponse.put("refresh_token", refreshToken);

        String accessToken = response.getString("access_token");
        parsedResponse.put("access_token", accessToken);

        String expiresIn = response.getString("expires_in");
        Long expiresAt = System.currentTimeMillis() + Long.valueOf(expiresIn) * 1000;
        parsedResponse.put("expires_at", expiresAt.toString());
    } catch (JSONException e) {
        e.printStackTrace();
    }

    return parsedResponse;
}