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:com.ewcms.web.pubsub.PubsubServlet.java

private void initInitialDelay() {
    String value = this.getInitParameter(INITIALDELAY_PARAM_NAME);
    if (StringUtils.isNumeric(value)) {
        initialDelay = Long.valueOf(value);
    }//from   w w  w  .j  a va  2s.  c  o  m
}

From source file:org.opencredo.couchdb.core.CouchDbChangesTemplateTest.java

@Test
public void pollForChanges() throws Exception {
    when(restOperations.getForObject(anyString(), eq(Changes.class), eq(Long.valueOf(0L))))
            .thenReturn(createChanges(NUMBER_OF_CHANGES));

    Collection<ChangedDocument> documents = changesTemplate.pollForChanges();
    assertThat(documents, is(notNullValue()));
    assertThat(documents.size(), equalTo(NUMBER_OF_CHANGES));
}

From source file:de.boksa.jasper.rt.data.JRRTRESTInterfaceDataSource.java

private Object parseValue(Class<?> type, String value) {
    try {//w ww.  j  a va 2s  . co m
        if (Long.class.equals(type)) {
            return Long.valueOf(value);
        } else if (Double.class.equals(type)) {
            return Double.valueOf(value.replace(',', '.')); // TODO check if this can be handled using the user's locale
        } else if (BigDecimal.class.equals(type)) {
            return new BigDecimal(value.replace(',', '.')); // TODO check if this can be handled using the user's locale
        } else {
            return value;
        }
    } catch (Exception ex) {
        LOG.warn(
                String.format("Could not parse '%s' from value '%s', returning value.", type.getName(), value));
        return value;
    }
}

From source file:de.forsthaus.backend.util.db.logging.ServiceLogging.java

public Object logging(ProceedingJoinPoint call) throws Throwable {
    startTimes.add(Long.valueOf(System.nanoTime()));
    try {/* w  ww  . j  ava2  s.c o  m*/
        // LOG.info("Start call: " + call.toShortString());
        return call.proceed();
    } finally {
        methodName = call.toShortString();
        finishTime = (System.nanoTime() - startTimes.remove().longValue()) / 1000000;
        if (startTimes.isEmpty()) {
            methodName = StringUtils.substring(methodName, 10, -1);

            // LOG.info("Execution time: " + finishTime + "ms " +
            // methodName);
            loggingService.saveStatistics(statistics, methodName, finishTime);
            init();
        }
    }
}

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

void getItinerary() {
    try {//  w  w  w.  ja  v  a  2s .  co m
        itneraryDuration = Long.valueOf(m_ItineraryJsonObject.get("duration").toString());
        System.out.println(m_ItineraryJsonObject.get("duration").toString() + "duration");

        //itneraryDurationlongS=caltime(itneraryStartTimelong);
        //System.out.println("itneraryDurationlongS"+itneraryDurationlongS);
        itineraryWalkTime = Long.valueOf(m_ItineraryJsonObject.get("walkTime").toString());
        itineraryTransitTime = Long.valueOf(m_ItineraryJsonObject.get("transitTime").toString());
        itineraryWaitingTime = Long.valueOf(m_ItineraryJsonObject.get("waitingTime").toString());
        itineraryTransfers = Long.valueOf(m_ItineraryJsonObject.get("transfers").toString());
        itneraryStartTime = m_ItineraryJsonObject.get("startTime");
        itneraryStartTimelong = Long.valueOf(m_ItineraryJsonObject.get("startTime").toString());
        System.out.println(m_ItineraryJsonObject.get("startTime").toString() + "startTime");
        ms = itneraryStartTimelong;

        itneraryEndTime = m_ItineraryJsonObject.get("endTime");
        itneraryFare = m_ItineraryJsonObject.get("fare");
        itneraryWalkDistance = (Double) m_ItineraryJsonObject.get("walkDistance");
        itneraryElevationLost = (Double) m_ItineraryJsonObject.get("elevationLost");
        itneraryElevationGained = (Double) m_ItineraryJsonObject.get("elevationGained");
        itneraryTooSloped = ((Boolean) m_ItineraryJsonObject.get("tooSloped"));
        planDate = Long.valueOf(CPlan.PlanJsonObject.get("date").toString());
        d = new Date(itneraryStartTimelong);
        System.out.println(d + "date");
        date = new Date();
        calendar.setTime(date);

        sd.setTimeZone(TimeZone.getTimeZone("IST"));
        System.out.println(sd.format(d) + " sd.format(d)");
        //....comented bcoz not going further  dateL = sd.parse(String.valueOf(itneraryStartTimelong));

        /*int hour = calendar.get(Calendar.HOUR);
        minute = calendar.get(Calendar.MINUTE);
        int  am_pm=  calendar.get(Calendar.AM_PM);
                
        if(am_pm==0)
        am_pmn="am";
        else
        am_pmn="pm";
        timeString="hour+";
        System.out.print("*"+hour+":"+minute+ am_pmn+"**"); */
        /*System.out.println(String.valueOf(itneraryDuration)+" itneraryDuration");
        System.out.println(String.valueOf(itineraryWalkTime)+" itineraryWalkTime");
        System.out.println(String.valueOf(itineraryTransitTime)+" itineraryTransitTime");
        System.out.println(String.valueOf(itineraryWaitingTime)+" itineraryWaitingTime");
        System.out.println(String.valueOf(itineraryTransfers)+" itineraryTransfers");
        System.out.println(itneraryStartTime.toString()+" itneraryStartTime");
        System.out.println(itneraryEndTime.toString()+" itneraryEndTime");
        System.out.println(itneraryFare+" itneraryFare");
        System.out.println(Double.toString(itneraryWalkDistance)+" itneraryWalkDistance");
        System.out.println(Double.toString(itneraryElevationLost)+" itneraryElevationLost");
        System.out.println(Double.toString(itneraryElevationGained)+" itneraryElevationGained");
        System.out.println(String.valueOf(itneraryTooSloped)+" itneraryTooSloped");
        System.out.println(String.valueOf(planDate) +"date");*/
        from = new CItenFrom();
        from.getFrom();
        to = new CItenTo();
        to.getTo();
        leg = new CLeg(m_ItineraryJsonObject);
        leg.getLeg();
        CTrip ctrip = new CTrip(m_ItineraryJsonObject);
        CTrip.legs.add(leg);
        System.out.println(
                ".........................................................................................");

        /* public static String caltime(long dur)
        {
                
        StringBuffer text = new StringBuffer("");
        if (ms > DAY) {
        text.append(ms / DAY).append(" days ");
        ms %= DAY;
        }
        if (ms > HOUR) {
        text.append(ms / HOUR).append(" hours ");
        ms %= HOUR;
        }
        if (ms > MINUTE) {
        text.append(ms / MINUTE).append(" minutes ");
        ms %= MINUTE;
        }
        if (ms > SECOND) {
        text.append(ms / SECOND).append(" seconds ");
        ms %= SECOND;
        }
        text.append(ms + " ms");
        time=text.toString();
        System.out.println(text.toString()+"itneraryStartTimelong*");
        // return(time);
        // }  */

    } catch (Exception e) {
        System.out.println(e);
    }
}

From source file:com.greenline.hrs.admin.auth.realm.WebRealm.java

/**
 * ???/*from  w w w.j a  v a 2 s  . co m*/
 *
 * @param principals
 * @return
 */
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
    //null usernames are invalid
    if (principals == null || principals.getPrimaryPrincipal() == null) {
        throw new AuthorizationException(AuthMessageConstants.PRINCIPAL_NULL);
    }
    UserAuthInfo userAuthInfo = null;
    try {
        Long userId = Long.valueOf(getAvailablePrincipal(principals).toString());
        userAuthInfo = manUserService.getUserAuthInfo(userId);
    } catch (Exception e) {
        LOG.error(AuthMessageConstants.AUTHORIZATION_EXCEPTION, e);
    }
    if (userAuthInfo == null) {
        throw new AuthorizationException(AuthMessageConstants.AUTHORIZATION_EXCEPTION + principals);
    }
    SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(userAuthInfo.getRoles());
    info.setStringPermissions(userAuthInfo.getPermissions());
    return info;
}

From source file:com.seer.datacruncher.spring.MacrosValidateController.java

public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String varList = request.getParameter("varList");
    String rule = request.getParameter("rule");
    Long schemaId = Long.valueOf(request.getParameter("schemaId"));
    if (rule == null) {
        throw new IllegalArgumentException("MacrosValidateController: null parameter 'rule'");
    }//w  w  w .j av  a2 s.c  om
    String success = "true";
    Map<String, String> resMap = new HashMap<String, String>();
    if (rule.trim().isEmpty()) {
        success = "false";
        resMap.put("errMsg", I18n.getMessage("error.macro.emptyRule"));
    }
    Pattern pattern = Pattern.compile(MacroRulesValidation.MACRO_SQL_VALIDATOR_PATTERN,
            Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher(rule);
    rule = matcher.replaceAll("true");
    List<Map<String, String>> list = MacroRulesValidation.parseVars(varList);
    MacroRulesValidation.combineVariableLists(list, schemaId);
    JexlEngine jexl = JexlEngineFactory.getInstance();
    try {
        Expression e = jexl.createExpression(rule);
        JexlContext context = new MapContext();
        for (Map<String, String> m : list) {
            String anyStringDigit = "7";
            context.set(m.get("uniqueName"),
                    JEXLFieldFactory.getField(m.get("fieldType"), anyStringDigit).getValue());
        }
        e.evaluate(context);
    } catch (Exception e1) {
        success = "false";
        resMap.put("errMsg", e1.getMessage() + "\n" + getStackTrace(e1));
    }
    resMap.put("success", success);
    response.getWriter().print(new JSONObject(resMap).toString());
    return null;
}

From source file:com.adaptris.core.services.jdbc.LongStatementParameter.java

Long toLong(Object value) throws ServiceException {
    if (isBlank((String) value) && convertNull()) {
        return Long.valueOf(NumberUtils.toLong((String) value));
    } else {//w  w w. ja  v  a 2  s.c  o  m
        return Long.valueOf((String) value);
    }
}

From source file:com.oneops.opamp.cache.WatchedByAttributeCacheLoader.java

@Override
public String load(String key) {
    logger.warn("Loading Watched By Attributes from cms for " + key);
    String attributeValue = null;
    if (key == null) {
        throw new IllegalArgumentException("key can not be null");
    } else {/*from w w  w  .  j  av  a 2 s. co m*/
        //split the key
        String[] parts = key.split(":");
        long manifestId = Long.valueOf(parts[0]);
        String source = parts[1];
        String attributeName = parts[2];
        attributeValue = getAttributeValue(manifestId, source, attributeName);
    }
    logger.info("loaded  the attribute for key: " + key + " with value " + attributeValue);

    return attributeValue;
}

From source file:org.ambraproject.annotation.action.CreateReplyActionTest.java

@Test
public void testCreateReply() throws Exception {
    UserProfile creator = new UserProfile("authIdForCreateReplyAction", "email@createReplyAction.org",
            "displayNameForCreateReplyAction");
    dummyDataStore.store(creator);// w  w w.  j a  va  2 s  . c  om
    login(creator);
    Article article = new Article("id:doi-for-create-reply-action");
    Long articleId = Long.valueOf(dummyDataStore.store(article));

    Annotation annotation = new Annotation(creator, AnnotationType.COMMENT, articleId);
    Long annotationId = Long.valueOf(dummyDataStore.store(annotation));

    String body = "test comment for reply";
    String title = "test title for reply";
    action.setInReplyTo(annotationId);
    action.setComment(body);
    action.setCommentTitle(title);
    action.setIsCompetingInterest(false);
    action.setCiStatement(null);

    String result = action.execute();
    assertEquals(result, Action.SUCCESS, "Action didn't return success");
    assertEquals(action.getActionErrors().size(), 0,
            "Action returned error messages: " + StringUtils.join(action.getActionErrors(), ";"));
    assertEquals(action.getFieldErrors().size(), 0,
            "Action returned field errors: " + StringUtils.join(action.getFieldErrors().values(), ";"));

    assertNotNull(action.getReplyId(), "Action returned null reply id");

    Annotation storedReply = dummyDataStore.get(Annotation.class, action.getReplyId());
    assertNotNull(storedReply, "didn't store reply to the database");
    assertEquals(storedReply.getType(), AnnotationType.REPLY, "stored reply had incorrect type");
    assertEquals(storedReply.getArticleID(), articleId, "stored reply had incorrect article id");
    assertEquals(storedReply.getParentID(), annotationId, "stored reply had incorrect parent id");
    assertEquals(storedReply.getTitle(), title, "stored reply had incorrect title");
    assertEquals(storedReply.getBody(), body, "stored reply had incorrect body");
    assertNull(storedReply.getCompetingInterestBody(), "stored reply had a competing interest statement added");
}