當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。