当前位置: 首页>>代码示例>>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;未经允许,请勿转载。