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


Java JsonObject.getInt方法代码示例

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


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

示例1: notifyMessageReceived

import javax.json.JsonObject; //导入方法依赖的package包/类
/** Notify listener that a message has been received */
protected final void notifyMessageReceived(JsonObject message) {
  // If there's no id, it's an event message.
  if (message.containsKey("id")) {
    int commandId = message.getInt("id");
    CommandFuture future = idToFuture.remove(commandId);
    if (future != null) {
      future.set(message);
    }
    // Or, it's a result object if it has a method.
  } else if (message.containsKey("method")) {
    DevtoolsEvent event = DevtoolsEvent.fromJson(message);
    for (Consumer<DevtoolsEvent> listener : eventListeners) {
      listener.accept(event);
    }
  } // Drop the message if we cannot identify it.
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:18,代码来源:DevtoolsDebugger.java

示例2: exceptionalStats

import javax.json.JsonObject; //导入方法依赖的package包/类
@Test
public void exceptionalStats() {
    try {
        invokeMethod("exceptional");
    } catch (Exception ex) {
    }
    //[{"hostName":"unknown","methodName":"public java.lang.String com.bmw.eve.fastandslow.boundary.Invoker.exceptional()",
    //"recentDuration":0,"minDuration":0,"maxDuration":0,"averageDuration":0,"numberOfExceptions":1,"numberOfInvocations":1,
    //"exception":"java.lang.IllegalStateException: Don't call me!","lastInvocationTimestamp":1469431094017,"totalDuration":0}]
    JsonArray invocationStatistics = this.methodsMonitoringTarget.
            request(MediaType.APPLICATION_JSON).
            get(JsonArray.class);
    assertThat(invocationStatistics.size(), is(1));
    System.out.println("invocationStatistics = " + invocationStatistics);
    long count = invocationStatistics.stream().map(a -> (JsonObject) a).
            map(i -> i.getString("methodName")).
            filter(m -> !m.contains("exceptional")).
            count();
    assertThat(count, is(0l));
    JsonObject invocation = invocationStatistics.getJsonObject(0);
    int numberOfInvocations = invocation.getInt("numberOfInvocations");
    assertThat(numberOfInvocations, is(1));
    int numberOfExceptions = invocation.getInt("numberOfExceptions");
    assertThat(numberOfExceptions, is(1));
}
 
开发者ID:AdamBien,项目名称:perceptor,代码行数:26,代码来源:MonitoringIT.java

示例3: updateSensor

import javax.json.JsonObject; //导入方法依赖的package包/类
@Override
public void updateSensor(JsonObject obj) throws UpdateException {
    try {
        setName(obj.getString("name"));

        JsonObject state = obj.getJsonObject("state");

        int t = state.getInt("temperature");
        BigDecimal temp = new BigDecimal(t).movePointLeft(2);

        SimpleDateFormat sdf = new SimpleDateFormat(Constants.HUEDATEFORMAT);
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
        Date time = sdf.parse(state.getString("lastupdated"));

        SensorValue<BigDecimal> val = new SensorValue<>(time, temp);
        updateValue(val);

        JsonObject conf = obj.getJsonObject("config");
        setOn(conf.getBoolean("on"));
        setBattery(conf.getInt("battery"));
        setReachable(conf.getBoolean("reachable"));

    } catch (ParseException | NullPointerException | ClassCastException ex) {
        throw new UpdateException("Error updating temp sensor", ex);
    }
}
 
开发者ID:dainesch,项目名称:HueSense,代码行数:27,代码来源:TempSensor.java

示例4: validateCommand

import javax.json.JsonObject; //导入方法依赖的package包/类
@POST
@javax.ws.rs.Path("/commands/{commandName}/validate")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public JsonObject validateCommand(JsonObject content,
                                  @PathParam("commandName") @DefaultValue(DEFAULT_COMMAND_NAME) String commandName,
                                  @Context HttpHeaders headers)
        throws Exception {
    validateCommand(commandName);
    JsonObjectBuilder builder = createObjectBuilder();
    try (CommandController controller = getCommand(commandName, ForgeInitializer.getRoot(), headers)) {
        controller.getContext().getAttributeMap().put("action", "validate");
        helper.populateController(content, controller);
        int stepIndex = content.getInt("stepIndex", 1);
        if (controller instanceof WizardCommandController) {
            WizardCommandController wizardController = (WizardCommandController) controller;
            for (int i = 0; i < stepIndex; i++) {
                wizardController.next().initialize();
                helper.populateController(content, wizardController);
            }
        }
        helper.describeValidation(builder, controller);
        helper.describeInputs(builder, controller);
        helper.describeCurrentState(builder, controller);
    }
    return builder.build();
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:28,代码来源:LaunchResource.java

示例5: nextStep

import javax.json.JsonObject; //导入方法依赖的package包/类
@POST
@javax.ws.rs.Path("/commands/{commandName}/next")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public JsonObject nextStep(JsonObject content,
                           @PathParam("commandName") @DefaultValue(DEFAULT_COMMAND_NAME) String commandName,
                           @Context HttpHeaders headers)
        throws Exception {
    validateCommand(commandName);
    int stepIndex = content.getInt("stepIndex", 1);
    JsonObjectBuilder builder = createObjectBuilder();
    try (CommandController controller = getCommand(commandName, ForgeInitializer.getRoot(), headers)) {
        if (!(controller instanceof WizardCommandController)) {
            throw new WebApplicationException("Controller is not a wizard", Status.BAD_REQUEST);
        }
        controller.getContext().getAttributeMap().put("action", "next");
        WizardCommandController wizardController = (WizardCommandController) controller;
        helper.populateController(content, controller);
        for (int i = 0; i < stepIndex; i++) {
            wizardController.next().initialize();
            helper.populateController(content, wizardController);
        }
        helper.describeMetadata(builder, controller);
        helper.describeInputs(builder, controller);
        helper.describeCurrentState(builder, controller);
    }
    return builder.build();
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:29,代码来源:LaunchResource.java

示例6: parseIntrospectResponse

import javax.json.JsonObject; //导入方法依赖的package包/类
private OAuthIntrospectResponse parseIntrospectResponse(String introspectJson)
{
    JsonReader jsonReader = _jsonReaderFactory.createReader(new StringReader(introspectJson));
    JsonObject jsonObject = jsonReader.readObject();

    return new OAuthIntrospectResponse(jsonObject.getBoolean("active"), jsonObject.getString("sub"),
            jsonObject.getString("scope"), jsonObject.getInt("exp"));
}
 
开发者ID:curityio,项目名称:oauth-filter-for-java,代码行数:9,代码来源:OpaqueTokenValidator.java

示例7: storeBeans

import javax.json.JsonObject; //导入方法依赖的package包/类
@POST
public void storeBeans(JsonObject object) {
    final String beanOrigin = object.getString("beanOrigin", null);
    final int amount = object.getInt("amount", 0);

    if (beanOrigin == null || amount == 0)
        throw new BadRequestException();

    commandService.storeBeans(beanOrigin, amount);
}
 
开发者ID:sdaschner,项目名称:scalable-coffee-shop,代码行数:11,代码来源:BeansResource.java

示例8: getLocation

import javax.json.JsonObject; //导入方法依赖的package包/类
public Point getLocation() throws Exception {
  String f =
      "(function(arg) { "
          + "var loc = "
          + JsAtoms.getLocation("arg")
          + ";"
          + "return "
          + JsAtoms.stringify("loc")
          + ";})";
  JsonObject response =
      getInspectorResponse(f, true, callArgument().withObjectId(getRemoteObject().getId()));
  String s = inspector.cast(response);
  JsonObject o = JavaxJson.parseObject(s);
  return new Point(o.getInt("left"), o.getInt("top"));
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:16,代码来源:RemoteWebElement.java

示例9: findElementByCSSSelector

import javax.json.JsonObject; //导入方法依赖的package包/类
public RemoteWebElement findElementByCSSSelector(String selector) {
  JsonObject response = inspector.sendCommand(DOM.querySelector(nodeId.getId(), selector));
  // TODO freynaud
  NodeId id = new NodeId(response.getInt("nodeId"));
  if (!id.exist()) {
    throw new NoSuchElementException("no element matching " + selector);
  }
  RemoteWebElement res = new RemoteWebElement(id, inspector);
  return res;
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:11,代码来源:RemoteWebElement.java

示例10: getRatings

import javax.json.JsonObject; //导入方法依赖的package包/类
private JsonObject getRatings(Cookie user, String xreq, String xtraceid, String xspanid,
                              String xparentspanid, String xsampled, String xflags, String xotspan){
  ClientBuilder cb = ClientBuilder.newBuilder();
  String timeout = star_color.equals("black") ? "10000" : "2500";
  cb.property("com.ibm.ws.jaxrs.client.connection.timeout", timeout);
  cb.property("com.ibm.ws.jaxrs.client.receive.timeout", timeout);
  Client client = cb.build();
  WebTarget ratingsTarget = client.target(ratings_service);
  Invocation.Builder builder = ratingsTarget.request(MediaType.APPLICATION_JSON);
  if(xreq!=null) {
    builder.header("x-request-id",xreq);
  }
  if(xtraceid!=null) {
    builder.header("x-b3-traceid",xtraceid);
  }
  if(xspanid!=null) {
    builder.header("x-b3-spanid",xspanid);
  }
  if(xparentspanid!=null) {
    builder.header("x-b3-parentspanid",xparentspanid);
  }
  if(xsampled!=null) {
    builder.header("x-b3-sampled",xsampled);
  }
  if(xflags!=null) {
    builder.header("x-b3-flags",xflags);
  }
  if(xotspan!=null) {
    builder.header("x-ot-span-context",xotspan);
  }
  if(user!=null) {
    builder.cookie(user);
  }
  Response r = builder.get();
  int statusCode = r.getStatusInfo().getStatusCode();
  if (statusCode == Response.Status.OK.getStatusCode() ) {
    StringReader stringReader = new StringReader(r.readEntity(String.class));
    try (JsonReader jsonReader = Json.createReader(stringReader)) {
       JsonObject j = jsonReader.readObject();
       JsonObjectBuilder jb = Json.createObjectBuilder();
       for(String key : j.keySet()){
         int count = j.getInt(key);
         String stars = "<font color=\""+ star_color +"\">";
         for(int i=0; i<count; i++){
           stars += "<span class=\"glyphicon glyphicon-star\"></span>";
         }
         stars += "</font>";
         if(count<5){
           for(int i=0; i<(5-count); i++){
             stars += "<span class=\"glyphicon glyphicon-star-empty\"></span>";
           }
         }
         jb.add(key,stars);
       }
       JsonObject result = jb.build();
       return result;
    }
  }else{
    System.out.println("Error: unable to contact "+ratings_service+" got status of "+statusCode);
    return null;
  }
}
 
开发者ID:IBM,项目名称:microservices-traffic-management-using-istio,代码行数:63,代码来源:LibertyRestEndpoint.java

示例11: numberOfTimeouts

import javax.json.JsonObject; //导入方法依赖的package包/类
static int numberOfTimeouts(JsonObject input) {
    assertNotNull(input);
    return input.getInt("addition-timeouts");
}
 
开发者ID:AdamBien,项目名称:javaee-calculator,代码行数:5,代码来源:AdditionTimeoutResourceIT.java

示例12: BeansStored

import javax.json.JsonObject; //导入方法依赖的package包/类
public BeansStored(JsonObject jsonObject) {
    this(jsonObject.getString("beanOrigin"), jsonObject.getInt("amount"), Instant.parse(jsonObject.getString("instant")));
}
 
开发者ID:sdaschner,项目名称:scalable-coffee-shop,代码行数:4,代码来源:BeansStored.java

示例13: testModifyAceForUser

import javax.json.JsonObject; //导入方法依赖的package包/类
@Test 
public void testModifyAceForUser() throws IOException, JsonException {
	testUserId = H.createTestUser();
	
	testFolderUrl = H.createTestFolder();
	
       String postUrl = testFolderUrl + ".modifyAce.html";

	List<NameValuePair> postParams = new ArrayList<NameValuePair>();
	postParams.add(new NameValuePair("principalId", testUserId));
	postParams.add(new NameValuePair("[email protected]:read", "granted"));
	postParams.add(new NameValuePair("[email protected]:write", "denied"));
	postParams.add(new NameValuePair("[email protected]:modifyAccessControl", "bogus")); //invalid value should be ignored.
	
	Credentials creds = new UsernamePasswordCredentials("admin", "admin");
	H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null);
	
	
	//fetch the JSON for the acl to verify the settings.
	String getUrl = testFolderUrl + ".acl.json";

	String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
	assertNotNull(json);
	JsonObject jsonObject = JsonUtil.parseObject(json);
	assertEquals(1, jsonObject.size());
	
	JsonObject aceObject = jsonObject.getJsonObject(testUserId);
	assertNotNull(aceObject);
	
	String principalString = aceObject.getString("principal");
	assertEquals(testUserId, principalString);

        int order = aceObject.getInt("order");
        assertEquals(0, order);

	JsonArray grantedArray = aceObject.getJsonArray("granted");
	assertNotNull(grantedArray);
	assertEquals(1, grantedArray.size());
	assertEquals("jcr:read", grantedArray.getString(0));

	JsonArray deniedArray = aceObject.getJsonArray("denied");
	assertNotNull(deniedArray);
	assertEquals(1, deniedArray.size());
	assertEquals("jcr:write", deniedArray.getString(0));
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-launchpad-integration-tests,代码行数:46,代码来源:ModifyAceTest.java

示例14: getWebElement

import javax.json.JsonObject; //导入方法依赖的package包/类
public RemoteWebElement getWebElement() throws JSONException, Exception {
  JsonObject result = inspector.sendCommand(DOM.requestNode(objectId));
  int id = result.getInt("nodeId");
  NodeId nodeId = new NodeId(id);
  return new RemoteWebElement(nodeId, this, inspector);
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:7,代码来源:RemoteObject.java

示例15: getEventsCount

import javax.json.JsonObject; //导入方法依赖的package包/类
public static int getEventsCount(HttpTestBase b, String topic) throws JsonException, IOException {
    final JsonObject json = JsonUtil.parseObject(b.getContent(HttpTest.HTTP_BASE_URL + "/testing/EventsCounter.json", HttpTest.CONTENT_TYPE_JSON));
    return json.containsKey(topic) ? json.getInt(topic) : 0;
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-launchpad-integration-tests,代码行数:5,代码来源:EventsCounterUtil.java


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