Example usage for java.lang Long toString

List of usage examples for java.lang Long toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a String object representing this Long 's value.

Usage

From source file:edu.pitt.dbmi.facebase.hd.HumanDataController.java

/** generates and returns one-time-password 
 * OTP is a long sent to Hub demonstrating that http request is legit, Hub checks it against 
 * This should thwart any bogus/malicious but similar HTTP requests from Internet, since bogus 
 * requesters won't be able to generate a hash that passes muster...Hub ignores requests with bad OTP
 * @return code, based on current time//from   w  w w  .  j  av a  2s .c  o  m
 */
public static long getOTP() {
    long w = 100;
    long t = System.currentTimeMillis() / 1000;
    long r = (long) Math.floor(t / w) * w;
    long s = 0;
    Long rLong = new Long(r);
    String sString = rLong.toString();
    for (int i = 0; i < sString.length(); i++) {
        char aChar = sString.charAt(i);
        String oneCharString = Character.toString(aChar);
        s += Integer.parseInt(oneCharString);
    }
    long p = (long) Math.pow(s, 5);
    return (r % p);
}

From source file:mvm.rya.accumulo.pig.AccumuloStorage.java

private static byte[] objToBytes(Object o) {
    if (o instanceof String) {
        String str = (String) o;
        return str.getBytes();
    } else if (o instanceof Long) {
        Long l = (Long) o;
        return l.toString().getBytes();
    } else if (o instanceof Integer) {
        Integer l = (Integer) o;
        return l.toString().getBytes();
    } else if (o instanceof Boolean) {
        Boolean l = (Boolean) o;
        return l.toString().getBytes();
    } else if (o instanceof Float) {
        Float l = (Float) o;
        return l.toString().getBytes();
    } else if (o instanceof Double) {
        Double l = (Double) o;
        return l.toString().getBytes();
    }//w  w  w. j a v  a2  s  . c  o  m

    // TODO: handle DataBag, Map<Object, Object>, and Tuple

    return ((DataByteArray) o).get();
}

From source file:com.facebook.ads.sdk.Domain.java

public static Domain fetchById(Long id, APIContext context) throws APIException {
    return fetchById(id.toString(), context);
}

From source file:com.facebook.ads.sdk.AdsDataPartner.java

public static AdsDataPartner fetchById(Long id, APIContext context) throws APIException {
    return fetchById(id.toString(), context);
}

From source file:com.facebook.ads.sdk.ExternalEventSource.java

public static ExternalEventSource fetchById(Long id, APIContext context) throws APIException {
    return fetchById(id.toString(), context);
}

From source file:com.taobao.ad.easyschedule.commons.utils.JobUtil.java

/**
 * ?URL//from www .jav  a 2s  . c o m
 * 
 * @param jobId
 * @param jobDetail
 * @param baseUrl
 * @return
 * @throws UnsupportedEncodingException
 */
public static String getJobTargetUrl(Long jobId, JobDetail jobDetail, String baseUrl)
        throws UnsupportedEncodingException {
    String jobClass = jobDetail.getJobClass().getName();
    JobDataMap data = jobDetail.getJobDataMap();
    Long currentTime = System.currentTimeMillis() / 1000;
    String token = TokenUtils.generateToken(currentTime.toString());
    StringBuffer targetUrl = new StringBuffer();
    targetUrl.append(baseUrl);
    targetUrl.append(baseUrl.contains("?") ? "&" : "?");
    targetUrl.append(Const.JOBID).append("=").append(jobId);
    targetUrl.append("&").append(Const.JOBGROUP).append("=").append(jobDetail.getGroup());
    targetUrl.append("&").append(Const.JOBNAME).append("=")
            .append(URLEncoder.encode(jobDetail.getName(), "utf-8"));
    targetUrl.append("&").append(Const.SIGNTIME).append("=").append(currentTime.toString());
    targetUrl.append("&").append(Const.TOKEN).append("=").append(token);
    targetUrl.append("&").append(Const.CLIENTRETRIES).append("=")
            .append(HttpJobUtils.getJobClientRetries(data.getString(Constants.JOBDATA_CLIENTRETRIES)));
    targetUrl.append("&").append(Const.SYNC).append("=").append(data.getString(Constants.JOBDATA_SYNCHRONOUS));
    targetUrl.append("&").append(Const.CALLBACKURL).append("=")
            .append(URLEncoder.encode(Constants.CALLBACKURL, "utf-8"));
    targetUrl.append("&").append(Const.CALLBACKURLS).append("=")
            .append(URLEncoder.encode(Constants.CALLBACKURLS, "utf-8"));
    if (HttpJob.class.getName().equals(jobClass)) {
        String parameter = data.getString(Constants.JOBDATA_PARAMETER);
        if (StringUtils.isNotBlank(parameter)) {
            parameter = URLEncoder.encode(parameter, "utf-8");
            targetUrl.append("&").append(Const.PARAMETER).append("=").append(parameter);
        }
    } else if (ShellJob.class.getName().equals(jobClass)) {
        String jobCommand = data.getString(Constants.JOBDATA_JOBCOMMAND);
        if (StringUtils.isNotBlank(jobCommand)) {
            jobCommand = URLEncoder.encode(jobCommand, "utf-8");
            targetUrl.append("&").append(Const.JOBCOMMAND).append("=").append(jobCommand);
        }
    } else if (FileLineCountJob.class.getName().equals(jobClass)) {
        String fileFullName = data.getString(Constants.JOBDATA_FILEFULLNAME);
        if (StringUtils.isNotBlank(fileFullName)) {
            fileFullName = URLEncoder.encode(fileFullName, "utf-8");
            targetUrl.append("&").append(Const.FILEFULLNAME).append("=").append(fileFullName);
        }
    } else if (DataTrackingJob.class.getName().equals(jobClass)) {
        String trackingSql = data.getString(Constants.JOBDATA_TRACKINGSQL);
        if (StringUtils.isNotBlank(trackingSql)) {
            trackingSql = URLEncoder.encode(trackingSql, "utf-8");
            targetUrl.append("&").append(Const.TRACKINGSQL).append("=").append(trackingSql);
        }
        String dataSource = data.getString(Constants.JOBDATA_DATASOURCE);
        if (StringUtils.isNotBlank(dataSource)) {
            dataSource = URLEncoder.encode(dataSource, "utf-8");
            targetUrl.append("&").append(Const.DATASOURCE).append("=").append(dataSource);
        }
        String dataSourceType = data.getString(Constants.JOBDATA_DATASOURCETYPE);
        if (StringUtils.isNotBlank(dataSourceType)) {
            dataSourceType = URLEncoder.encode(dataSourceType, "utf-8");
            targetUrl.append("&").append(Const.DATASOURCETYPE).append("=").append(dataSourceType);
        }
    } else if (StoredProcedureJob.class.getName().equals(jobClass)) {
        String parameter = data.getString(Constants.JOBDATA_PARAMETER);
        if (StringUtils.isNotBlank(parameter)) {
            parameter = URLEncoder.encode(parameter, "utf-8");
            targetUrl.append("&").append(Const.PARAMETER).append("=").append(parameter);
        }
        String storedProcedureCall = data.getString(JobData.JOBDATA_DATA_STOREDPROCEDURECALL);
        if (StringUtils.isNotBlank(storedProcedureCall)) {
            storedProcedureCall = URLEncoder.encode(storedProcedureCall, "utf-8");
            targetUrl.append("&").append(Const.STOREDPROCEDURECALL).append("=").append(storedProcedureCall);
        }
        String dataSource = data.getString(Constants.JOBDATA_DATASOURCE);
        if (StringUtils.isNotBlank(dataSource)) {
            dataSource = URLEncoder.encode(dataSource, "utf-8");
            targetUrl.append("&").append(Const.DATASOURCE).append("=").append(dataSource);
        }
        String dataSourceType = data.getString(Constants.JOBDATA_DATASOURCETYPE);
        if (StringUtils.isNotBlank(dataSourceType)) {
            dataSourceType = URLEncoder.encode(dataSourceType, "utf-8");
            targetUrl.append("&").append(Const.DATASOURCETYPE).append("=").append(dataSourceType);
        }
    }
    return targetUrl.toString();
}

From source file:com.facebook.ads.sdk.ProductFeedUploadErrorSample.java

public static ProductFeedUploadErrorSample fetchById(Long id, APIContext context) throws APIException {
    return fetchById(id.toString(), context);
}

From source file:edu.pitt.dbmi.facebase.hd.HumanDataController.java

/** http web client class used for communicating with Hub 
 * @param action String is one of status, update, event
 * @param signal String is a timeInSeconds or QueueID or eventCode
 * for action=status, signal is "0", number-of-seconds-until-back, 
 * for action=update, signal is qid.hash
 * for action=event, signal "1" means mysql server is unavailable.
 * uses getOTP() method for URL construction
 *//*from w w w  . ja v a 2  s .co m*/
public static void httpGetter(String action, String signal) {
    String oneTimePassword = (new Long(getOTP())).toString();
    String url = hubURL + responseTrigger + oneTimePassword + "/";
    if (action == "update") {
        url += action + "/" + signal;
    } else if (action == "status") {
        long time = System.currentTimeMillis() / 1000L;
        time += Long.parseLong(signal);
        Long timeLong;
        timeLong = new Long(time);
        url += action + "/" + timeLong.toString();
    } else if (action == "event") {
        url += action + "/" + signal;
    } else {
    }
    HttpClient webClient = new HttpClient();
    HttpMethod httpMethod = new GetMethod(url);
    try {
        webClient.executeMethod(httpMethod);
        String response = httpMethod.getResponseBodyAsString();
    } catch (HttpException httpe) {
    } catch (IOException ioe) {
    } finally {
        httpMethod.releaseConnection();
        httpMethod.recycle();
    }
}

From source file:com.sun.identity.openid.provider.Codec.java

/**
 * TODO: Description./*from  ww  w  . ja  v a 2s . co  m*/
 * 
 * @param value
 *            TODO.
 * @return TODO.
 */
public static String encodeLong(Long value) {
    if (value == null) {
        return null;
    }

    return value.toString();
}

From source file:com.aurel.track.dbase.InitReportTemplateBL.java

public static void addReportTemplates() {
    URL urlSrc;//w  ww  .j  a v  a2  s  .  co m
    File srcDir = null;
    //first try to get the template dir through class.getResource(path)
    urlSrc = PluginUtils.class.getResource("/resources/reportTemplates");
    urlSrc = PluginUtils.createValidFileURL(urlSrc);
    if (urlSrc != null) {
        LOGGER.info("Retrieving report templates from " + urlSrc.toString());
        srcDir = new File(urlSrc.getPath());
        Long uuid = new Date().getTime();
        File tmpDir = new File(
                System.getProperty("java.io.tmpdir") + File.separator + "TrackTmp" + uuid.toString());
        if (!tmpDir.isDirectory()) {
            tmpDir.mkdir();
        }
        tmpDir.deleteOnExit();

        File[] files = srcDir.listFiles(new InitReportTemplateBL.Filter());
        if (files == null || files.length == 0) {
            LOGGER.error("Problem unzipping report template: No files.");
            return;
        }
        for (int index = 0; index < files.length; index++) {
            ZipFile zipFile = null;
            try {
                String sname = files[index].getName();
                String oid = sname.substring(sname.length() - 6, sname.length() - 4);
                zipFile = new ZipFile(files[index], ZipFile.OPEN_READ);
                LOGGER.debug("Extracting template from " + files[index].getName());
                unzipFileIntoDirectory(zipFile, tmpDir);

                File descriptor = new File(tmpDir, "description.xml");
                InputStream in = new FileInputStream(descriptor);
                //parse using builder to get DOM representation of the XML file
                Map<String, Object> desc = ReportBL.getTemplateDescription(in);

                String rname = "The name";
                String description = "The description";
                String expfmt = (String) desc.get("format");

                Map<String, String> localizedStuff = (Map<String, String>) desc
                        .get("locale_" + Locale.getDefault().getLanguage());
                if (localizedStuff != null) {
                    rname = localizedStuff.get("listing");
                    description = localizedStuff.get("description");
                } else {
                    localizedStuff = (Map<String, String>) desc.get("locale_en");
                    rname = localizedStuff.get("listing");
                    description = localizedStuff.get("description");
                }

                addReportTemplateToDatabase(new Integer(oid), rname, expfmt, description);

            } catch (IOException e) {
                LOGGER.error("Problem unzipping report template " + files[index].getName());
                LOGGER.debug(ExceptionUtils.getStackTrace(e));
            }
        }
    }
}