本文整理汇总了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;
}
示例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;
}
示例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")
);
}
示例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);
});
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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");
}
示例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;
}
示例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();
}
}
示例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;
}
示例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;
}
示例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));
}
示例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("插入完毕");
}
}