当前位置: 首页>>代码示例>>Java>>正文


Java JsonObject.getInteger方法代码示例

本文整理汇总了Java中io.vertx.core.json.JsonObject.getInteger方法的典型用法代码示例。如果您正苦于以下问题:Java JsonObject.getInteger方法的具体用法?Java JsonObject.getInteger怎么用?Java JsonObject.getInteger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.vertx.core.json.JsonObject的用法示例。


在下文中一共展示了JsonObject.getInteger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addToList

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
private void addToList(RoutingContext rc) {
    JsonObject json = rc.getBodyAsJson();
    int quantity = json.getInteger("quantity", 1);
    if (quantity <= 0) {
        rc.response().setStatusCode(400);
        return;
    }

    redis.hset(KEY, json.getString("name"), Integer.toString(quantity), r -> {
        if (r.succeeded()) {
            getList(rc);
        } else {
            rc.fail(r.cause());
        }
    });

}
 
开发者ID:cescoffier,项目名称:vertx-chtijug-2017,代码行数:18,代码来源:MyShoppingVerticle.java

示例2: applyForOauth

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
/**
 * 申请微信授权
 * /awp/wxOauth/apply/{body}
 * web服务需要授权时,向用户发送重定向,重定向到当前接口
 * 参数只有一个,内容为JSON,请用http://localhost:8083/awp/base64.html进行加密
 * {
 * "eid":web项目使用的公众号在本项目中的用户ID
 * "type":0=静默授权,只能获取OpenID,1=正常授权,会弹出授权确认页面,可以获取到用户信息
 * "callback":授权成功后调用的web项目回调接口地址,请使用完整地址,
 * 回调时会使用GET方法,加上rs参数,
 * 如果静默授权,rs参数内容就是openid
 * 如果正常授权,rs参数内容是turingBase64加密的授权结果(JSON)
 * }
 *
 * @param rc Vertx的RoutingContext对象
 * @author Leibniz.Hu
 */
private void applyForOauth(RoutingContext rc) {
    HttpServerResponse resp = rc.response();
    String decodedBody = TuringBase64Util.decode(rc.request().getParam("body"));
    JsonObject reqJson = new JsonObject(decodedBody);
    Integer eid = reqJson.getInteger("eid");
    int type = reqJson.getInteger("type");
    String callback = TuringBase64Util.encode(reqJson.getString("callback"));//授权后回调方法
    vertx.eventBus().<JsonObject>send(ADDR_ACCOUNT_DB.get(), makeMessage(COMMAND_GET_ACCOUNT_BY_ID, eid), ar -> {
        if (ar.succeeded()) {
            JsonObject account = ar.result().body();
            String redirectAfterUrl = PROJ_URL + "oauth/wx/" + (type == 0 ? "baseCb" : "infoCb") + "?eid=" + eid + "&visitUrl=" + callback;
            String returnUrl = null;
            try {
                returnUrl = String.format((type == 0 ? OAUTH_BASE_API : OAUTH_INFO_API)
                        , account.getString(WXAPPID), URLEncoder.encode(redirectAfterUrl, "UTF-8"));
            } catch (UnsupportedEncodingException ignored) { //不可能出现的
            }
            resp.setStatusCode(302).putHeader("Location", returnUrl).end();
        } else {
            log.error("EventBus消息响应错误", ar.cause());
            resp.setStatusCode(500).end("EventBus error!");
        }
    });
}
 
开发者ID:Leibnizhu,项目名称:AlipayWechatPlatform,代码行数:42,代码来源:WechatOauthSubRouter.java

示例3: init

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
/**
 * Read the configuration and set the initial values.
 * @param config the configuration
 */
void init(JsonObject config) {
  period = config.getLong("period", 3000L);
  variation = config.getInteger("variation", 100);
  name = config.getString("name");
  Objects.requireNonNull(name);
  symbol = config.getString("symbol", name);
  stocks = config.getInteger("volume", 10000);
  price = config.getDouble("price", 100.0);

  value = price;
  ask = price + random.nextInt(variation / 2);
  bid = price + random.nextInt(variation / 2);

  share = stocks / 2;

  System.out.println("Initialized " + name);
}
 
开发者ID:cescoffier,项目名称:vertx-kubernetes-workshop,代码行数:22,代码来源:MarketDataVerticle.java

示例4: updateAfterPaid

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
/**
 * 支付完成后,更新订单信息
 * 包括支付平台的订单ID,以及支付时间
 */
public void updateAfterPaid(JsonObject order, Handler<Integer> callback) {
    String platOrderId = order.getString(PLATORDERID);
    if (platOrderId == null || platOrderId.length() == 0) {
        throw new IllegalArgumentException("OrderId of pay platform cannot be null!!!");
    }
    String orderId = order.getString(ORDERID);
    if (orderId == null || orderId.length() == 0)
        throw new IllegalArgumentException("OrderId in Order object cannot be null!!!");
    Integer type = order.getInteger(TYPE);
    if (type == null)
        throw new IllegalArgumentException("Type in Order object cannot be null!!!");
    String sql = "UPDATE awp_order SET platOrderId = ?, payTime = NOW() where orderId=? and type=?";
    JsonArray params = new JsonArray().add(platOrderId).add(orderId).add(type);
    update(sql, params, callback);
}
 
开发者ID:Leibnizhu,项目名称:AlipayWechatPlatform,代码行数:20,代码来源:OrderDao.java

示例5: getChannel

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
/**
 * @param vertx  Vert.x instance
 * @param config configuration
 * @return ManagedChannel
 */
public static ManagedChannel getChannel(final Vertx vertx,
                                        final JsonObject config) {
    final String rpcHost = config.getString(Key.HOST);
    final Integer rpcPort = config.getInteger(Key.PORT);
    LOGGER.info(Info.CLIENT_RPC, rpcHost, String.valueOf(rpcPort));
    final VertxChannelBuilder builder =
            VertxChannelBuilder
                    .forAddress(vertx, rpcHost, rpcPort);
    Fn.safeSemi(null != config.getValue(Key.SSL), LOGGER,
            () -> {
                final JsonObject sslConfig = config.getJsonObject(Key.SSL);
                if (null != sslConfig && !sslConfig.isEmpty()) {
                    final Object type = sslConfig.getValue("type");
                    final CertType certType = null == type ?
                            CertType.PEM : Types.fromStr(CertType.class, type.toString());
                    final TrustPipe<JsonObject> pipe = TrustPipe.get(certType);
                    // Enable SSL
                    builder.useSsl(pipe.parse(sslConfig));
                } else {
                    builder.usePlaintext(true);
                }
            });
    return builder.build();
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:30,代码来源:RpcSslTool.java

示例6: createFromJSON

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
public static Message createFromJSON (JsonObject json) {
    Message message = new Message();

    //get header information
    message.event = json.getString("event");
    String messageID = json.getString("messageID");
    int statusCode = json.getInteger("statusCode");
    message.type = ResponseType.getByString(json.getString("status"));
    message.data = json.getJsonObject("data");
    message.ssid = json.getString("ssid");

    if (!messageID.isEmpty() && !messageID.equals("none")) {
        //get UUID
        message.uuid = UUID.fromString(messageID);
    }

    return message;
}
 
开发者ID:open-erp-systems,项目名称:erp-frontend,代码行数:19,代码来源:Message.java

示例7: create

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@Override
public Single<JsonObject> create(JsonObject item) {
  if (item == null) {
    return Single.error(new IllegalArgumentException("The item must not be null"));
  }
  if (item.getString("name") == null || item.getString("name").isEmpty()) {
    return Single.error(new IllegalArgumentException("The name must not be null or empty"));
  }
  if (item.getInteger("stock", 0) < 0) {
    return Single.error(new IllegalArgumentException("The stock must greater or equal to 0"));
  }
  if (item.containsKey("id")) {
    return Single.error(new IllegalArgumentException("The created item already contains an 'id'"));
  }

  return db.rxGetConnection()
    .flatMap(conn -> {
      JsonArray params = new JsonArray().add(item.getValue("name")).add(item.getValue("stock", 0));
      return conn
        .rxUpdateWithParams(INSERT, params)
        .map(ur -> item.put("id", ur.getKeys().getLong(0)))
        .doAfterTerminate(conn::close);
    });
}
 
开发者ID:cescoffier,项目名称:various-vertx-demos,代码行数:25,代码来源:JdbcProductStore.java

示例8: addToList

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
private void addToList(RoutingContext rc) {
    JsonObject json = rc.getBodyAsJson();
    String name = json.getString("name");
    Integer quantity = json
        .getInteger("quantity", 1);

    client.hset(KEY, name, quantity.toString(), x -> {
        getList(rc);
    });
}
 
开发者ID:cescoffier,项目名称:vertx-chtijug-2017,代码行数:11,代码来源:ShoppingBackend.java

示例9: buy

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@Override
public void buy(int amount, JsonObject quote, Handler<AsyncResult<Portfolio>> resultHandler) {
    if (amount <= 0) {
        resultHandler.handle(Future.failedFuture("Cannot buy " + quote.getString("name") + " - the amount must be " +
            "greater than 0"));
        return;
    }

    if (quote.getInteger("shares") < amount) {
        resultHandler.handle(Future.failedFuture("Cannot buy " + amount + " - not enough " +
            "stocks on the market (" + quote.getInteger("shares") + ")"));
        return;
    }

    double price = amount * quote.getDouble("ask");
    String name = quote.getString("name");
    // 1) do we have enough money
    if (portfolio.getCash() >= price) {
        // Yes, buy it
        portfolio.setCash(portfolio.getCash() - price);
        int current = portfolio.getAmount(name);
        int newAmount = current + amount;
        portfolio.getShares().put(name, newAmount);
        sendActionOnTheEventBus("BUY", amount, quote, newAmount);
        resultHandler.handle(Future.succeededFuture(portfolio));
    } else {
        resultHandler.handle(Future.failedFuture("Cannot buy " + amount + " of " + name + " - " + "not enough money, " +
            "need " + price + ", has " + portfolio.getCash()));
    }
}
 
开发者ID:cescoffier,项目名称:vertx-kubernetes-workshop,代码行数:31,代码来源:PortfolioServiceImpl.java

示例10: update

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@Override
public Completable update(long id, JsonObject item) {
  if (item == null) {
    return Completable.error(new IllegalArgumentException("The item must not be null"));
  }
  if (item.getString("name") == null || item.getString("name").isEmpty()) {
    return Completable.error(new IllegalArgumentException("The name must not be null or empty"));
  }
  if (item.getInteger("stock", 0) < 0) {
    return Completable.error(new IllegalArgumentException("The stock must greater or equal to 0"));
  }
  if (item.containsKey("id") && id != item.getInteger("id")) {
    return Completable.error(new IllegalArgumentException("The 'id' cannot be changed"));
  }

  return db.rxGetConnection()
    .flatMapCompletable(conn -> {
      JsonArray params = new JsonArray().add(item.getValue("name")).add(item.getValue("stock", 0)).add(id);
      return conn.rxUpdateWithParams(UPDATE, params)
        .flatMapCompletable(up -> {
          if (up.getUpdated() == 0) {
            return Completable.error(new NoSuchElementException("Unknown item '" + id + "'"));
          }
          return Completable.complete();
        })
        .doAfterTerminate(conn::close);
    });
}
 
开发者ID:cescoffier,项目名称:various-vertx-demos,代码行数:29,代码来源:JdbcProductStore.java

示例11: handleNotification

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
private void handleNotification(ProtonDelivery delivery, Message message) {
    JsonObject json = new JsonObject(Buffer.buffer(((Data) message.getBody()).getValue().getArray()));
    String deviceId = json.getString("device-id");
    int temperature = json.getInteger("temperature");

    log.info("Received notification with payload {}", json);

    adjustTemperature(deviceId, temperature);
}
 
开发者ID:EnMasseProject,项目名称:enmasse-workshop,代码行数:10,代码来源:Thermostat.java

示例12: addToList

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
private void addToList(RoutingContext rc) {
    JsonObject json = rc.getBodyAsJson();
    String name = json.getString("name");
    Integer quantity = json.getInteger("quantity", 1);
    redis.hset(KEY, name, quantity.toString(), x -> {
        getList(rc);
    });
}
 
开发者ID:cescoffier,项目名称:vertx-kubernetes-live-coding-devoxx-ma,代码行数:9,代码来源:ShoppingBackendVerticle.java

示例13: createRecord

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
private Record createRecord(final JsonObject item) {
    final String name = item.getString(NAME);
    final String host = item.getString(HOST);
    final Integer port = item.getInteger(PORT);
    final JsonObject meta = item.getJsonObject(META);
    return HttpEndpoint.createRecord(
            name, host, port, "/*", meta
    );
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:10,代码来源:EndPointOrigin.java

示例14: VertxPrometheusOptions

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
public VertxPrometheusOptions(@NotNull JsonObject json) {
  super(json);
  host = json.getString("host", DEFAULT_HOST);
  port = json.getInteger("port", DEFAULT_PORT);
  metrics = EnumSet.noneOf(MetricsType.class);
  for (Object metric : json.getJsonArray("metrics", EMPTY_METRICS).getList()) {
    metrics.add(MetricsType.valueOf(metric.toString()));
  }
}
 
开发者ID:nolequen,项目名称:vertx-prometheus-metrics,代码行数:10,代码来源:VertxPrometheusOptions.java

示例15: queryTimeSeries

import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
/**
 * Searches datapoints within range and for selected targets
 *
 * @param msg
 */
void queryTimeSeries(final Message<JsonObject> msg) {

    long start = System.currentTimeMillis();
    final JsonObject query = msg.body();
    LOG.debug("{}\n{}", address, query.encodePrettily());

    // get the paramsters from the query
    final Range range = rangeParser.parse(query.getJsonObject("range").getString("from"),
                                          query.getJsonObject("range").getString("to"));
    final Integer limit = query.getInteger("maxDataPoints");
    final String interval = query.getString("interval");

    List<Future> futures = range.split(numChunks)
                                .stream()
                                .map(rc -> Tuple.of(obj().put("range",
                                                              obj().put("from", rc.getStartString())
                                                                   .put("to", rc.getEndString()))
                                                         .put("interval", interval)
                                                         .put("maxDataPoints", limit / numChunks)
                                                         .put("targets", query.getJsonArray("targets")),
                                                    Future.<Message<JsonObject>>future()))
                                .map(tup -> {
                                    vertx.eventBus()
                                         .send(queryChunkAddress, tup.getFirst(), tup.getSecond().completer());
                                    return tup.getSecond();
                                })
                                .collect(toList());

    CompositeFuture.all(futures).setHandler(result -> {
        if (result.succeeded()) {
            JsonArray rawResult = result.result()
                                        .list()
                                        .stream()
                                        .map(o -> (Message) o)
                                        .map(m -> (JsonArray) m.body())
                                        .collect(toMergedResult());
            // POST Processing if registered
            if (this.postProcessingAddress != null) {
                vertx.eventBus().send(this.postProcessingAddress, rawResult, ppReply -> {
                    if (ppReply.succeeded()) {
                        sendReply(msg, rawResult.addAll((JsonArray) ppReply.result().body()), start);
                    } else {
                        LOG.error("PostProcessing failed", ppReply.cause());
                        sendReply(msg, rawResult, start);
                        this.postProcessingAddress = null;
                    }
                });
            } else {
                sendReply(msg, rawResult, start);
            }
        } else {
            LOG.warn("Could not process query", result.cause());
        }
    });
}
 
开发者ID:gmuecke,项目名称:grafana-vertx-datasource,代码行数:61,代码来源:SplitMergeTimeSeriesVerticle.java


注:本文中的io.vertx.core.json.JsonObject.getInteger方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。