本文整理汇总了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.
}
示例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));
}
示例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);
}
}
示例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();
}
示例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();
}
示例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"));
}
示例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);
}
示例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"));
}
示例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;
}
示例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;
}
}
示例11: numberOfTimeouts
import javax.json.JsonObject; //导入方法依赖的package包/类
static int numberOfTimeouts(JsonObject input) {
assertNotNull(input);
return input.getInt("addition-timeouts");
}
示例12: BeansStored
import javax.json.JsonObject; //导入方法依赖的package包/类
public BeansStored(JsonObject jsonObject) {
this(jsonObject.getString("beanOrigin"), jsonObject.getInt("amount"), Instant.parse(jsonObject.getString("instant")));
}
示例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);
}
示例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