Example usage for org.apache.commons.lang.math NumberUtils toLong

List of usage examples for org.apache.commons.lang.math NumberUtils toLong

Introduction

In this page you can find the example usage for org.apache.commons.lang.math NumberUtils toLong.

Prototype

public static long toLong(String str) 

Source Link

Document

Convert a String to a long, returning zero if the conversion fails.

If the string is null, zero is returned.

 NumberUtils.toLong(null) = 0L NumberUtils.toLong("")   = 0L NumberUtils.toLong("1")  = 1L 

Usage

From source file:com.zb.app.web.webuser.ZuobianWebUserBuilder.java

/**
 * webUser//from  w  w w .j  av a2  s. co  m
 * 
 * @param cookieManager
 * @return
 */
public static ZuobianWebUser create(CookieManager cookieManager) {
    ZuobianWebUser webUser = new ZuobianWebUser();

    String userName = cookieManager.get(CookieKeyEnum.member_nickname);
    Long mId = NumberUtils.toLong(cookieManager.get(CookieKeyEnum.member_id));
    Long cId = NumberUtils.toLong(cookieManager.get(CookieKeyEnum.member_company_id));
    Integer type = NumberUtils.toInt(cookieManager.get(CookieKeyEnum.member_type));
    Date lastLogin = new Date(NumberUtils.toLong(cookieManager.get(CookieKeyEnum.last_login_time)));

    webUser.setUserName(userName);
    webUser.setmId(mId);
    webUser.setcId(cId);
    webUser.setType(CompanyTypeEnum.getEnum(type));
    webUser.setLastLogin(lastLogin);

    boolean hasLogin = StringUtils.isNotBlank(userName) && mId != null && mId != 0l && cId != null && cId != 0l
            && type != null && type != 0;
    webUser.setHasLogin(hasLogin);

    String cookieId = CookieIdBuilder.getCookieId(cookieManager);
    if (cookieId == null) {
        webUser.setFirstAccess(true);
        cookieId = CookieIdBuilder.createCookieId(cookieManager);
    } else {
        webUser.setFirstAccess(false);
    }
    webUser.setCookieId(cookieId);

    ZuobianWebUser.setCurrentUser(webUser);
    return ZuobianWebUser.getCurrentUser();
}

From source file:com.mmj.app.web.webuser.MMJWebUserBuilder.java

/**
 * webUser/* www.  j av  a 2  s .  c  o m*/
 * 
 * @param cookieManager
 * @return
 */
public static MMJWebUser create(CookieManager cookieManager) {
    MMJWebUser webUser = new MMJWebUser();

    String name = cookieManager.get(CookieKeyEnum.member_name);
    String nick = cookieManager.get(CookieKeyEnum.member_nickname);
    Long uId = NumberUtils.toLong(cookieManager.get(CookieKeyEnum.member_id));
    Integer type = NumberUtils.toInt(cookieManager.get(CookieKeyEnum.member_type));
    Date lastLogin = new Date(NumberUtils.toLong(cookieManager.get(CookieKeyEnum.last_login_time)));

    webUser.setuId(uId);
    webUser.setType(UserTypeEnum.getEnum(type));
    webUser.setName(name);
    webUser.setNick(nick);
    webUser.setLastLogin(lastLogin);

    boolean hasLogin = (StringUtils.isNotBlank(nick) || StringUtils.isNotBlank(name)) && uId != null
            && uId != 0l && type != null && type != 0;
    webUser.setHasLogin(hasLogin);

    String cookieId = CookieIdBuilder.getCookieId(cookieManager);
    if (cookieId == null) {
        webUser.setFirstAccess(true);
        cookieId = CookieIdBuilder.createCookieId(cookieManager);
    } else {
        webUser.setFirstAccess(false);
    }
    webUser.setCookieId(cookieId);

    MMJWebUser.setCurrentUser(webUser);
    return MMJWebUser.getCurrentUser();
}

From source file:com.us.action.account.ViewMyPic.java

@Override
public String execute() throws Exception {
    if (!StringUtil.hasText(catalog) || !NumberUtils.isNumber(catalog) || NumberUtils.toLong(catalog) == -1) {
        albums = albumBo.find(Album.class, "creator", getLogonUserId());
    } else {/*from   w  w w  .  j  a  v  a  2 s  .  c  o  m*/
        String pro[] = ArrayHelper.make("creator", "catalog.uuid");
        Object val[] = ArrayHelper.make(getLogonUserId(), NumberUtils.toLong(catalog));
        albums = albumBo.find(Album.class, pro, val);
    }
    for (Album album : albums) {
        List<Object> o = albumBo.findByHql("select count(uuid) from com.us.vo.Image i where i.album=?",
                album.getUuid());
        final long imageCount = Long.parseLong(o.get(0).toString());
        album.setImgaeConunt(imageCount);
        totolImg += imageCount;
    }
    return view("viewMyAlbums.jsp");
}

From source file:com.edgenius.wiki.gwt.server.SearchUtil.java

public static void copyResultToModel(SearchResult result, SearchResultModel model) {
    if (result == null)
        return;//w w w  .  j a v  a  2s.co  m

    model.currPage = result.getCurrentPage();
    model.timeSecond = result.getTimeSecond();
    model.totalItems = result.getTotalItem();
    model.totalPage = result.getTotalPage();

    ArrayList<SearchResultItemModel> list = new ArrayList<SearchResultItemModel>();
    List<SearchResultItem> items = result.getItems();
    if (items != null) {
        for (SearchResultItem resultItem : items) {
            SearchResultItemModel itemModel = new SearchResultItemModel();
            itemModel.fragment = resultItem.getFragment();
            itemModel.itemUid = resultItem.getItemUid();
            itemModel.type = resultItem.getType();
            itemModel.title = resultItem.getTitle();
            itemModel.spaceUname = resultItem.getSpaceUname();
            itemModel.desc = resultItem.getDesc();
            itemModel.date = NumberUtils.toLong(resultItem.getDatetime());
            itemModel.contributor = resultItem.getContributor();
            itemModel.contributorUsername = resultItem.getContributorUsername();
            list.add(itemModel);
        }
    }
    model.results = list;
}

From source file:gemlite.core.internal.domain.utilClass.MqDataSource.java

public final long getLong(String name) {
    String str = map.get(name);
    long n = NumberUtils.toLong(str);
    return n;
}

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 {/*from w w w.  java2 s  . c  o m*/
        return Long.valueOf((String) value);
    }
}

From source file:gemlite.core.webapp.pages.file.JarFileDownload.java

@RequestMapping(value = "/{fileId}", method = RequestMethod.GET)
public ResponseEntity<byte[]> getJarContent(@PathVariable String fileId) {
    JarFileService service = JpaContext.getService(JarFileService.class);
    byte[] bytes = null;
    try {/*from   w w  w .j a va 2s.c om*/
        long id = NumberUtils.toLong(fileId);
        ReleasedJarFile jarFile = service.getFileById(id);
        LogUtil.getCoreLog().info("FileId:" + fileId + " name:" + jarFile.getFileName());
        bytes = jarFile.getContent();

        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
        headers.setContentDispositionFormData("attachment", jarFile.getFileName());
        return new ResponseEntity<byte[]>(bytes, headers, HttpStatus.CREATED);
    } catch (Exception e) {
        LogUtil.getCoreLog().error("", e);
    }
    return new ResponseEntity<byte[]>(null, null, HttpStatus.CREATED);
}

From source file:com.smartitengineering.cms.client.impl.WorkspaceSequenceResourceImpl.java

public long getCurrentValue() {
    return NumberUtils.toLong(getLastReadStateOfEntity().get("value"));
}

From source file:com.baidu.cc.web.action.ProjectDelAction.java

/**
 * ?./*  w w w  .  j a v a 2  s .co m*/
 * 
 * @param reqParam
 *            request param
 * @return 
 */
@Override
protected DataResult doExecuteService(ReqParam reqParam) {
    List<String> projectIds = reqParam.getProjectIds();
    Long userId = NumberUtils.toLong(ThreadLocalInfo.getThreadUuid());
    if (projectIds == null || projectIds.size() == 0) {
        return null;
    }

    for (String projectId : projectIds) {
        projectService.deleteProjectCascadeById(userId, NumberUtils.toLong(projectId));
    }
    return null;
}

From source file:com.smartitengineering.cms.client.impl.WorkspaceSequenceResourceImpl.java

public long update(long delta) {
    MultivaluedMap<String, String> formData = new MultivaluedMapImpl();
    formData.putSingle("delta", Long.toString(delta));
    ClientResponse response = post(MediaType.APPLICATION_FORM_URLENCODED, formData, ClientResponse.Status.OK);
    response.bufferEntity();/*from w w w. ja  v  a 2 s. c  o m*/
    response.close();
    return NumberUtils.toLong(response.getEntity(new GenericType<Map<String, String>>() {
    }).get("value"));
}