本文整理汇总了Java中org.vertx.java.core.json.JsonArray类的典型用法代码示例。如果您正苦于以下问题:Java JsonArray类的具体用法?Java JsonArray怎么用?Java JsonArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JsonArray类属于org.vertx.java.core.json包,在下文中一共展示了JsonArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: formatSearchResult
import org.vertx.java.core.json.JsonArray; //导入依赖的package包/类
private JsonArray formatSearchResult(final JsonArray results, final JsonArray columnsHeader, final String locale) {
final List<String> aHeader = columnsHeader.toList();
final JsonArray traity = new JsonArray();
for (int i=0;i<results.size();i++) {
final JsonObject j = results.get(i);
final JsonObject jr = new JsonObject();
if (j != null) {
jr.putString(aHeader.get(0), j.getString("fileNameLabel"));
jr.putString(aHeader.get(1), j.getString("description", ""));
jr.putObject(aHeader.get(2), j.getObject("modified"));
jr.putString(aHeader.get(3), j.getObject("owner").getString("displayName"));
jr.putString(aHeader.get(4), j.getObject("owner").getString("userId"));
jr.putString(aHeader.get(5), "/sharebigfiles#/view/" + j.getString("_id"));
traity.add(jr);
}
}
return traity;
}
示例2: create
import org.vertx.java.core.json.JsonArray; //导入依赖的package包/类
private void create(String description, Long expiryDate, String fileNameLabel, String idFile, JsonObject metadata,
UserInfos user, HttpServerRequest request) {
final JsonObject object = new JsonObject();
object.putString("fileId", idFile);
object.putString("fileNameLabel", fileNameLabel);
//for the cron task knows the locale of user
object.putString("locale", I18n.acceptLanguage(request));
object.putString("description", description);
if (expiryDate.equals(0L)) {
object.putObject("expiryDate", MongoDb.now());
} else {
object.putObject("expiryDate", new JsonObject().putValue("$date", expiryDate));
}
object.putArray("downloadLogs", new JsonArray());
object.putObject("fileMetadata", metadata);
shareBigFileCrudService.create(object, user, notEmptyResponseHandler(request));
}
示例3: updateShare
import org.vertx.java.core.json.JsonArray; //导入依赖的package包/类
@Override
public void updateShare(String pageId, String userId, JsonObject value, Handler<Either<String, JsonObject>> handler) {
JsonArray shared = new JsonArray();
shared.add(new JsonObject().putString("groupId", value.getString("read")).
putBoolean("net-atos-entng-community-controllers-PagesController|get", true));
shared.add(new JsonObject().putString("groupId", value.getString("contrib")).
putBoolean("net-atos-entng-community-controllers-PagesController|get", true).
putBoolean("net-atos-entng-community-controllers-PagesController|update", true));
shared.add(new JsonObject().putString("groupId", value.getString("manager")).
putBoolean("net-atos-entng-community-controllers-PagesController|get", true).
putBoolean("net-atos-entng-community-controllers-PagesController|update", true).
putBoolean("net-atos-entng-community-controllers-PagesController|delete", true));
MongoUpdateBuilder updateQuery = new MongoUpdateBuilder().set("shared", shared);
QueryBuilder query = QueryBuilder.start("_id").is(pageId);
mongo.update(conf.getCollection(), MongoQueryBuilder.build(query), updateQuery.build(), MongoDbResult.validActionResultHandler(handler));
}
示例4: dispatchEvents
import org.vertx.java.core.json.JsonArray; //导入依赖的package包/类
private void dispatchEvents() {
//
// Read next batch of events from map (if any)
//
if (m_handledNotifs != null
&& m_queueNotifs != null) {
List<JsonObject> events = new ArrayList();
m_queueNotifs.drainTo(events, m_config.getDispatcherBatchSize());
JsonArray jsonEvents = new JsonArray();
for (JsonObject event : events) {
jsonEvents.add(event);
}
// Send events to dispatcher
eventBus().send(DISPATCHER_LOCAL_ADDRESS, jsonEvents);
}
}
示例5: emitMultiLine
import org.vertx.java.core.json.JsonArray; //导入依赖的package包/类
private void emitMultiLine() {
// Emit multi-line (if any)
MultiLine multiLine = m_multiLine;
if (multiLine.hasLines()) {
JsonObject multiEvent = multiLine.getEvent();
JsonArray tags = multiEvent.getArray(EVENT_FIELD_TAGS);
for (String tag : m_multiTags) {
if (tag != null) {
tags.addString(tag);
} else {
break;
}
}
emitEvent(multiEvent);
multiLine.clear();
}
}
示例6: handleEvent
import org.vertx.java.core.json.JsonArray; //导入依赖的package包/类
@Override
protected void handleEvent(final JsonObject batchEvent) {
try {
//
// Operate on arrays only (batches)
//
JsonArray batch = batchEvent.getArray(EVENT_FIELD_BATCH_EVENTS, new JsonArray());
if (!batchEvent.containsField(EVENT_FIELD_BATCH_EVENTS)) {
batch.addObject(batchEvent);
}
for (int i = 0; i < batch.size(); i++) {
JsonObject event = batch.get(i);
// Simply log the event using the specified MDC
String mdcKey = event.getString(FIELD_MDC_KEY, DEF_MDC_KEY);
String mdcValue = event.getString(FIELD_MDC_VALUE, m_mdcValue);
MDC.put(mdcKey, String.valueOf(variables().translate(event, mdcValue)));
eventLogger().info(event.toString());
}
} catch (Exception e) {
logger().error("Failed to log event: {}",
batchEvent.getString(EVENT_FIELD_ID), e);
}
}
示例7: retrieve
import org.vertx.java.core.json.JsonArray; //导入依赖的package包/类
@Override
public void retrieve(String id, Handler<Either<String, JsonObject>> handler) {
String query;
JsonArray values = new JsonArray();
if (id != null) {
query = "SELECT t.id as _id, t.title, t.icon, t.mode, t.created, t.modified, t.owner, u.username" +
", json_agg(row_to_json(row(ts.member_id, ts.action)::actualites.share_tuple)) as shared" +
", array_to_json(array_agg(group_id)) as groups" +
" FROM actualites.thread AS t" +
" LEFT JOIN actualites.users AS u ON t.owner = u.id" +
" LEFT JOIN actualites.thread_shares AS ts ON t.id = ts.resource_id" +
" LEFT JOIN actualites.members AS m ON (ts.member_id = m.id AND m.group_id IS NOT NULL)" +
" WHERE t.id = ? " +
" GROUP BY t.id, u.username" +
" ORDER BY t.modified DESC";
values.add(Sql.parseId(id));
Sql.getInstance().prepared(query.toString(), values, SqlResult.parseSharedUnique(handler));
}
}
示例8: matchValue
import org.vertx.java.core.json.JsonArray; //导入依赖的package包/类
private boolean matchValue(final Object eventValue) {
boolean match = true;
//
// Handle array and single value
//
if (eventValue instanceof JsonArray) {
JsonArray array = (JsonArray) eventValue;
for (int i = 0; i < array.size(); i++) {
Object singleValue = array.get(i);
if (!matchEventValue(singleValue)) {
match = false;
break;
}
}
} else {
// Single value
match = matchEventValue(eventValue);
}
return match;
}
示例9: addFields
import org.vertx.java.core.json.JsonArray; //导入依赖的package包/类
private void addFields(
final Variables variables,
final JsonObject event,
final Map<String, Object> fields) {
Set<Map.Entry<String, Object>> entries = fields.entrySet();
for (Map.Entry<String, Object> entry : entries) {
String field = entry.getKey();
Object valueDef = entry.getValue(); // Support arrays
if (valueDef instanceof List) {
JsonArray jsonArray = new JsonArray();
List valueDefs = (List) valueDef;
for (Object def : valueDefs) {
String value = String.valueOf(def);
jsonArray.add(variables.translate(event, value));
}
event.putValue(field, jsonArray);
} else {
event.putValue(field, variables.translate(event, valueDef));
}
}
}
示例10: renames
import org.vertx.java.core.json.JsonArray; //导入依赖的package包/类
private void renames(
final JsonObject event,
final Map<String, String> fields) {
Set<Map.Entry<String, String>> entries = fields.entrySet();
for (Map.Entry<String, String> entry : entries) {
String oldName = entry.getKey();
if (event.containsField(oldName)) {
String newName = entry.getValue();
Object value = event.removeField(oldName);
if (value instanceof Map) {
event.putObject(newName, new JsonObject((Map<String, Object>) value));
} else if (value instanceof List) {
event.putArray(newName, new JsonArray((List<Object>) value));
} else {
event.putValue(newName, value);
}
}
}
}
示例11: delTags
import org.vertx.java.core.json.JsonArray; //导入依赖的package包/类
private void delTags(
final JsonObject event,
final List<String> tags) {
JsonArray curTags = event.getArray(EVENT_FIELD_TAGS, new JsonArray());
for (String tag : tags) {
if (curTags.contains(tag)) {
JsonArray newTags = new JsonArray();
for (int i = 0; i < curTags.size(); i++) {
String oldTag = curTags.get(i);
if (!tag.equals(oldTag)) {
newTags.addString(oldTag);
}
}
curTags = newTags;
}
}
event.putArray(EVENT_FIELD_TAGS, curTags);
}
示例12: formatSearchResult
import org.vertx.java.core.json.JsonArray; //导入依赖的package包/类
private JsonArray formatSearchResult(final JsonArray results, final JsonArray columnsHeader, final String userId) {
final List<String> aHeader = columnsHeader.toList();
final JsonArray traity = new JsonArray();
for (int i=0;i<results.size();i++) {
final JsonObject j = results.get(i);
//Only published (status == 3) or owner
if (j != null && (j.getInteger("status", 0).equals(3) || j.getString("owner", "").equals(userId))) {
final JsonObject jr = new JsonObject();
jr.putString(aHeader.get(0), j.getString("title"));
jr.putString(aHeader.get(1), j.getString("content"));
jr.putObject(aHeader.get(2), new JsonObject().putValue("$date",
DatatypeConverter.parseDateTime(j.getString("modified")).getTime().getTime()));
jr.putString(aHeader.get(3), j.getString("username"));
jr.putString(aHeader.get(4), j.getString("owner"));
jr.putString(aHeader.get(5), "/actualites#/view/thread/"+
j.getNumber("thread_id",0) + "/info/"+j.getNumber("id",0));
traity.add(jr);
}
}
return traity;
}
示例13: buildCellProcessors
import org.vertx.java.core.json.JsonArray; //导入依赖的package包/类
private CellProcessor[] buildCellProcessors(final JsonArray fields) {
CellProcessor[] processors = new CellProcessor[fields.size()];
for (int i = 0; i < fields.size(); i++) {
JsonArray def = fields.get(i);
String fieldName = def.get(0);
// Any cell processing definitions?
int len = def.size();
if (len > 1) {
CellProcessor nextProcessor = null;
for (int j = (len - 1); j > 0; j--) {
String procDef = def.get(j);
processors[i] = buildCellProcessor(nextProcessor, fieldName, procDef);
nextProcessor = processors[i];
}
} else {
// Nope, use "Optional" as default
processors[i] = new Optional();
}
}
return processors;
}
示例14: NagiosNrdpHandler
import org.vertx.java.core.json.JsonArray; //导入依赖的package包/类
public NagiosNrdpHandler(
final AbstractFilter filter,
final JsonObject config,
final EventBus eventBus,
final JsonArray tags) {
m_processor = new NagiosNrdpProcessor(
filter,
config.getObject(CONF_KEY_NRDP_CONFIG, new JsonObject()),
eventBus,
tags);
try {
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
m_parser = saxParserFactory.newSAXParser();
} catch (ParserConfigurationException | SAXException e) {
throw new IllegalStateException("Failed to create XML parser for NRDP handler", e);
}
}
示例15: createEmptyLineConfig
import org.vertx.java.core.json.JsonArray; //导入依赖的package包/类
private JsonObject createEmptyLineConfig() {
// Command configuration
final JsonObject config = createBaseConfig();
if (HostOs.isWindows()) {
config.putString("command", "cmd");
JsonArray args = new JsonArray();
args.addString("/c");
args.addString("echo.");
config.putArray("args", args);
} else {
config.putString("command", "echo");
}
config.putString("work-dir", "build");
return config;
}