本文整理汇总了Java中io.vertx.core.json.JsonObject.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java JsonObject.getValue方法的具体用法?Java JsonObject.getValue怎么用?Java JsonObject.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.core.json.JsonObject
的用法示例。
在下文中一共展示了JsonObject.getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRestServerVerticleWithRouterSSL
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@Test
public void testRestServerVerticleWithRouterSSL(@Mocked Transport transport, @Mocked Vertx vertx,
@Mocked Context context,
@Mocked JsonObject jsonObject, @Mocked Future<Void> startFuture) throws Exception {
URIEndpointObject endpointObject = new URIEndpointObject("http://127.0.0.1:8080?sslEnabled=true");
new Expectations() {
{
transport.parseAddress("http://127.0.0.1:8080?sslEnabled=true");
result = endpointObject;
}
};
Endpoint endpiont = new Endpoint(transport, "http://127.0.0.1:8080?sslEnabled=true");
new Expectations() {
{
context.config();
result = jsonObject;
jsonObject.getValue(AbstractTransport.ENDPOINT_KEY);
result = endpiont;
}
};
RestServerVerticle server = new RestServerVerticle();
// process stuff done by Expectations
server.init(vertx, context);
server.start(startFuture);
}
示例2: fromJson
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
/**
* Populates this object with the information from the supplied JsonObject
* @param json The JSON Object
*/
public void fromJson(JsonObject json) {
Objects.requireNonNull(json, "json is required");
if (json.getValue("name") instanceof String)
setName((String) json.getValue("name"));
if (json.getValue("deploymentOptions") instanceof JsonObject) {
setDeploymentOptions(new DeploymentOptions());
DeploymentOptionsConverter.fromJson((JsonObject) json.getValue("deploymentOptions"), this.getDeploymentOptions());
}
if (json.getValue("dependents") instanceof JsonArray) {
json.getJsonArray("dependents").forEach(item -> {
if (item instanceof JsonObject) {
DependentsDeployment deps = new DependentsDeployment();
deps.fromJson((JsonObject) item);
getDependents().add(deps);
}
});
}
}
示例3: fromJson
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
public static void fromJson(JsonObject json, RequestParameters obj) {
if (json.getValue("filter") instanceof Boolean) {
obj.setFilter((Boolean) json.getValue("filter"));
}
if (json.getValue("language") instanceof String) {
obj.setLanguage(Language.valueOf((String) json.getValue("language")));
}
if (json.getValue("pattern") instanceof String) {
obj.setPattern((String) json.getValue("pattern"));
}
if (json.getValue("properties") instanceof JsonObject) {
obj.setProperties(((JsonObject) json.getValue("properties")).copy());
}
if (json.getValue("text") instanceof String) {
obj.setText((String) json.getValue("text"));
}
}
示例4: fromJson
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
public static void fromJson(JsonObject json, CoreNLPClientOptions obj) {
if (json.getValue("host") instanceof String) {
obj.setHost((String) json.getValue("host"));
}
if (json.getValue("password") instanceof String) {
obj.setPassword((String) json.getValue("password"));
}
if (json.getValue("port") instanceof Number) {
obj.setPort(((Number) json.getValue("port")).intValue());
}
if (json.getValue("ssl") instanceof Boolean) {
obj.setSsl((Boolean) json.getValue("ssl"));
}
if (json.getValue("sslKey") instanceof String) {
obj.setSslKey((String) json.getValue("sslKey"));
}
if (json.getValue("username") instanceof String) {
obj.setUsername((String) json.getValue("username"));
}
}
示例5: verify
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
private boolean verify(final JsonObject config, final String key) {
final Object value = config.getValue(key);
boolean verified = true;
if (JsonObject.class == value.getClass()) {
// Checking the type
try {
Ruler.verify(KEY, (JsonObject) value);
} catch (final ZeroException ex) {
LOGGER.zero(ex);
verified = false;
}
} else {
LOGGER.warn(Info.TYPE_CONFLICT, key, config.encode());
verified = false;
}
return verified;
}
示例6: verifyBody
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
private static WebException verifyBody(
final Map<String, List<Rule>> rulers,
final JsonObject data) {
WebException error = null;
outer:
for (final String field : rulers.keySet()) {
final Object value = data.getValue(field);
final List<Rule> rules = rulers.get(field);
// Search for each rule
for (final Rule rule : rules) {
final Ruler ruler = Ruler.get(rule.getType());
if (null != ruler) {
error = ruler.verify(field, value, rule);
}
// Error found.
if (null != error) {
break outer;
}
// Else skip
}
}
return error;
}
示例7: storeSession
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
private static <T> void storeSession(
final RoutingContext context,
final T data,
final Method method
) {
final Session session = context.session();
if (null != session && null != data && method.isAnnotationPresent(SessionData.class)) {
final Annotation annotation = method.getAnnotation(SessionData.class);
final String key = Instance.invoke(annotation, "value");
final String field = Instance.invoke(annotation, "field");
// Data Storage
Object reference = data;
if (Types.isJObject(data) && StringUtil.notNil(field)) {
final JsonObject target = (JsonObject) data;
reference = target.getValue(field);
}
// Session Put
session.put(key, reference);
}
}
示例8: setDataBase
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
private void setDataBase(JsonObject data){
for(String key:data.fieldNames()){
if(data.getValue(key)==null) continue;
if(data.getValue(key) instanceof Number){
pieChartData.add(new javafx.scene.chart.PieChart.Data(key, ((Number)data.getValue(key)).doubleValue()));
}else{
try{
double value = Double.parseDouble(data.getValue(key).toString());
pieChartData.add(new javafx.scene.chart.PieChart.Data(key, value));
}catch (Exception e){
//do nothing
}
}
}
((javafx.scene.chart.PieChart)body).setData(pieChartData);
}
示例9: fromJson
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
static void fromJson(final JsonObject json, final ServidorOptions obj) {
if (json.getValue("name") instanceof String) {
obj.setName(json.getString("name"));
}
if (json.getValue("config") instanceof JsonObject) {
final JsonObject config = json.getJsonObject("config").copy();
if (config.getValue("host") instanceof String) {
obj.setHost(config.getString("host"));
}
if (config.getValue("port") instanceof Integer) {
obj.setPort(config.getInteger("port"));
}
config.remove("host");
config.remove("port");
obj.setOptions(config);
}
}
示例10: setSeries
import io.vertx.core.json.JsonObject; //导入方法依赖的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);
}
示例11: testHighwayVerticle
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@Test
public void testHighwayVerticle(@Mocked Transport transport, @Mocked Vertx vertx, @Mocked Context context,
@Mocked JsonObject json) {
URIEndpointObject endpiontObject = new URIEndpointObject("highway://127.0.0.1:9090");
new Expectations() {
{
transport.parseAddress(anyString);
result = endpiontObject;
}
};
Endpoint endpoint = new Endpoint(transport, "highway://127.0.0.1:9090");
new Expectations() {
{
context.config();
result = json;
json.getValue(anyString);
result = endpoint;
}
};
highwayVerticle.init(vertx, context);
@SuppressWarnings("unchecked")
Future<Void> startFuture = Mockito.mock(Future.class);
highwayVerticle.startListen(startFuture);
MockUtil.getInstance().mockHighwayConfig();
try {
highwayVerticle.startListen(startFuture);
Assert.assertTrue(true);
} catch (Exception e) {
Assert.assertTrue(false);
}
}
示例12: fromJson
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
/**
* Populates this object with the information from the supplied JsonObject
* @param json The JSON Object
*/
public void fromJson(JsonObject json) {
Objects.requireNonNull(json, "json is required");
if (json.getValue("configurations") instanceof JsonArray) {
json.getJsonArray("configurations").forEach(item -> {
if (item instanceof JsonObject) {
DeploymentConfiguration cfg = new DeploymentConfiguration();
cfg.fromJson((JsonObject) item);
getConfigurations().add(cfg);
}
});
}
}
示例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: mapIndex
import io.vertx.core.json.JsonObject; //导入方法依赖的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;
}
示例15: convert
import io.vertx.core.json.JsonObject; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
static <I, O> JsonObject convert(
final JsonObject entity,
final String field,
final Function<I, O> function,
final boolean immutable
) {
final JsonObject result = immutable ? entity.copy() : entity;
final Object value = result.getValue(field);
if (null != value) {
final I input = (I) value;
result.put(field, function.apply(input));
}
return result;
}