當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonArray.size方法代碼示例

本文整理匯總了Java中io.vertx.core.json.JsonArray.size方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonArray.size方法的具體用法?Java JsonArray.size怎麽用?Java JsonArray.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.vertx.core.json.JsonArray的用法示例。


在下文中一共展示了JsonArray.size方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processInit

import io.vertx.core.json.JsonArray; //導入方法依賴的package包/類
private Handler<Message<JsonObject>> processInit() {
    return msg -> {
    	try{
         JsonObject payload = msg.body();
         JsonArray buys = payload.getJsonArray("Buys");
         
for(int i = 0; i<buys.size();i++){
	orderBook.getBuyOrders().put(buys.getJsonObject(i).getDouble("Rate"), buys.getJsonObject(i).getDouble("Quantity"));
}
JsonArray sells = payload.getJsonArray("Sells");
for(int i = 0; i<sells.size();i++){
	orderBook.getSellOrders().put(sells.getJsonObject(i).getDouble("Rate"), sells.getJsonObject(i).getDouble("Quantity"));
}
vertx.eventBus().publish(MessageDefinitions.ORDERBOOK_READY+":"+tradingPair, "ready");
    	} catch(Exception e){
    		e.printStackTrace();
    		System.out.println("Failed setting up Order Book");
    	}
    };
}
 
開發者ID:AlxGDev,項目名稱:BittrexGatherer,代碼行數:21,代碼來源:BittrexOrderBookVerticle.java

示例2: fromJson

import io.vertx.core.json.JsonArray; //導入方法依賴的package包/類
@Override
public FdfsClientOptions fromJson(JsonObject json) {

	super.fromJson(json);

	JsonArray array = json.getJsonArray(TRACKERS);

	if (array != null && array.size() > 0) {
		array.forEach(object -> {
			if (object instanceof JsonObject) {
				JsonObject tracker = (JsonObject) object;

				String host = tracker.getString(HOST, "");
				int port = tracker.getInteger(PORT, -1);

				if (!host.isEmpty() && port != -1) {
					trackers.add(SocketAddress.inetSocketAddress(port, host));
				}
			}
		});
	}
	
	return this;
}
 
開發者ID:gengteng,項目名稱:vertx-fastdfs-client,代碼行數:25,代碼來源:FdfsClientOptions.java

示例3: zip

import io.vertx.core.json.JsonArray; //導入方法依賴的package包/類
static JsonArray zip(
        final JsonArray target,
        final JsonArray sources,
        final String fromKey,
        final String toKey
) {
    final ConcurrentMap<Integer, Object> targetMap = mapIndex(target, fromKey);
    final ConcurrentMap<Object, JsonObject> sourceMap = mapZip(sources, toKey);
    final ConcurrentMap<Integer, JsonObject> merged = Statute.reduce(targetMap, sourceMap);
    final JsonArray results = new JsonArray();
    for (int idx = 0; idx < target.size(); idx++) {
        final JsonObject item = append(target.getJsonObject(idx), merged.get(idx), true);
        results.add(item);
    }
    target.clear();
    return target.addAll(results);
}
 
開發者ID:silentbalanceyh,項目名稱:vertx-zero,代碼行數:18,代碼來源:Dual.java

示例4: execZero

import io.vertx.core.json.JsonArray; //導入方法依賴的package包/類
/**
 * @param dataArray
 * @param clazz
 * @param fnIt
 * @param <T>
 * @throws ZeroException
 */
static <T> void execZero(final JsonArray dataArray,
                         final Class<T> clazz,
                         final ZeroBiConsumer<T, Integer> fnIt)
        throws ZeroException {
    final int size = dataArray.size();
    for (int idx = Values.IDX; idx < size; idx++) {
        final Object value = dataArray.getValue(idx);
        if (null != value) {
            if (clazz == value.getClass()) {
                final T item = (T) value;
                fnIt.accept(item, idx);
            }
        }
    }
}
 
開發者ID:silentbalanceyh,項目名稱:vertx-zero,代碼行數:23,代碼來源:Congregation.java

示例5: deployAll

import io.vertx.core.json.JsonArray; //導入方法依賴的package包/類
/**
 * Deploys the list of local and/or remote components
 *
 * @param future Vert.x Future object to update the status of deployment
 * @see <a href="http://vertx.io/docs/apidocs/io/vertx/core/Future.html" target="_blank">Future</a>
 */
public void deployAll(Future<Void> future) {
	if (null == this.vertx) {
		String errMesg = "Not setup yet! Call 'setup' method first.";

		logger.error(errMesg);
		future.fail(new Exception(errMesg));

		return;
	}

	JsonArray compList = this.deployConfig.getJsonArray("components");
	List<DeployComponent> components = new ArrayList<>();
	int listLen = compList.size();
	JsonObject deployConf;

	for (int idx = 0; idx < listLen; idx++) {
		deployConf = compList.getJsonObject(idx);
		components.add(this.setupComponent(deployConf));
	}

	this.deployRecords.deployAll(components, future);
}
 
開發者ID:mustertech,項目名稱:rms-deployer,代碼行數:29,代碼來源:VtxDeployer.java

示例6: processReceivedData

import io.vertx.core.json.JsonArray; //導入方法依賴的package包/類
/**
 * This is where the data leaves the verticle onto the Bus
 *
 * @param receivedData
 *            JSON data
 */
protected void processReceivedData(final JsonArray receivedData) {
	// The last element in the Array is the all over status
	for (int i = 0; i < (receivedData.size() - 1); i++) {
		this.processOneResult(receivedData.getJsonObject(i));
	}

}
 
開發者ID:Stwissel,項目名稱:vertx-sfdc-platformevents,代碼行數:14,代碼來源:CometD.java

示例7: subscriptionResult

import io.vertx.core.json.JsonArray; //導入方法依賴的package包/類
private void subscriptionResult(final AsyncResult<HttpResponse<JsonArray>> ar) {
	if (ar.succeeded()) {
		// Process the result
		this.captureCookies(ar.result().cookies());
		final JsonArray receivedData = ar.result().body();
		final JsonObject status = receivedData.getJsonObject(receivedData.size() - 1);
		if (status.getBoolean("successful", false)) {
			// If the array has only one member we didn't get new data
			if (receivedData.size() > 1) {
				this.processReceivedData(receivedData);
			}
			// Do it again eventually
			if (!this.shuttingDown && !this.shutdownCompleted) {
				this.subscriptionFetch();
			} else {
				this.shutdownCompleted = true;
			}
		} else {
			// We won't continue
			this.logger.fatal(status.encodePrettily());
			this.shutdownCompleted = true;
		}

	} else {
		// Preliminary stopping here
		// needs to be handled
		this.logger.fatal(ar.cause());
		this.shutdownCompleted = true;
	}
}
 
開發者ID:Stwissel,項目名稱:vertx-sfdc-platformevents,代碼行數:31,代碼來源:CometD.java

示例8: mapIndex

import io.vertx.core.json.JsonArray; //導入方法依賴的package包/類
private static ConcurrentMap<Integer, Object> mapIndex(
        final JsonArray sources,
        final String field
) {
    final ConcurrentMap<Integer, Object> resultMap =
            new ConcurrentHashMap<>();
    for (int idx = Values.IDX; idx < sources.size(); idx++) {
        final JsonObject item = sources.getJsonObject(idx);
        final Object value = item.getValue(field);
        if (null != value) {
            resultMap.put(idx, value);
        }
    }
    return resultMap;
}
 
開發者ID:silentbalanceyh,項目名稱:vertx-zero,代碼行數:16,代碼來源:Dual.java

示例9: getRequestParameter

import io.vertx.core.json.JsonArray; //導入方法依賴的package包/類
@Override
public String getRequestParameter(String name) {
    JsonArray values = parameters.getJsonArray(name);
    if (values != null && values.size() > 0) {
        return values.getString(0);
    }
    return null;
}
 
開發者ID:millross,項目名稱:pac4j-async,代碼行數:9,代碼來源:VertxAsyncWebContext.java

示例10: apply

import io.vertx.core.json.JsonArray; //導入方法依賴的package包/類
@Override
public Object apply(Object firstParam, Options options) throws IOException {
  if (options.params.length > 0) {
    int index = options.param(0);
    if (firstParam instanceof JsonArray) {
      JsonArray array = (JsonArray) firstParam;
      if (array.size() > index) {
        return array.getValue(index);
      }
    }
  }
  return null;
}
 
開發者ID:Knotx,項目名稱:knotx-handlebars-extension,代碼行數:14,代碼來源:ElementHelper.java

示例11: setSeries

import io.vertx.core.json.JsonArray; //導入方法依賴的package包/類
private void setSeries(String name, JsonArray jsonArray){

        javafx.scene.chart.XYChart.Series series = new javafx.scene.chart.XYChart.Series();
        series.setName(name);
        if(xScale == null) return;
        for(int i=0;i<xScale.size();i++){
            if(i<jsonArray.size()&&jsonArray.getValue(i)!=null) {
                Object x = xScale.getValue(i);
                if(xAxis instanceof CategoryAxis)
                    x = x.toString();

                Object y = jsonArray.getValue(i);
                if(y == null){

                }else if(y instanceof Number)
                    addData(series,x,y);
                else if(y instanceof JsonObject){
                    Object xx=null, yy=null, extra=null;
                    JsonObject jsonObject = (JsonObject)y;
                    for(String key:jsonObject.fieldNames()){
                        if(key.equals("x")) xx = jsonObject.getValue(key);
                        else if(key.equals("y")) yy = jsonObject.getValue(key);
                        else extra = jsonObject.getValue(key);
                    }

                    if(xx!=null&&yy!=null){
                        if(extra!=null) addData(series,xx,yy,extra);
                        else addData(series,xx,yy);
                    }
                }
                else
                    addData(series,x,y);
            }
        }
        ((javafx.scene.chart.XYChart)body).getData().add(series);
    }
 
開發者ID:whitewoodcity,項目名稱:xbrowser,代碼行數:37,代碼來源:XYChart.java

示例12: syncBatchMaterial

import io.vertx.core.json.JsonArray; //導入方法依賴的package包/類
/**
 * 獲取素材
 * @param mediaType 素材類型
 * @param offset 開始位置
 * @param count 獲取數量
 * @return
 */
public static Material syncBatchMaterial(MediaType mediaType, Integer offset, Integer count, Account mpAccount){
	String accessToken = getAccessToken(mpAccount);
	String url = WxApi.getBatchMaterialUrl(accessToken);
	JsonObject bodyObj = new JsonObject();
	bodyObj.put("type", mediaType.toString());
	bodyObj.put("offset", offset);
	bodyObj.put("count", count);
	String body = bodyObj.toString();
	try {
		JsonObject jsonObj = WxApi.httpsRequest(url, "POST", body);
		if (jsonObj.containsKey("errcode")) {//獲取素材失敗
			System.out.println(ErrCode.errMsg(jsonObj.getInteger("errcode")));
			return null;
		}else{
			Material material = new Material();
			material.setTotalCount(jsonObj.getInteger("total_count"));
			material.setItemCount(jsonObj.getInteger("item_count"));
			JsonArray arr = jsonObj.getJsonArray("item");
			if(arr != null && arr.size() > 0){
				List<MaterialItem> itemList = new ArrayList<MaterialItem>();
				for(int i = 0; i < arr.size(); i++){
					JsonObject item = arr.getJsonObject(i);
					MaterialItem materialItem = new MaterialItem();
					materialItem.setMediaId(item.getString("media_id"));
					materialItem.setUpdateTime(item.getLong("update_time")*1000L);
					if(item.containsKey("content")){//mediaType=news (圖文消息)
						JsonArray articles = item.getJsonObject("content").getJsonArray("news_item");
						List<MaterialArticle> newsItems = new ArrayList<MaterialArticle>();
						for(int j = 0; j < articles.size(); j++){
							JsonObject article = articles.getJsonObject(j);
							MaterialArticle ma = new MaterialArticle();
							ma.setTitle(article.getString("title"));
							ma.setThumb_media_id(article.getString("thumb_media_id"));
							ma.setShow_cover_pic(article.getString("show_cover_pic"));
							ma.setAuthor(article.getString("author"));
							ma.setContent_source_url(article.getString("content_source_url"));
							ma.setContent(article.getString("content"));
							ma.setUrl(article.getString("url"));
							newsItems.add(ma);
						}
						materialItem.setNewsItems(newsItems);
					}else{
						materialItem.setName(item.getString("name"));
						materialItem.setUrl(item.getString("url"));
					}
					itemList.add(materialItem);
				}
				material.setItems(itemList);
			}
			return material;
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	return null;
}
 
開發者ID:Leibnizhu,項目名稱:AlipayWechatPlatform,代碼行數:64,代碼來源:WxApiClient.java

示例13: parseSubMenus

import io.vertx.core.json.JsonArray; //導入方法依賴的package包/類
protected void parseSubMenus (Menu menu, JsonArray jsonArray) {
    for (int i = 0; i < jsonArray.size(); i++) {
        //get json object
        JsonObject entry = jsonArray.getJsonObject(i);

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

        //create new menu item
        MenuItem menuItem = new MenuItem(title);

        //add click handler
        menuItem.setOnAction(event1 -> {
            System.out.println("open activitiy: " + event);

            EventBus.getInstance().raiseEvent("open_activity", event);
        });

        menuItem.setAccelerator(new KeyCodeCombination(KeyCode.C, KeyCombination.CONTROL_DOWN));

        //check for shortcut
        if (entry.containsKey("shortcut") && !entry.getString("shortcut").isEmpty()) {
            String keys[] = entry.getString("shortcut").split("\\+");

            if (keys.length > 1) {
                KeyCombination.Modifier modifier = null;

                if (keys[1].equals("SHIFT_DOWN")) {
                    modifier = KeyCombination.SHIFT_DOWN;
                } else {
                    throw new UnsupportedOperationException("Unsupported key code: " + keys[1]);
                }

                //KeyCombination combination = KeyCombination.keyCombination(keys[1]);

                menuItem.setAccelerator(new KeyCodeCombination(KeyCode.getKeyCode(keys[0]), modifier));
            } else if (keys.length == 1) {
                menuItem.setAccelerator(new KeyCodeCombination(KeyCode.getKeyCode(keys[0])));
            } else {
                //no shortcut is set
            }
        }

        //add menu item to menu
        menu.getItems().add(menuItem);
    }
}
 
開發者ID:open-erp-systems,項目名稱:erp-frontend,代碼行數:49,代碼來源:DefaultMenuManager.java


注:本文中的io.vertx.core.json.JsonArray.size方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。