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


Java JsonArray类代码示例

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


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

示例1: processChoiceBoxColumnName

import io.vertx.core.json.JsonArray; //导入依赖的package包/类
private TableColumn processChoiceBoxColumnName(String name, JsonArray items){
    TableColumn column = new TableColumn(name);
    column.setCellValueFactory( p -> ((TableColumn.CellDataFeatures<Item, Object>)p).getValue().getStringProperty(name));
    ObservableList list = FXCollections.observableArrayList();
    if(items!=null) list.addAll(items.getList());
    column.setCellFactory(ChoiceBoxTableCell.forTableColumn(list));
    column.setOnEditCommit( t -> {
        int index = ((TableColumn.CellEditEvent<Item, Object>) t).getTablePosition().getRow();
        Item item = ((TableColumn.CellEditEvent<Item, Object>) t).getTableView().getItems().get(index);
        item.setProperty(name,((TableColumn.CellEditEvent<Item, Object>) t).getNewValue());
    });
    columnMap.put(name, column);
    return column;
}
 
开发者ID:whitewoodcity,项目名称:xbrowser,代码行数:15,代码来源:TableView.java

示例2: reformatJsonArray

import io.vertx.core.json.JsonArray; //导入依赖的package包/类
private static JsonArray reformatJsonArray(JsonArray result, CaseConversion conversion, boolean capitalAtStart) {
    if (result == null || result.isEmpty()) {
        return new JsonArray();
    }
    List<Object> reformatedList = new LinkedList<>();
    for (Object obj : result.getList()) {
        if (obj instanceof JsonObject || obj instanceof Map) {
            @SuppressWarnings("unchecked")
            JsonObject jsonObject = (obj instanceof JsonObject) ? (JsonObject) obj
                    : new JsonObject((Map<String, Object>) obj);
            reformatedList.add(reformatJsonObject(jsonObject, conversion, capitalAtStart));
        } else {
            reformatedList.add(obj);
        }
    }
    return new JsonArray(reformatedList);

}
 
开发者ID:ARMmbed,项目名称:mbed-cloud-sdk-java,代码行数:19,代码来源:Serializer.java

示例3: visit

import io.vertx.core.json.JsonArray; //导入依赖的package包/类
private ConcurrentMap<Integer, ServidorOptions> visit(final JsonArray serverData)
        throws ZeroException {
    LOGGER.info(Info.INF_B_VERIFY, KEY, ServerType.IPC, serverData.encode());
    Ruler.verify(KEY, serverData);
    final ConcurrentMap<Integer, ServidorOptions> map =
            new ConcurrentHashMap<>();
    Fn.itJArray(serverData, JsonObject.class, (item, index) -> {
        if (isServer(item)) {
            // 1. Extract port
            final int port = extractPort(item.getJsonObject(YKEY_CONFIG));
            // 2. Convert JsonObject to HttpServerOptions
            final ServidorOptions options = this.transformer.transform(item);
            Fn.safeNull(() -> {
                // 3. Add to map;
                map.put(port, options);
            }, port, options);
        }
    });
    LOGGER.info(Info.INF_A_VERIFY, KEY, ServerType.IPC, map.keySet());
    return map;
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:22,代码来源:RpcServerVisitor.java

示例4: handle

import io.vertx.core.json.JsonArray; //导入依赖的package包/类
@Override
public void handle(RoutingContext rc) {
  Long genreId = PathUtil.parseLongParam(rc.pathParam("genreId"));
  if (genreId == null) {
    rc.next();
    return;
  }

  dbClient.rxGetConnection().flatMap(sqlConnection -> {
    Single<JsonObject> gs = findGenre(sqlConnection, genreId);
    Single<JsonArray> als = findAlbums(sqlConnection, genreId);
    Single<JsonArray> ars = findArtists(sqlConnection, genreId);

    return Single.zip(gs, als, ars, (genre, albums, artists) -> {
      Map<String, Object> data = new HashMap<>();
      data.put("genre", genre);
      data.put("albums", albums);
      data.put("artists", artists);
      return data;
    }).doAfterTerminate(sqlConnection::close);
  }).flatMap(data -> {
    data.forEach(rc::put);
    return templateEngine.rxRender(rc, "templates/genre");
  }).subscribe(rc.response()::end, rc::fail);
}
 
开发者ID:tsegismont,项目名称:vertx-musicstore,代码行数:26,代码来源:GenreHandler.java

示例5: getSubscriptionBody

import io.vertx.core.json.JsonArray; //导入依赖的package包/类
private JsonArray getSubscriptionBody() {
	final JsonArray result = new JsonArray();
	final JsonObject subscribe = new JsonObject();
	final JsonObject ext = new JsonObject();
	final JsonObject replay = new JsonObject();
	// TODO: Handling of Replay options need to be fixed here!
	replay.put(this.getListenerConfig().getListenSubject(), -2);
	ext.put("replay", replay);
	subscribe.put("ext", ext);
	subscribe.put("clientId", this.clientId);
	subscribe.put("channel", "/meta/subscribe");
	subscribe.put("subscription", this.getListenerConfig().getListenSubject());
	subscribe.put("id", "3");
	result.add(subscribe);
	return result;
}
 
开发者ID:Stwissel,项目名称:vertx-sfdc-platformevents,代码行数:17,代码来源:CometD.java

示例6: fetchPage

import io.vertx.core.json.JsonArray; //导入依赖的package包/类
@Override
public WikiDatabaseService fetchPage(String name, Handler<AsyncResult<JsonObject>> resultHandler) {
  dbClient.queryWithParams(sqlQueries.get(SqlQuery.GET_PAGE), new JsonArray().add(name), fetch -> {
    if (fetch.succeeded()) {
      JsonObject response = new JsonObject();
      ResultSet resultSet = fetch.result();
      if (resultSet.getNumRows() == 0) {
        response.put("found", false);
      } else {
        response.put("found", true);
        JsonArray row = resultSet.getResults().get(0);
        response.put("id", row.getInteger(0));
        response.put("rawContent", row.getString(1));
      }
      resultHandler.handle(Future.succeededFuture(response));
    } else {
      LOGGER.error("Database query error", fetch.cause());
      resultHandler.handle(Future.failedFuture(fetch.cause()));
    }
  });
  return this;
}
 
开发者ID:vert-x3,项目名称:vertx-guide-for-java-devs,代码行数:23,代码来源:WikiDatabaseServiceImpl.java

示例7: handle

import io.vertx.core.json.JsonArray; //导入依赖的package包/类
@Override
public void handle(RoutingContext rc) {
  Long artistId = PathUtil.parseLongParam(rc.pathParam("artistId"));
  if (artistId == null) {
    rc.next();
    return;
  }

  dbClient.rxGetConnection().flatMap(sqlConnection -> {
    Single<JsonObject> ars = findArtist(sqlConnection, artistId);
    Single<JsonArray> als = findAlbums(sqlConnection, artistId);

    return Single.zip(ars, als, (artist, albums) -> {
      Map<String, Object> data = new HashMap<>(2);
      data.put("artist", artist);
      data.put("albums", albums);
      return data;
    }).doAfterTerminate(sqlConnection::close);

  }).flatMap(data -> {
    data.forEach(rc::put);
    return templateEngine.rxRender(rc, "templates/artist");
  }).subscribe(rc.response()::end, rc::fail);
}
 
开发者ID:tsegismont,项目名称:vertx-musicstore,代码行数:25,代码来源:ArtistHandler.java

示例8: rootHandler

import io.vertx.core.json.JsonArray; //导入依赖的package包/类
/**
 * Handler for the /api endpoint, listing out routes and loaded verticles
 * 
 * @param ctx
 */
private void rootHandler(final RoutingContext ctx) {
	ctx.response().putHeader(Constants.CONTENT_HEADER, Constants.CONTENT_TYPE_JSON);
	final JsonObject result = new JsonObject().put("RunningSince", Utils.getDateString(this.startDate));
	final JsonObject routeObject = new JsonObject();
	for (final Route r : this.router.getRoutes()) {
		final String p = r.getPath();
		if (p != null) {
			routeObject.put(p, String.valueOf(r));
		}
	}
	result.put("Routes", routeObject);
	final JsonArray verticleArray = new JsonArray(this.loadedVerticles);
	result.put("Verticles", verticleArray);
	ctx.response().end(result.encodePrettily());
}
 
开发者ID:Stwissel,项目名称:vertx-sfdc-platformevents,代码行数:21,代码来源:ApplicationStarter.java

示例9: getBookById

import io.vertx.core.json.JsonArray; //导入依赖的package包/类
@Override
public BookDatabaseService getBookById(int id, Handler<AsyncResult<JsonObject>> resultHandler) {
  pgConnectionPool.rxPreparedQuery(SQL_FIND_BOOK_BY_ID, Tuple.of(id))
    .map(PgResult::getDelegate)
    .subscribe(pgResult -> {
      JsonArray jsonArray = transformPgResultToJson(pgResult);
      if (jsonArray.size() == 0) {
        resultHandler.handle(Future.succeededFuture(new JsonObject()));
      } else {
        JsonObject dbResponse = jsonArray.getJsonObject(0);
        resultHandler.handle(Future.succeededFuture(dbResponse));
      }
    }, throwable -> {
      LOGGER.error("Failed to get the book by id " + id, throwable);
      resultHandler.handle(Future.failedFuture(throwable));
    });
  return this;
}
 
开发者ID:BillyYccc,项目名称:vertx-postgresql-starter,代码行数:19,代码来源:BookDatabaseServiceImpl.java

示例10: createSetCharHandler

import io.vertx.core.json.JsonArray; //导入依赖的package包/类
private Handler<AsyncResult<Set<Character>>> createSetCharHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      JsonArray arr = new JsonArray();
      for (Character chr: res.result()) {
        arr.add((int) chr);
      }
      msg.reply(arr);
    }
  };
}
 
开发者ID:pflima92,项目名称:jspare-vertx-ms-blueprint,代码行数:18,代码来源:NotificationServiceVertxProxyHandler.java

示例11: parseMenu

import io.vertx.core.json.JsonArray; //导入依赖的package包/类
protected void parseMenu (Stage stage, MenuBar menuBar, JsonArray jsonArray) {
    Platform.runLater(() -> {
        for (int i = 0; i < jsonArray.size(); i++) {
            //get menu entry
            JsonObject entry = jsonArray.getJsonObject(i);

            //get event and title
            //String event = entry.getString("event");
            String title = entry.getString("title");

            //create new menu
            Menu menu = new Menu(title);

            //add sub menus
            this.parseSubMenus(menu, entry.getJsonArray("submenus"));

            //add menu to menu bar
            menuBar.getMenus().add(menu);
        }

        menuBar.prefWidthProperty().bind(stage.widthProperty());
    });
}
 
开发者ID:open-erp-systems,项目名称:erp-frontend,代码行数:24,代码来源:DefaultMenuManager.java

示例12: deployToResteasy

import io.vertx.core.json.JsonArray; //导入依赖的package包/类
@Override
public Single<Void> deployToResteasy(VertxResteasyDeployment deployment) {
	JsonArray packages = AppGlobals.get().getConfig().getJsonArray("scan");
	if(packages == null) {
		System.err.println("Not scanning any packages, please specify the 'scan' array of packages in configuration");
	}else {
		String[] packagesToScan = (String[]) packages.getList().toArray(new String[packages.size()+1]);
		packagesToScan[packagesToScan.length-1] = "net.redpipe.engine";
		new FastClasspathScanner(packagesToScan)
			.matchClassesWithAnnotation(Path.class, klass -> {
				if(!Modifier.isAbstract(klass.getModifiers()))
					deployment.getActualResourceClasses().add(klass);
			})
			.matchClassesWithAnnotation(Provider.class, klass -> {
				if(!Modifier.isAbstract(klass.getModifiers()))
					deployment.getActualProviderClasses().add(klass);
			})
			.scan();
	}
	return Single.just(null);
}
 
开发者ID:FroMage,项目名称:redpipe,代码行数:22,代码来源:FCSPlugin.java

示例13: step4ActionSubscribe

import io.vertx.core.json.JsonArray; //导入依赖的package包/类
private void step4ActionSubscribe() {
	if (this.shuttingDown || this.shutdownCompleted) {
		this.shutdownCompleted = true;
		return;
	}

	final JsonArray body = this.getSubscriptionBody();
	final HttpRequest<Buffer> request = this.initWebPostRequest(Constants.URL_SUBSCRIBE);

	request.sendJson(body, postReturn -> {
		if (postReturn.succeeded()) {
			this.step4ResultSubscribe(postReturn.result());
		} else {
			this.logger.error(postReturn.cause());
		}
	});
}
 
开发者ID:Stwissel,项目名称:vertx-sfdc-platformevents,代码行数:18,代码来源:CometD.java

示例14: getAccountList

import io.vertx.core.json.JsonArray; //导入依赖的package包/类
/**
 * 查询所有账号
 * 返回JSON包括id,name,email字段
 * 需要管理员权限
 */
private void getAccountList(RoutingContext rc) {
    if (forbidAccess(rc, "id", false)) {
        return;
    }
    log.debug("即将发送EventBus消息查询所有账号");
    vertx.eventBus().<JsonArray>send(ADDR_ACCOUNT_DB.get(), makeMessage(COMMAND_GET_ALL_ACCOUNT), ar -> {
        HttpServerResponse response = rc.response();
        if(ar.succeeded()){
            JsonArray rows = ar.result().body();
            response.putHeader("content-type", "application/json; charset=utf-8").end(rows.toString());
        } else {
            log.error("EventBus消息响应错误", ar.cause());
            response.setStatusCode(500).end("EventBus error!");
        }
    });
}
 
开发者ID:Leibnizhu,项目名称:AlipayWechatPlatform,代码行数:22,代码来源:OfficialAccountSubRouter.java

示例15: testAddingView

import io.vertx.core.json.JsonArray; //导入依赖的package包/类
@Test
public void testAddingView() throws Exception {
    goAndWaitForPageToLoad();
    searchForMovie();
    openDetailView();
    WebElement addToViewsButton = driver.findElementByCssSelector("#add-watch > div.card-content");
    sleep(driver, 5, visibilityOf(addToViewsButton));
    addToViewsButton.click();
    WebElement watchStartNowButton = driver.findElementById("watchStartNow");
    sleep(driver, 5, visibilityOf(watchStartNowButton));
    watchStartNowButton.click();
    driver.findElement(id("watchEndCalculate")).click();
    driver.findElement(id("add-btn")).click();
    await().atMost(5, SECONDS).until(() -> localDatabase
            .queryBlocking("SELECT * FROM Views WHERE MovieId = ?", new JsonArray().add(315837))
            .size() > 0);
}
 
开发者ID:kristenkotkas,项目名称:moviediary,代码行数:18,代码来源:UiMoviesPageTest.java


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