Java Code Examples for com.alibaba.fastjson.JSONObject#getDoubleValue()

The following examples show how to use com.alibaba.fastjson.JSONObject#getDoubleValue() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Jpom   File: NodeMonitor.java    License: MIT License 6 votes vote down vote up
private void getNodeInfo(NodeModel nodeModel) {
    JsonMessage message = NodeForward.request(nodeModel, null, NodeUrl.GetDirectTop);
    JSONObject jsonObject = (JSONObject) message.getData();
    if (jsonObject == null) {
        return;
    }
    double disk = jsonObject.getDoubleValue("disk");
    if (disk <= 0) {
        return;
    }
    //
    SystemMonitorLog log = new SystemMonitorLog();
    log.setId(IdUtil.fastSimpleUUID());
    log.setOccupyMemory(jsonObject.getDoubleValue("memory"));
    log.setOccupyDisk(disk);
    log.setOccupyCpu(jsonObject.getDoubleValue("cpu"));
    log.setMonitorTime(jsonObject.getLongValue("time"));
    log.setNodeId(nodeModel.getId());
    dbSystemMonitorLogService.insert(log);
}
 
Example 2
Source Project: UIAutomatorWD   File: ActionController.java    License: MIT License 6 votes vote down vote up
private static boolean drag(JSONObject args) throws Exception {
    String elementId = args.getString("element");
    Double fromX = args.getDouble("fromX");
    Double fromY = args.getDouble("fromY");
    Double toX = args.getDouble("toX");
    Double toY = args.getDouble("toY");
    double duration = args.getDoubleValue("duration");
    int steps = (int) Math.round(duration * 40);
    if (elementId != null) {
        Element el = elements.getElement(elementId);
        return el.drag(toX.intValue(), toY.intValue(), steps);
    } else {
        boolean res = mDevice.drag(fromX.intValue(), fromY.intValue(), toX.intValue(), toY.intValue(), steps);
        Thread.sleep(steps * 100);
        return res;
    }
}
 
Example 3
Source Project: FastWaiMai   File: ShopCartDataConverter.java    License: MIT License 5 votes vote down vote up
@Override
public LinkedList<MultipleItemEntity> convert() {
	final JSONArray dataArray = JSON.parseObject(getJsonData()).getJSONArray("data");

	final int size = dataArray.size();
	for(int i = 0; i < size; i++ ){
		final JSONObject data = dataArray.getJSONObject(i);
		final Double price = data.getDoubleValue("price");
		final String id = data.getString("id");
		final Integer count = data.getIntValue("count");
		final String title = data.getString("title");
		final String desc = data.getString("desc");
		final String thumb = data.getString("thumb");

		final MultipleItemEntity entity = MultipleItemEntity.builder()
				.setField(MultipleFields.ITEM_TYPE, ShopCartItemType.SHOP_CART_ITEM)
				.setField(MultipleFields.ID, Integer.valueOf(id))
				.setField(MultipleFields.IMAGE_URL, thumb)
				.setField(ShopCartItemFields.COUNT, count)
				.setField(ShopCartItemFields.DESC, desc)
				.setField(ShopCartItemFields.PRICE, price)
				.setField(ShopCartItemFields.TITLE, title)
				.setField(ShopCartItemFields.IS_SELECTED, true)
				.setField(ShopCartItemFields.POSITION, i)
				.build();
		ENTITYS.add(entity);
	}

	return ENTITYS;
}
 
Example 4
Source Project: easyweb-shiro   File: JSONUtil.java    License: MIT License 5 votes vote down vote up
/**
 * 得到doubleValue类型的值
 */
public static double getDoubleValue(String json, String key) {
    double result = 0;
    try {
        JSONObject jsonObject = JSON.parseObject(json);
        result = jsonObject.getDoubleValue(key);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result;
}
 
Example 5
Source Project: UIAutomatorWD   File: ActionController.java    License: MIT License 5 votes vote down vote up
private static boolean press(JSONObject args) throws Exception {
    String elementId = args.getString("element");
    double duration = args.getDoubleValue("duration");
    int steps = (int) Math.round(duration * 40);
    if (elementId != null) {
        Element el = elements.getElement(elementId);
        Rect elRect = el.getUiObject().getVisibleBounds();
        return mDevice.swipe(elRect.centerX(), elRect.centerY(),  elRect.centerX(), elRect.centerY(), steps);
    } else {
        int x = args.getInteger("x");
        int y = args.getInteger("y");
        return mDevice.swipe(x, y, x, y, steps);
    }
}
 
Example 6
Source Project: tephra   File: ImageParserSupport.java    License: MIT License 5 votes vote down vote up
void parse(XSLFSlide xslfSlide, XSLFPictureData xslfPictureData, JSONObject object) {
    if (!object.containsKey("alpha")) {
        parseImage(xslfSlide, xslfPictureData, object);

        return;
    }

    double alpha = object.getDoubleValue("alpha");
    if (alpha >= 1.0D) {
        parseImage(xslfSlide, xslfPictureData, object);

        return;
    }

    PackagePart packagePart = xslfPictureData.getPackagePart();
    POIXMLDocumentPart.RelationPart relationPart = xslfSlide.addRelation(null, XSLFRelation.IMAGES,
            new XSLFPictureData(packagePart));

    XSLFAutoShape xslfAutoShape = xslfSlide.createAutoShape();
    CTShape ctShape = (CTShape) xslfAutoShape.getXmlObject();
    CTBlipFillProperties ctBlipFillProperties = ctShape.getSpPr().addNewBlipFill();
    CTBlip ctBlip = ctBlipFillProperties.addNewBlip();
    ctBlip.setEmbed(relationPart.getRelationship().getId());
    ctBlip.setCstate(STBlipCompression.PRINT);
    ctBlip.addNewAlphaModFix().setAmt(numeric.toInt(alpha * 100000));
    ctBlipFillProperties.addNewSrcRect();
    ctBlipFillProperties.addNewStretch().addNewFillRect();
    xslfAutoShape.setAnchor(parserHelper.getRectangle(object));
    parserHelper.rotate(xslfAutoShape, object);
}
 
Example 7
Source Project: tephra   File: ParserHelperImpl.java    License: MIT License 5 votes vote down vote up
@Override
public void rotate(XSLFSimpleShape xslfSimpleShape, JSONObject object) {
    if (object.containsKey("rotation") && object.getDoubleValue("rotation") != 0)
        xslfSimpleShape.setRotation(object.getDoubleValue("rotation"));
    if (json.hasTrue(object, "rotationX"))
        xslfSimpleShape.setFlipVertical(true);
    if (json.hasTrue(object, "rotationY"))
        xslfSimpleShape.setFlipHorizontal(true);
}
 
Example 8
Source Project: wd.java   File: Element.java    License: MIT License 5 votes vote down vote up
/**
 * get CenterX coordinate for this element
 *
 * @return
 * @throws Exception
 */
public double getCenterX() throws Exception {
    JSONObject rect = (JSONObject) getRect();
    double x = rect.getDoubleValue("x");
    double y = rect.getDoubleValue("y");
    double width = rect.getDoubleValue("width");
    double height = rect.getDoubleValue("height");
    double centerX = x + width / 2.0;
    return centerX;
}
 
Example 9
Source Project: wd.java   File: Element.java    License: MIT License 5 votes vote down vote up
/**
 * get CenterY coordinate for this element
 *
 * @return
 * @throws Exception
 */
public double getCenterY() throws Exception {
    JSONObject rect = (JSONObject) getRect();
    double x = rect.getDoubleValue("x");
    double y = rect.getDoubleValue("y");
    double width = rect.getDoubleValue("width");
    double height = rect.getDoubleValue("height");
    double centerY = y + height / 2.0;
    return centerY;
}
 
Example 10
Source Project: FastWaiMai   File: OrderListDataConverter.java    License: MIT License 4 votes vote down vote up
@Override
public LinkedList<MultipleItemEntity> convert() {
    //获取全部订单

    final JSONArray orderArray = JSON.parseObject(getJsonData()).getJSONArray("resultList");
    final int orderSize = orderArray.size();
    for(int i = 0; i < orderSize; i++){
        //每一个订单
        final JSONObject orderObject = orderArray.getJSONObject(i);
        //订单ID
        final String orderId = orderObject.getString("orderCode");
        //订单创建时间
        final String createTime = orderObject.getString("createTime");
        //订单总价格
        final Double totalPrice = orderObject.getDoubleValue("totalPrice");
        /**
         * 订单状态:
         *      0: 未付款
         *      1: 代发货
         *      2: 待收货
         *      3: 评价
         *      4: 退款/售后
         *
         *
         */
        final String orderStatus = orderObject.getString("orderStatus");
        //获取当前订单下的商品
        final JSONArray goodsArray = orderObject.getJSONArray("orderDetailList");
        final int goodsSize = goodsArray.size();

        final MultipleItemEntity headerEntity = MultipleItemEntity.builder()
                .setItemType(OrderListItemType.ITEM_ORDER_LIST_HEADER)
                .setField(OrderItemFields.ORDER_ID, orderId)
                .setField(OrderItemFields.CREATE_TIME, createTime)
                .setField(OrderItemFields.PAY_STATE, orderStatus)
                .build();

        final MultipleItemEntity footEntity = MultipleItemEntity.builder()
                .setItemType(OrderListItemType.ITEM_ORDER_LIST_FOOTER)
                .setField(OrderItemFields.TOTAL_PRICE, totalPrice)
                .build();

        ENTITYS.add(headerEntity);
        for(int j = 0; j < goodsSize; j++){
            final JSONObject goodsObject = goodsArray.getJSONObject(j);
            final String goodsName = goodsObject.getString("productName");
            final String goodsPic = goodsObject.getString("productPic");
            final double goodsPrice = goodsObject.getDoubleValue("price");
            final int goodsCount = goodsObject.getIntValue("count");

            final MultipleItemEntity contentEntity = MultipleItemEntity.builder()
                    .setItemType(OrderListItemType.ITEM_ORDER_LIST_CONTENT)
                    .setField(OrderItemFields.PRODUCT_COUNT, goodsCount)
                    .setField(OrderItemFields.PRODUCT_IMG, goodsPic)
                    .setField(OrderItemFields.PRODUCT_NAME, goodsName)
                    .setField(OrderItemFields.PRODUCT_PRICE, goodsPrice)
                    .build();
            ENTITYS.add(contentEntity);
        }
        ENTITYS.add(footEntity);

    }
    /**
     *  ENTITYS 添加数据的顺序影响显示的顺序
     *      headerEntity
     *      contentEntity
     *      footEntity
     */

    return ENTITYS;
}
 
Example 11
Source Project: wd.java   File: Element.java    License: MIT License 2 votes vote down vote up
/**
 * get X coordinate for this element
 *
 * @return
 * @throws Exception
 */
public double getOriginX() throws Exception {
    JSONObject rect = (JSONObject) getRect();
    double x = rect.getDoubleValue("x");
    return x;
}
 
Example 12
Source Project: wd.java   File: Element.java    License: MIT License 2 votes vote down vote up
/**
 * get Y coordinater for this element
 *
 * @return
 * @throws Exception
 */
public double getOriginY() throws Exception {
    JSONObject rect = (JSONObject) getRect();
    double y = rect.getDoubleValue("y");
    return y;
}
 
Example 13
Source Project: wd.java   File: Element.java    License: MIT License 2 votes vote down vote up
/**
 * get width for this element
 *
 * @return
 * @throws Exception
 */
public double getWidth() throws Exception {
    JSONObject rect = (JSONObject) getRect();
    double width = rect.getDoubleValue("width");
    return width;
}
 
Example 14
Source Project: wd.java   File: Element.java    License: MIT License 2 votes vote down vote up
/**
 * get height for this element
 *
 * @return
 * @throws Exception
 */
public double getHeight() throws Exception {
    JSONObject rect = (JSONObject) getRect();
    double height = rect.getDoubleValue("height");
    return height;
}