Example usage for java.lang Long parseLong

List of usage examples for java.lang Long parseLong

Introduction

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

Prototype

public static long parseLong(String s) throws NumberFormatException 

Source Link

Document

Parses the string argument as a signed decimal long .

Usage

From source file:Main.java

/**
 * Same as {@link #asLong(String, Node)} but allows an xpath to be passed
 * in explicitly for reuse.// w  w w. j a  va 2  s  .co m
 */
public static Long asLong(String expression, Node node, XPath xpath) throws XPathExpressionException {
    String longString = evaluateAsString(expression, node, xpath);
    return (isEmptyString(longString)) ? null : Long.parseLong(longString);
}

From source file:com.mylaensys.dhtmlx.adapter.format.KeyFormatter.java

public Key parse(String source, Locale locale) throws ParseException {
    return KeyFactory.createKey("Object", Long.parseLong(source));
}

From source file:com.speedment.examples.social.JSONUser.java

public static JSONUser parse(JSONObject user) {
    final JSONUser usr = new JSONUser();
    usr.id = Long.parseLong(user.get("id").toString());
    usr.mail = user.get("mail").toString();
    usr.firstname = mapToString(user, "firstName");
    usr.lastname = mapToString(user, "lastName");
    usr.avatar = Optional.ofNullable(user.get("avatar")).map(Object::toString).filter(s -> !s.isEmpty())
            .map(s -> fromBase64(s)).orElse(null);

    return usr;/*from   w ww .  j a  v a  2  s.c om*/
}

From source file:org.jblogcms.core.blog.converter.StringToBlogConverter.java

@Override
public Blog convert(String s) {
    Long blogId = Long.parseLong(s);
    return blogRepository.findOne(blogId);
}

From source file:controller.EditBikeController.java

@RequestMapping(value = "editproduct/bike/{id}", method = GET) //betreffende productgegevens ophalen
public String showProductEdit(@PathVariable String id, Model model) {
    model.addAttribute(dao.findProductById(Long.parseLong(id), model.Car.class));

    return "editBike";
}

From source file:info.usbo.skypetwitter.VK.java

VK(String line) throws ParseException {
    JSONObject json2 = (JSONObject) new JSONParser().parse(line);
    id = Long.parseLong(json2.get("id").toString());
    text = json2.get("text").toString();
    if ("".equals(text)) {
        if (json2.get("copy_history") != null) {
            JSONArray json3 = (JSONArray) new JSONParser().parse(json2.get("copy_history").toString());
            if (json3.size() > 0) {
                JSONObject json4 = (JSONObject) new JSONParser().parse(json3.get(0).toString());
                text = json4.get("text").toString();
            }//from w  w w  .  j  a  v a 2 s  . c  om
        } else {
            text = "";
        }
    }
    date = new Date(Long.parseLong(json2.get("date").toString()) * 1000);
    attachment = findAttachment(json2);
}

From source file:com.speedment.examples.social.JSONImage.java

public static List<JSONImage> parseFrom(String json) {

    final JSONObject container = (JSONObject) JSONValue.parse(json);
    final JSONArray array = (JSONArray) container.get("images");
    final List<JSONImage> images = new ArrayList<>();

    array.stream().forEach(o -> {/*from  w w w.  ja  va2  s. com*/
        final JSONObject obj = (JSONObject) o;
        final JSONImage img = new JSONImage();
        final long time = Long.parseLong(obj.get("uploaded").toString());

        final LocalDateTime ldt = LocalDateTime.ofEpochSecond(time / 1000L, (int) (time % 1000) * 1000,
                ZoneOffset.UTC);

        img.title = obj.get("title").toString();
        img.description = obj.get("description").toString();
        img.uploaded = ldt;
        img.uploader = JSONUser.parse((JSONObject) obj.get("uploader"));
        img.image = fromBase64(obj.get("img_data").toString());
        images.add(img);
    });

    Collections.sort(images, Comparator.reverseOrder());

    return images;
}

From source file:com.wineaccess.wineOWS.WineOwsAdapterHelper.java

/**
 * this method is to view the wine historical ows data based on wineId
 * if no wine historical ows data exists then copy winery ows data to wine ows data
 * @param viewWineOwsPO/*ww  w .j  a va2s  .  com*/
 * return map the output map
 */
public static Map<String, Object> viewWineOwsData(final ViewWineOwsPO viewWineOwsPO) {
    logger.info("start view wine historical Ows data");

    final Map<String, Object> output = new ConcurrentHashMap<String, Object>();
    Response response = null;
    final ProductItemModel productModel = ProductItemRepository
            .getProductItemById(Long.parseLong(viewWineOwsPO.getProductId()));
    if (productModel == null) {
        response = ApplicationUtils.errorMessageGenerate(
                WineaccessErrorCodes.SystemErrorCode.WINE_OWS_ERROR_104,
                WineaccessErrorCodes.SystemErrorCode.WINE_OWS_ERROR_104_TEXT, SUCCESS_CODE);
    } else {
        final WineHistoricalOWSData historicalOwsData = WineOwsDataRepository
                .getOwsDataByWineId(productModel.getItemId());
        if (historicalOwsData != null) {

            ViewWineOwsVO viewWineOwsVO = new ViewWineOwsVO();
            final WineModel wineModel = WineRepository.getWineById(historicalOwsData.getWineId());
            populateViewOwsVOFromPO(wineModel, historicalOwsData, viewWineOwsVO, productModel);

            response = new com.wineaccess.response.SuccessResponse(viewWineOwsVO, SUCCESS_CODE);

        } else if (historicalOwsData == null) {

            final WineModel wineModel = WineRepository.getWineById(productModel.getItemId());
            if (wineModel != null) {
                WineryHistoricalOwsData wineryHistoricalOwsData = null;
                if (wineModel.getWineryId() != null) {
                    wineryHistoricalOwsData = WineryOwsDataRepository
                            .getOwsDataByWineryId(wineModel.getWineryId().getId());
                }
                if (wineryHistoricalOwsData != null) {
                    //Copy the winery historical data to wine historical data
                    WineHistoricalOWSData wineHistoricalOWSData = new WineHistoricalOWSData();
                    wineHistoricalOWSData.setCeraCertEndDate(wineryHistoricalOwsData.getCeraCertEndDate());
                    wineHistoricalOWSData.setCeraCertNumber(wineryHistoricalOwsData.getCeraCertNumber());
                    wineHistoricalOWSData.setCeraCertStartDate(wineryHistoricalOwsData.getCeraCertStartDate());
                    wineHistoricalOWSData.setCeraLicenseNumber(wineryHistoricalOwsData.getCeraLicenseNumber());
                    wineHistoricalOWSData
                            .setFullFillerWineryCode(wineryHistoricalOwsData.getFullFillerWineryCode());
                    wineHistoricalOWSData
                            .setFullFillerWineryName(wineryHistoricalOwsData.getFullFillerWineryName());
                    wineHistoricalOWSData.setWineId(productModel.getItemId());

                    WineOwsDataRepository.save(wineHistoricalOWSData);

                    ViewWineOwsVO viewWineOwsVO = new ViewWineOwsVO();
                    populateViewOwsVOFromPO(wineModel, wineHistoricalOWSData, viewWineOwsVO, productModel);

                    response = new com.wineaccess.response.SuccessResponse(viewWineOwsVO, SUCCESS_CODE);
                } else {
                    response = ApplicationUtils.errorMessageGenerate(
                            WineaccessErrorCodes.SystemErrorCode.NO_ENTITY_FOUND,
                            WineaccessErrorCodes.SystemErrorCode.NO_ENTITY_FOUND_TEXT, SUCCESS_CODE);
                }
            } else {
                response = ApplicationUtils.errorMessageGenerate(
                        WineaccessErrorCodes.SystemErrorCode.WINE_OWS_ERROR_103,
                        WineaccessErrorCodes.SystemErrorCode.WINE_OWS_ERROR_103_TEXT, SUCCESS_CODE);
            }
        }
    }

    output.put(OUPUT_PARAM_KEY, response);
    logger.info("exit view winery historical Ows data");

    return output;
}

From source file:com.mtech.easyexchange.ordersolver.consumer.OrderMessageListener.java

public void process(Message message) {

    String action = new String(message.getBody());

    System.out.println(action);/* w  ww  .ja v  a  2 s  . co  m*/

    String[] result = action.split(":");
    Long id = Long.parseLong(result[0]);
    OrderAction orderAction = OrderAction.valueOf(result[1]);

    try {
        Order order = orderManager.get(id);
        OrderOperation op = new OrderOperation(order, orderAction);

        holder.add(op);

        System.out.println("OrderOperation caught");
    } catch (OrderNotFoundException e) {
        System.out.println("Order not found with id #" + id);
    }
}

From source file:controller.EditCarController.java

@RequestMapping(value = "editproduct/car/{id}", method = GET) //betreffende productgegevens ophalen
public String showProductEdit(@PathVariable String id, Model model) {
    model.addAttribute(dao.findProductById(Long.parseLong(id), model.Car.class));

    return "editCar";
}