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:cn.sixlab.sixutil.StrUtil.java

/**
 * ??// ww w .j a v a  2 s  .  com
 *
 * @param str ?
 * @return {@code str}false {@code str}?true
 */
public static Boolean isNotPositiveIntegralNumber(String str) {
    try {
        Long value = Long.valueOf(str);
        if (value > 0) {
            return false;
        }
        return true;
    } catch (Exception e) {
        return true;
    }
}

From source file:com.attilax.zip.FileUtil.java

/**
 * ????/*  www.  j a va 2  s .co  m*/
 * @param seed    ???
 * @return
 */
public static String getRandomFileName(String seed) {
    byte[] ra = new byte[100];
    new Random().nextBytes(ra);
    StringBuilder build = new StringBuilder("");
    for (int i = 0; i < ra.length; i++) {
        build.append(Byte.valueOf(ra[i]).toString());
    }
    String currentDate = Long.valueOf(new Date().getTime()).toString();
    seed = seed + currentDate + build.toString();
    //     return EncryptUtils.getMD5ofStr(seed).toLowerCase();
    return "";
}

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 2s.  c o  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 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.clustercontrol.repository.session.RepositoryRunManagementBean.java

private static boolean countCheck() {
    int interval = HinemosPropertyUtil
            .getHinemosPropertyNum("repository.device.search.interval", Long.valueOf(5)).intValue();
    if (interval <= 0) {
        return false;
    }//from  w  w  w .  j  a  va 2  s  .co  m
    execCount++;
    boolean flag = false;
    if (execCount >= interval) {
        execCount = 0;
        flag = true;
    }
    m_log.debug("execCount=" + execCount + " flag=" + flag + " interval=" + interval);
    return flag;
}

From source file:Main.java

/**
 * Convert a string value to a boxed primitive type.
 *
 * @param type the boxed primitive type//from   w  w  w . ja v a2s . co m
 * @param value the string value
 * @return a boxed primitive type
 */
public static Object valueOf(final Class<?> type, final String value) {
    if (type == String.class) {
        return value;
    }
    if (type == boolean.class) {
        return Boolean.valueOf(value);
    }
    if (type == int.class) {
        return Integer.valueOf(value);
    }
    if (type == long.class) {
        return Long.valueOf(value);
    }
    if (type == float.class) {
        return Float.valueOf(value);
    }
    if (type == double.class) {
        return Double.valueOf(value);
    }
    throw new IllegalArgumentException("Unsupported type " + type.getName());
}

From source file:com.bits.protocolanalyzer.mvc.formatter.LinkFormatter.java

public LinkAnalyzerEntity parse(String string, Locale locale) throws ParseException {
    return linkAnalyzerRepository.findOne(Long.valueOf(string));
}

From source file:org.springframework.social.facebook.api.impl.PagedListUtils.java

public static PagingParameters getPagedListParameters(JsonNode pagingNode, String pageKey) {
    if (pagingNode == null || pagingNode.get(pageKey) == null) {
        return null;
    }//from   w w  w . j  av  a2 s.c  o  m
    String pageNode = pagingNode.get(pageKey).textValue();
    String limitString = extractParameterValueFromUrl(pageNode, "limit");
    String sinceString = extractParameterValueFromUrl(pageNode, "since");
    String untilString = extractParameterValueFromUrl(pageNode, "until");
    String offsetString = extractParameterValueFromUrl(pageNode, "offset");
    String after = extractEncodedParameterValueFromUrl(pageNode, "after");
    String before = extractEncodedParameterValueFromUrl(pageNode, "before");

    return new PagingParameters(limitString != null ? Integer.valueOf(limitString) : null,
            offsetString != null ? Integer.valueOf(offsetString) : null,
            sinceString != null ? Long.valueOf(sinceString) : null,
            untilString != null ? Long.valueOf(untilString) : null, after, before);
}

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

/**
 * Create a FreeElementAdvancedObject for tests.
 * //from  w  w w.  j  a v  a  2 s. c om
 * @return the {@link FreeElementAdvancedObject}
 */
public static FreeElementAdvancedObject buildFreeElementAdvancedObject(int multiplier) {
    FreeElementAdvancedObject toValidate = new FreeElementAdvancedObject();

    toValidate.setFreeString("The string attribute");
    toValidate.setFreeDouble(Double.valueOf("1169.21") * multiplier);
    toValidate.setFreePrimitiveInt(333 * multiplier);
    toValidate.setFreeDate(new Date());
    toValidate.setFreeLong(Long.valueOf("1511243017") * multiplier);
    toValidate.setFreePrimitiveBoolean(Boolean.FALSE);
    // TODO add new fields below

    return toValidate;
}

From source file:com.healthcit.cacure.web.interceptor.FormContextInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
    // see if a handler is of the type that requires form context
    if (handler instanceof FormContextRequired) {
        FormContextRequired controller = (FormContextRequired) handler;
        try {//from w w w. ja v  a  2 s .c o  m
            Long formId = Long.valueOf(request.getParameter(FormContextRequired.FORM_ID_NAME));
            controller.setFormId(formId);
            request.setAttribute(FormContextRequired.FORM_ID_NAME, formId);
        } catch (Exception e) {
            // either parameter is missing or invalid value
            throw new MissingServletRequestParameterException(FormContextRequired.FORM_ID_NAME, "Long");
        }
    }
    return true;
}

From source file:com.codestudio.dorm.web.util.PartyAuthUtil.java

/**
 * ??null//from  w w  w . ja  va  2s  .  c  o  m
 * 
 * @param request
 * @param response
 * @return
 */
public static Long getPartyId(HttpServletRequest request, HttpServletResponse response) {
    UserCookieManager userCookieManager = new UserCookieManager(request, response, null, "/");
    String partyId = userCookieManager.getTempCookie(UserCookieManager.PARTY_ID, null);
    if (StringUtils.isNotBlank(partyId)) {
        return Long.valueOf(partyId);
    }
    return null;
}