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:cz.jirutka.spring.http.client.cache.CachingHttpRequestInterceptor.java

protected ClientHttpResponse createResponse(CacheEntry entry) {
    ClientHttpResponse response = entry.getResponse();

    Long age = (currentDate().getTime() - entry.getResponseCreated().getTime()) / 1000L;
    response.getHeaders().set("Age", age.toString());

    return response;
}

From source file:de.lgblaumeiser.ptm.store.filesystem.FileStore.java

private File getFileInformation(final Long index) {
    File store = getStore();/*  w  w  w.  j a  va  2 s . c  om*/
    return new File(store, index.toString() + "." + getExtension());
}

From source file:com.taobao.ad.easyschedule.server.JobHttpServer.java

@Override
public void run() {
    try {/*from   w  w w .  java 2s .co m*/
        HttpServer httpServer = HttpServer.create(new InetSocketAddress(Integer.parseInt(Const.SERVER_PORT)),
                0);
        httpServer.createContext(Const.SERVER_CONTEXT, new HttpHandler() {
            @Override
            public void handle(final HttpExchange exchange) throws IOException {
                JobResult result = JobResult.succcessResult();
                String queryPath = exchange.getRequestURI().getPath();
                String queryStr = exchange.getRequestURI().getQuery();
                if (StringUtils.isEmpty(queryStr) || StringUtils.isEmpty(queryPath)) {
                    result = JobResult.errorResult(JobResult.RESULTCODE_PARAMETER_ILLEGAL,
                            "??");
                } else {
                    try {
                        queryPath = queryPath.replaceAll(Const.SERVER_CONTEXT, "");
                        JobData jobData = HttpJobUtils.createJobData(queryStr);
                        String beanId = jobData.getData().get(JobData.JOBDATA_DATA_BEANID);
                        if (StringUtils.isEmpty(beanId)) {
                            result = JobResult.errorResult(JobResult.RESULTCODE_PARAMETER_ILLEGAL,
                                    "???");
                        } else {
                            if (Const.DEPLOY_MODE.equals("dev")) {
                                Long signTime = System.currentTimeMillis() / 1000;
                                String token = TokenUtils.generateToken(signTime.toString());
                                jobData.setSignTime(signTime.toString());
                                jobData.setToken(token);
                            }
                            result = HttpJobUtils.checkJobData(jobData);
                            if (result.isSuccess()) {
                                if (queryPath.equals(Const.QUERYPATH_DOSTDJOB)) {
                                    WebApplicationContext context = ContextLoader
                                            .getCurrentWebApplicationContext();
                                    JobExecutor executor = (JobExecutor) context.getBean(beanId);
                                    result = HttpJobExecutor.getInstance().execute(jobData, executor);
                                } else {
                                    result = JobResult.errorResult(JobResult.RESULTCODE_PARAMETER_ILLEGAL,
                                            "" + queryPath);
                                }
                            }
                        }
                    } catch (Exception e) {
                        result = JobResult.errorResult(JobResult.RESULTCODE_OTHER_ERR, "");
                        logger.info("|" + queryStr);
                    }
                }
                JSONObject json = (JSONObject) JSONObject.toJSON(result);
                exchange.getResponseHeaders().set("Content-type", "application/json;charset=utf-8");
                exchange.sendResponseHeaders(200, 0L);
                OutputStream os = exchange.getResponseBody();
                os.write(json.toString().getBytes("utf-8"));
                os.close();
            }
        });
        httpServer.start();
    } catch (Throwable e) {
        logger.error("JobHttpServer.run is fail:" + e.getMessage(), e);
    }
}

From source file:org.kuali.mobility.push.dao.PushDeviceTupleDaoImplTest.java

@Test
@DirtiesContext/*from   ww w.  j  a va2  s. c o  m*/
public void countUnsentTuples() {
    Query query = getEntityManager().createNamedQuery("PushDeviceTuple.countUnsent");
    Long count = (Long) query.getSingleResult();
    LOG.debug("There are " + count.toString() + " unsent tuples in the database.");
    assertTrue("Count was null and should never be.", count != null);
}

From source file:almira.sample.dao.AbstractSpringDbUnitTestCase.java

public void addReplacementObject(String key, Long value) {
    replacementObjects.put(key, value.toString());
}

From source file:org.sakaiproject.contentreview.dao.ContentReviewDaoImplTest.java

@Test
public void onSetUpInTransaction() {
    contentReviewItemLockedExp = new ContentReviewItem(USER, "site", "task", "content", new Date(),
            ContentReviewItem.NOT_SUBMITTED_CODE);
    contentReviewDao.save(contentReviewItemLockedExp);

    //first test we have saved the item
    Assert.assertNotNull(contentReviewItemLockedExp.getId());

    ContentReviewItem newItem = new ContentReviewItem(USER, "site", "task", "content", new Date(),
            ContentReviewItem.NOT_SUBMITTED_CODE);
    contentReviewDao.save(newItem);//www  .j a  v a 2s  . co  m

    //now this should have an id greater that is different from the one above
    Assert.assertNotSame(newItem.getId(), contentReviewItemLockedExp.getId());

    //can we get the lock?
    Long tId = Long.valueOf(contentReviewItemLockedExp.getId());
    String sId = tId.toString();
    Assert.assertTrue(contentReviewDao.obtainLock(sId, ADMIN_USER, -1000));

    //lock item
    contentReviewItemLocked = new ContentReviewItem(USER, "site", "task", "content", new Date(),
            ContentReviewItem.NOT_SUBMITTED_CODE);
    contentReviewDao.save(contentReviewItemLocked);
    contentReviewDao.obtainLock(contentReviewItemLocked.getId().toString(), ADMIN_USER, 10000);

    contentReviewItemUnlocked = new ContentReviewItem(USER, "site", "task", "content", new Date(),
            ContentReviewItem.NOT_SUBMITTED_CODE);
    contentReviewDao.save(contentReviewItemUnlocked);

    testgetLock();
}

From source file:org.araneaframework.tests.framework.filter.StandardTransactionFilterWidgetTests.java

public void testConsistentKeyRoutesUpdate() throws Exception {
    Long key = ((Long) trans.getTransactionId());

    req.addParameter(StandardTransactionFilterWidget.TRANSACTION_ID_KEY, key.toString());
    StandardServletInputData input = new StandardServletInputData(req);
    trans._getWidget().update(input);/*from  www. ja v a 2 s .c  o  m*/

    assertTrue(child.isUpdateCalled());
}

From source file:org.tdmx.lib.control.service.UniqueIdServiceImpl.java

@Override
public String getNextId() {
    long result = 0;
    synchronized (syncObject) {
        if (cachedMaxValue == 0 || cachedMaxValue >= lastCachedMaxValue) {
            MaxValue mv = getMaxValueService().increment(getMaxValueKey(), getBatchSize());
            lastCachedMaxValue = mv.getValue();
            cachedMaxValue = mv.getValue() - getBatchSize() + 1;
        } else {//from   w  ww. ja v  a  2 s  . co m
            cachedMaxValue += 1;
        }
        result = cachedMaxValue; // assign
    }
    int checkDigit = calculateCheckDigit(result);
    Long oid = (result * DIGIT) + checkDigit;

    String id = oid.toString();
    log.info("Generated " + getMaxValueKey() + "=" + id);
    return id;
}

From source file:fr.unix_experience.owncloud_sms.engine.OCHttpClient.java

GetMethod getMessages(Long start, Integer limit) {
    return get(OCHttpClient.OC_V2_GET_MESSAGES.replace("[START]", start.toString()).replace("[LIMIT]",
            limit.toString()));//  w  ww.  java2 s .  c  o  m
}

From source file:org.araneaframework.tests.framework.filter.StandardTransactionFilterWidgetTests.java

public void testConsistentKeyRoutesEvent() throws Exception {
    Long key = ((Long) trans.getTransactionId());

    req.addParameter(StandardTransactionFilterWidget.TRANSACTION_ID_KEY, key.toString());
    StandardServletInputData input = new StandardServletInputData(req);
    trans._getWidget().update(input);/*  w  ww .j a  v  a2s .  c o  m*/

    trans._getWidget().event(new StandardPath(""), input);
    assertTrue(child.isEventCalled());
}