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


Java JsonObject.containsKey方法代碼示例

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


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

示例1: data

import io.vertx.core.json.JsonObject; //導入方法依賴的package包/類
/**
 * Extract request part to t ( Direct Mode )
 *
 * @param argIndex
 * @param <T>
 * @return
 */
public <T> T data(final Integer argIndex, final Class<T> clazz) {
    T reference = null;
    Fn.flingUp(0 > argIndex, LOGGER,
            IndexExceedException.class, this.getClass(), argIndex);
    if (this.data.containsKey(Key.DATA)) {
        final JsonObject raw = this.data.getJsonObject(Key.DATA);
        if (null != raw) {
            final String key = argIndex.toString();
            if (raw.containsKey(key)) {
                reference = this.extract(raw.getValue(key), clazz);
            }
        }
    }
    return reference;
}
 
開發者ID:silentbalanceyh,項目名稱:vertx-zero,代碼行數:23,代碼來源:Envelop.java

示例2: getOAuthAccessToken

import io.vertx.core.json.JsonObject; //導入方法依賴的package包/類
public static OAuthAccessToken getOAuthAccessToken(String appId, String appSecret, String code) {
    OAuthAccessToken token = null;
    String tockenUrl = getOAuthTokenUrl(appId, appSecret, code);
    JsonObject jsonObject = httpsRequest(tockenUrl, HttpMethod.GET, null);
    if (null != jsonObject && !jsonObject.containsKey("errcode")) {
        token = new OAuthAccessToken();
        token.setAccessToken(jsonObject.getString("access_token"));
        token.setExpiresIn(jsonObject.getInteger("expires_in"));
        token.setOpenid(jsonObject.getString("openid"));
        token.setScope(jsonObject.getString("scope"));
    } else if (null != jsonObject) {
        token = new OAuthAccessToken();
        token.setErrcode(jsonObject.getInteger("errcode"));
    }
    return token;
}
 
開發者ID:Leibnizhu,項目名稱:AlipayWechatPlatform,代碼行數:17,代碼來源:WxApi.java

示例3: initOpts

import io.vertx.core.json.JsonObject; //導入方法依賴的package包/類
private void initOpts(final JsonObject raw) {
    // Options
    JsonObject normalized = getOptions();
    if (raw.containsKey("timeout")) {
        final JsonObject options = raw.getJsonObject("timeout");
        normalized = normalized.mergeIn(options);
    }
    this.options = new Request.Options(
            normalized.getInteger("connect"),
            normalized.getInteger("read"));
    // Defaults
    normalized = getDefaults();
    if (raw.containsKey("retry")) {
        final JsonObject defaults = raw.getJsonObject("retry");
        normalized = normalized.mergeIn(defaults);
    }
    this.defaults = new Retryer.Default(
            normalized.getInteger("period"),
            normalized.getInteger("maxPeriod"),
            normalized.getInteger("attempts")
    );
}
 
開發者ID:silentbalanceyh,項目名稱:vertx-zero,代碼行數:23,代碼來源:FeignDepot.java

示例4: create

import io.vertx.core.json.JsonObject; //導入方法依賴的package包/類
@Override
public Single<JsonObject> create(JsonObject item) {
  if (item == null) {
    return Single.error(new IllegalArgumentException("The item must not be null"));
  }
  if (item.getString("name") == null || item.getString("name").isEmpty()) {
    return Single.error(new IllegalArgumentException("The name must not be null or empty"));
  }
  if (item.getInteger("stock", 0) < 0) {
    return Single.error(new IllegalArgumentException("The stock must greater or equal to 0"));
  }
  if (item.containsKey("id")) {
    return Single.error(new IllegalArgumentException("The created item already contains an 'id'"));
  }

  return db.rxGetConnection()
    .flatMap(conn -> {
      JsonArray params = new JsonArray().add(item.getValue("name")).add(item.getValue("stock", 0));
      return conn
        .rxUpdateWithParams(INSERT, params)
        .map(ur -> item.put("id", ur.getKeys().getLong(0)))
        .doAfterTerminate(conn::close);
    });
}
 
開發者ID:cescoffier,項目名稱:various-vertx-demos,代碼行數:25,代碼來源:JdbcProductStore.java

示例5: copy

import io.vertx.core.json.JsonObject; //導入方法依賴的package包/類
static JsonObject copy(
        final JsonObject entity,
        final String from,
        final String to,
        final boolean immutable
) {
    final JsonObject result = immutable ? entity.copy() : entity;
    if (StringUtil.notNil(to) && entity.containsKey(from)) {
        result.put(to, entity.getValue(from));
    }
    return result;
}
 
開發者ID:silentbalanceyh,項目名稱:vertx-zero,代碼行數:13,代碼來源:Self.java

示例6: read

import io.vertx.core.json.JsonObject; //導入方法依賴的package包/類
@Override
public JsonObject read() {
    // Not null because execNil
    final JsonObject config = ZeroTool.read(null, true);
    // Injection Lime
    final JsonObject zero = Fn.getJvm(new JsonObject(),
            () -> config.getJsonObject(Key.ZERO), config);
    if (null != zero && zero.containsKey(Key.LIME)) {
        prodcessLime(zero);
    }
    // Return to zero configuration part
    return zero;
}
 
開發者ID:silentbalanceyh,項目名稱:vertx-zero,代碼行數:14,代碼來源:ZeroVertx.java

示例7: getJSTicket

import io.vertx.core.json.JsonObject; //導入方法依賴的package包/類
public static JSTicket getJSTicket(String token) {
    JSTicket jsTicket = null;
    String jsTicketUrl = WxApi.getJsApiTicketUrl(token);
    JsonObject jsonObject = httpsRequest(jsTicketUrl, HttpMethod.GET, null);
    if (null != jsonObject && jsonObject.containsKey("errcode") && jsonObject.getInteger("errcode") == 0) {
        jsTicket = new JSTicket();
        jsTicket.setTicket(jsonObject.getString("ticket"));
        jsTicket.setExpiresIn(jsonObject.getInteger("expires_in"));
    } else if (null != jsonObject) {
        jsTicket = new JSTicket();
        jsTicket.setErrcode(jsonObject.getInteger("errcode"));
    }
    return jsTicket;
}
 
開發者ID:Leibnizhu,項目名稱:AlipayWechatPlatform,代碼行數:15,代碼來源:WxApi.java

示例8: createDbClient

import io.vertx.core.json.JsonObject; //導入方法依賴的package包/類
@Override
protected SQLClient createDbClient(JsonObject config) {
	JsonObject myConfig = new JsonObject();
	if(config.containsKey("db_host"))
		myConfig.put("host", config.getString("db_host"));
	if(config.containsKey("db_port"))
		myConfig.put("port", config.getInteger("db_port"));
	if(config.containsKey("db_user"))
		myConfig.put("username", config.getString("db_user"));
	if(config.containsKey("db_pass"))
		myConfig.put("password", config.getString("db_pass"));
	if(config.containsKey("db_name"))
		myConfig.put("database", config.getString("db_name"));
	myConfig.put("max_pool_size", config.getInteger("db_max_pool_size", 30));
	
	Vertx vertx = AppGlobals.get().getVertx();
	AsyncSQLClient dbClient = PostgreSQLClient.createNonShared(vertx, myConfig);
	AsyncJooqSQLClient client = AsyncJooqSQLClient.create(vertx, dbClient);

	Configuration configuration = new DefaultConfiguration();
	configuration.set(SQLDialect.POSTGRES);

	PagesDao dao = new PagesDao(configuration);
	dao.setClient(client);
	
	AppGlobals.get().setGlobal("dao", dao);
	
	return dbClient;
}
 
開發者ID:FroMage,項目名稱:redpipe,代碼行數:30,代碼來源:WikiServer.java

示例9: getArray

import io.vertx.core.json.JsonObject; //導入方法依賴的package包/類
default JsonArray getArray(String key) {
    JsonObject obj = get(key);

    if (obj == null) {
        return null;
    }

    if (!obj.containsKey("array")) {
        throw new IllegalStateException("cached object isnt an array.");
    }

    return obj.getJsonArray("array");
}
 
開發者ID:open-erp-systems,項目名稱:erp-frontend,代碼行數:14,代碼來源:ICache.java

示例10: json

import io.vertx.core.json.JsonObject; //導入方法依賴的package包/類
public JsonObject json(final Object entity, final boolean overwrite) {
    final JsonObject data = Jackson.serializeJson(entity);
    final JsonObject merged = this.converted.copy();
    for (final String field : data.fieldNames()) {
        if (overwrite) {
            // If overwrite
            merged.put(field, data.getValue(field));
        } else {
            if (!merged.containsKey(field)) {
                merged.put(field, data.getValue(field));
            }
        }
    }
    return merged;
}
 
開發者ID:silentbalanceyh,項目名稱:vertx-zero,代碼行數:16,代碼來源:Mirror.java

示例11: init

import io.vertx.core.json.JsonObject; //導入方法依賴的package包/類
private void init(final JsonObject raw) {
    // Options
    initOpts(raw);
    // Config
    this.endpoint = raw.getString("endpoint");
    if (raw.containsKey("config")) {
        this.config = raw.getJsonObject("config");
    } else {
        this.config = new JsonObject();
    }
}
 
開發者ID:silentbalanceyh,項目名稱:vertx-zero,代碼行數:12,代碼來源:FeignDepot.java

示例12: isMatch

import io.vertx.core.json.JsonObject; //導入方法依賴的package包/類
/**
 * Match calculation.
 *
 * @param uri
 * @param record
 * @return
 */
private boolean isMatch(final String uri, final Record record) {
    final JsonObject data = record.getMetadata();
    boolean match = false;
    if (data.containsKey(Origin.PATH)) {
        final String path = data.getString(Origin.PATH);
        if (!StringUtil.isNil(path) && path.contains(Strings.COLON)) {
            final Pattern pattern = RegexPath.createRegex(path);
            match = pattern.matcher(uri).matches();
        } else {
            match = path.equalsIgnoreCase(uri);
        }
    }
    return match;
}
 
開發者ID:silentbalanceyh,項目名稱:vertx-zero,代碼行數:22,代碼來源:CommonArithmetic.java

示例13: build

import io.vertx.core.json.JsonObject; //導入方法依賴的package包/類
private static Envelop build(final JsonObject json) {
    Envelop envelop = Envelop.ok();
    // 1. Headers
    if (null != json) {
        // 2.Rebuild
        if (json.containsKey("data")) {
            envelop = Envelop.success(json.getValue("data"));
        }
        // 3.Header
        if (null != json.getValue("header")) {
            final MultiMap headers = MultiMap.caseInsensitiveMultiMap();
            final JsonObject headerData = json.getJsonObject("header");
            for (final String key : headerData.fieldNames()) {
                final Object value = headerData.getValue(key);
                if (null != value) {
                    headers.set(key, value.toString());
                }
            }
            envelop.setHeaders(headers);
        }
        // 4.User
        if (null != json.getValue("user")) {
            envelop.setUser(new VirtualUser(json.getJsonObject("user")));
        }
    }
    return envelop;
}
 
開發者ID:silentbalanceyh,項目名稱:vertx-zero,代碼行數:28,代碼來源:DataEncap.java

示例14: factoryConfig

import io.vertx.core.json.JsonObject; //導入方法依賴的package包/類
/**
 * Setup remote deployment related configuration such as maven settings
 */
private void factoryConfig() {
	JsonObject proxyObj = BaseUtil.proxyFromSystemProps();
	ResolverOptions resolverOptions = new ResolverOptions();

	if (proxyObj.containsKey("httpProxyURL")) {
		resolverOptions.setHttpProxy(proxyObj.getString("httpProxyURL"));
	}

	if (proxyObj.containsKey("httpsProxyURL")) {
		resolverOptions.setHttpsProxy(proxyObj.getString("httpsProxyURL"));
	}

	if (this.deployConfig.containsKey("maven")) {
		JsonObject mvnOpts = this.deployConfig.getJsonObject("maven");
		Set<String> optKeys = mvnOpts.fieldNames();
		Iterator<String> optIter = optKeys.iterator();
		String optKey;

		while (optIter.hasNext()) {
			optKey = optIter.next();

			switch (optKey) {
				case "localRepo":
					resolverOptions.setLocalRepository(mvnOpts.getString(optKey));
					break;
				case "remoteRepos":
					List<String> remoteRepoList = BaseUtil.jsonArrayToList(mvnOpts.getJsonArray(optKey), String.class);
					resolverOptions.setRemoteRepositories(remoteRepoList);
					break;
				case "snapshotRefresh":
					resolverOptions.setRemoteSnapshotPolicy(mvnOpts.getString(optKey));
					break;
				default:
					break;
			}
		}
	}

	// Language specific factories
	this.vertx.registerVerticleFactory(new JSVerticleFactory());
	this.vertx.registerVerticleFactory(new GroovyVerticleFactory());
	this.vertx.registerVerticleFactory(new JRubyVerticleFactory());
	this.vertx.registerVerticleFactory(new ScalaVerticleFactory());
	this.vertx.registerVerticleFactory(new KotlinVerticleFactory());
	this.vertx.registerVerticleFactory(new KotlinScriptVerticleFactory());
	this.vertx.registerVerticleFactory(new CeylonVerticleFactory());

	// Service factories
	this.vertx.registerVerticleFactory(new ServiceVerticleFactory());
	this.vertx.registerVerticleFactory(new HttpServiceFactory());
	this.vertx.registerVerticleFactory(new HttpSecureServiceFactory());
	this.vertx.registerVerticleFactory(new MavenVerticleFactory(resolverOptions));
}
 
開發者ID:mustertech,項目名稱:rms-deployer,代碼行數:57,代碼來源:VtxDeployer.java

示例15: importES

import io.vertx.core.json.JsonObject; //導入方法依賴的package包/類
private static void importES(Client client) throws IOException {
  String filePath = "es.txt";
  File file = new File(filePath);
  if (!file.exists()) {
    System.out.println("文件不存在");
    return;
  }
  try (BufferedReader br = new BufferedReader(new FileReader(filePath))) {
    //讀取剛才導出的ES數據

    String string;
    int count = 0;
    //開啟批量插入
    BulkRequestBuilder bulkRequest = client.prepareBulk();
    while ((string = br.readLine()) != null) {
      if (Objects.equals(string, "")) continue;
      JsonObject jsonObject = new JsonObject(string);
      System.out.println(jsonObject);
      String ESindex;
      if (jsonObject.containsKey("ESindex")) {
        ESindex = (String) jsonObject.remove("ESindex");
      } else {
        ESindex = index;
      }
      String EStype;
      if (jsonObject.containsKey("EStype")) {
        EStype = (String) jsonObject.remove("EStype");
      } else {
        EStype = type;
      }
      ++count;
      bulkRequest.add(client.prepareIndex(ESindex, EStype, String.valueOf(count)).setSource(jsonObject.toString()));
      //每一千條提交一次
      if (count % 1000 == 0) {
        bulkRequest.execute().actionGet();
        System.out.println("提交了:" + count);
      }
    }
    bulkRequest.execute().actionGet();
    System.out.println("插入完畢");
  }
}
 
開發者ID:MoneZhao,項目名稱:elasticsearch,代碼行數:43,代碼來源:App.java


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