本文整理汇总了Java中org.vertx.java.core.json.JsonArray.size方法的典型用法代码示例。如果您正苦于以下问题:Java JsonArray.size方法的具体用法?Java JsonArray.size怎么用?Java JsonArray.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.vertx.java.core.json.JsonArray
的用法示例。
在下文中一共展示了JsonArray.size方法的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: 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;
}
示例3: formatSearchResult
import org.vertx.java.core.json.JsonArray; //导入方法依赖的package包/类
private void formatSearchResult(final JsonArray results, final JsonArray columnsHeader, final Handler<Either<String, JsonArray>> handler) {
final List<String> aHeader = columnsHeader.toList();
final JsonArray traity = new JsonArray();
if (results.size() == 0) {
handler.handle(new Right<String, JsonArray>(traity));
} else {
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("name"));
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), "/collaborativeeditor#/view/" + j.getString("_id"));
traity.add(jr);
}
}
handler.handle(new Right<String, JsonArray>(traity));
}
}
示例4: 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);
}
示例5: 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;
}
示例6: canBypassDelaysConstraints
import org.vertx.java.core.json.JsonArray; //导入方法依赖的package包/类
private boolean canBypassDelaysConstraints(String owner, String schoolId, UserInfos user, JsonArray managers) {
if(user.getUserId().equals(owner)) {
return true;
}
List<String> scope = getLocalAdminScope(user);
if (scope!=null && !scope.isEmpty() && scope.contains(schoolId)) {
return true;
}
if(managers != null && managers.size() > 0) {
// Create a list containing userId and groupIds of current user
List<String> userAndGroupIds = new ArrayList<>();
userAndGroupIds.add(user.getUserId());
userAndGroupIds.addAll(user.getGroupsIds());
// Return true if managers and userAndGroupIds have at least one common element
if (!Collections.disjoint(userAndGroupIds, managers.toList())) {
return true;
}
}
return false;
}
示例7: formatSearchResult
import org.vertx.java.core.json.JsonArray; //导入方法依赖的package包/类
private JsonArray formatSearchResult(final JsonArray results, final JsonArray columnsHeader, String locale) {
final List<String> aHeader = columnsHeader.toList();
final JsonArray traity = new JsonArray();
final String dateFormat = "EEEEE dd MMMMM yyyy " + i18n.translate("rbs.search.date.to", I18n.DEFAULT_DOMAIN, locale) + " HH:mm";
final DateFormat dateFormatFromDB = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
for (int i=0;i<results.size();i++) {
final JsonObject j = results.get(i);
final JsonObject jr = new JsonObject();
if (j != null) {
Long start = 0L;
Long end = 0L;
try {
start = dateFormatFromDB.parse(j.getString("start_date")).getTime();
end = dateFormatFromDB.parse(j.getString("end_date")).getTime();
} catch (ParseException e) {
log.error("Can't parse date form RBS DB", e);
}
jr.putString(aHeader.get(0), formatTitle(j, start, end, dateFormat, locale));
jr.putString(aHeader.get(1), j.getString("booking_reason"));
jr.putObject(aHeader.get(2), new JsonObject().putValue("$date",
DatatypeConverter.parseDateTime(j.getString("modified")).getTime().getTime()));
jr.putString(aHeader.get(3), j.getString("owner_name"));
jr.putString(aHeader.get(4), j.getString("owner"));
jr.putString(aHeader.get(5), formatUrl(j.getNumber("id",0), start));
traity.add(jr);
}
}
return traity;
}
示例8: groupEventsPerTopic
import org.vertx.java.core.json.JsonArray; //导入方法依赖的package包/类
private Map<String, List<JsonObject>> groupEventsPerTopic(
final JsonObject batchEvent,
final String topicSelector) {
//
// 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);
}
Map<String, List<JsonObject>> topics = new HashMap();
for (int i = 0; i < batch.size(); i++) {
JsonObject event = batch.get(i);
String topic = String.valueOf(variables().translate(event, topicSelector));
List<JsonObject> events = topics.get(topic);
if (events == null) {
events = new ArrayList();
}
events.add(event);
topics.put(topic, events);
}
return topics;
}
示例9: init
import org.vertx.java.core.json.JsonArray; //导入方法依赖的package包/类
public void init() {
String dsnameSeparator = m_config.getString(CONF_KEY_DSNAME_SEPARATOR, DEF_DSNAME_SEPARATOR);
String itemSeparator = m_config.getString(CONF_KEY_ITEM_SEPARATOR, DEF_ITEM_SEPARATOR);
// Build default mappings
CollectdMapping.buildDefaults(m_mappings,
dsnameSeparator,
itemSeparator);
// Mappings defined in the configuration
JsonArray jsonMappings = m_config.getArray(CONF_KEY_MAPPINGS, new JsonArray());
for (int i = 0; i < jsonMappings.size(); i++) {
JsonObject jsonMapping = (JsonObject) jsonMappings.get(i);
String plugin = jsonMapping.getString(COLLECTD_KEY_PLUGIN);
CollectdMapping mapping = new CollectdMapping(
jsonMapping.getString(SPIKEX_KEY_DSNAME, ""),
jsonMapping.getString(SPIKEX_KEY_DSTYPE, ""),
jsonMapping.getString(SPIKEX_KEY_SUBGROUP, ""),
jsonMapping.getString(SPIKEX_KEY_INSTANCE, ""),
dsnameSeparator,
itemSeparator);
m_mappings.put(plugin, mapping);
}
}
示例10: deleteGroups
import org.vertx.java.core.json.JsonArray; //导入方法依赖的package包/类
@Override
public void deleteGroups(JsonArray groups) {
if(groups != null && groups.size() > 0) {
final JsonArray gIds = new JsonArray();
for (Object o : groups) {
if (!(o instanceof JsonObject)) continue;
final JsonObject j = (JsonObject) o;
gIds.add(j.getString("group"));
}
if (gIds.size() > 0) {
// Delete the groups. Cascade delete : delete from members, thread_shares and info_shares too
Sql.getInstance().prepared("DELETE FROM actualites.groups WHERE id IN " + Sql.listPrepared(gIds.toArray())
, gIds, SqlResult.validRowsResultHandler(new Handler<Either<String, JsonObject>>() {
@Override
public void handle(Either<String, JsonObject> event) {
if (event.isRight()) {
log.info("[ActualitesRepositoryEvents][deleteGroups]The groups and their shares are deleted");
} else {
log.error("[ActualitesRepositoryEvents][deleteGroups] Error deleting the groups and their shares. Message : " + event.left().getValue());
}
}
}));
}
} else {
log.warn("[ActualitesRepositoryEvents][deleteGroups] groups is null or empty");
}
}
示例11: startFilter
import org.vertx.java.core.json.JsonArray; //导入方法依赖的package包/类
@Override
protected void startFilter() {
//
// Use Bouncy Castle as our security provider
// Needed for PKCS#8 parsing
//
Provider bcProvider = Security.getProvider(BouncyCastleProvider.PROVIDER_NAME);
if (bcProvider == null) {
Security.addProvider(new BouncyCastleProvider());
}
NsqClientConfig config = NsqClientConfig.builder(config()).build();
List<String> nodes = config.getNodes();
// Sanity checks
Preconditions.checkArgument(nodes.size() > 0, "No nodes defined");
//
// Topics
//
m_topics = new ArrayList();
JsonArray topics = config().getArray(CONF_KEY_TOPICS, new JsonArray());
for (int i = 0; i < topics.size(); i++) {
JsonObject topicConfig = topics.get(i);
m_topics.add(Topic.create(topicConfig));
}
//
// Producer
//
NSQConfig nsqConfig = config.buildNSQConfig(variables());
m_producer = new NSQProducer();
m_producer.setConfig(nsqConfig);
for (String host : nodes) {
int port = NSQ_HTTP_PORT;
int pos = host.lastIndexOf(":");
if (pos != -1) {
port = Integer.parseInt(host.substring(pos + 1));
host = host.substring(0, pos);
}
m_producer.addAddress(host, port);
}
m_producer.start();
}
示例12: startClient
import org.vertx.java.core.json.JsonArray; //导入方法依赖的package包/类
@Override
protected void startClient() {
// URL escape database name and admin (the others must be predefined constants)
m_databaseName = config().getString(CONF_KEY_DATABASE_NAME, DEF_DATABASE_NAME);
m_consistency = config().getString(CONF_KEY_CONSISTENCY, DEF_CONSISTENCY);
m_precision = config().getString(CONF_KEY_PRECISION, DEF_PRECISION);
String adminUser = config().getString(CONF_KEY_ADMIN_USER, "");
String adminPassword = config().getString(CONF_KEY_ADMIN_PASSWORD, "");
//
// Series
//
m_series = new ArrayList();
JsonArray series = config().getArray(CONF_KEY_SERIES, new JsonArray());
for (int i = 0; i < series.size(); i++) {
JsonObject serieConfig = series.get(i);
m_series.add(Serie.create(serieConfig));
}
//
// Sanity checks
//
Preconditions.checkArgument(m_series.size() > 0, "No series defined");
//
// Create database on startup
//
if (config().getBoolean(CONF_KEY_CREATE_DATABASE_ON_STARTUP,
DEF_CREATE_DATABASE_ON_STARTUP)) {
String retention = config().getString(CONF_KEY_RETENTION_DURATION,
DEF_RETENTION_DURATION);
logger().info("Creating database: {} with retention duration: {}",
m_databaseName,
retention);
doQuery(
"CREATE DATABASE " + m_databaseName,
adminUser,
adminPassword);
doQuery(
"CREATE RETENTION POLICY " + m_databaseName
+ " ON " + m_databaseName
+ " DURATION " + retention
+ " REPLICATION 1",
adminUser,
adminPassword);
}
}
示例13: handleEvent
import org.vertx.java.core.json.JsonArray; //导入方法依赖的package包/类
@Override
protected void handleEvent(final JsonObject batchEvent) {
try {
if (isStarted()) {
int available = connections().getAvailableCount();
logger().trace("Received event: {} batch-size: {} available servers: {}",
batchEvent.getString(EVENT_FIELD_ID),
batchEvent.getInteger(EVENT_FIELD_BATCH_SIZE, 0),
available);
//
// 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);
}
if (available > 0) {
String precision = m_precision;
List<String> points = new ArrayList();
for (int i = 0; i < batch.size(); i++) {
//
// Does event match any serie definition
//
JsonObject event = batch.get(i);
for (Serie serie : m_series) {
if (serie.isMatch(event)) {
String point = translateToDataPoint(serie, event, precision);
logger().trace("Data point: {}", point);
// Ignore empty points (eg. empty value fields)
if (point != null) {
points.add(point);
}
break; // Match found, handle next event
}
}
}
//
// Store events in InfluxDB
//
if (points.size() > 0) {
IConnection<HttpClient> connection = connections().next();
InfluxDbWriter handler = new InfluxDbWriter(
connection,
m_databaseName,
m_consistency,
m_precision,
points);
connection.doRequest(handler);
}
}
}
} catch (ConnectionException e) {
logger().error("Failed to publish event: {}",
batchEvent.getString(EVENT_FIELD_ID), e);
}
}
示例14: deleteUsers
import org.vertx.java.core.json.JsonArray; //导入方法依赖的package包/类
@Override
public void deleteUsers(JsonArray users) {
//FIXME: anonymization is not relevant
if (users != null && users.size() > 0) {
final JsonArray uIds = new JsonArray();
for (Object u : users) {
if (!(u instanceof JsonObject)) continue;
final JsonObject j = (JsonObject) u;
uIds.add(j.getString("id"));
}
SqlStatementsBuilder statementsBuilder = new SqlStatementsBuilder();
// Remove all thread shares from thread_shares table
statementsBuilder.prepared("DELETE FROM actualites.thread_shares WHERE member_id IN " + Sql.listPrepared(uIds.toArray()), uIds);
// Remove all news shares from info_shares table
statementsBuilder.prepared("DELETE FROM actualites.info_shares WHERE member_id IN " + Sql.listPrepared(uIds.toArray()), uIds);
// Delete users (Set deleted = true in users table)
statementsBuilder.prepared("UPDATE actualites.users SET deleted = true WHERE id IN " + Sql.listPrepared(uIds.toArray()), uIds);
// Delete all threads where the owner is deleted and no manager rights shared on these resources
// Cascade delete : the news that belong to these threads will be deleted too
// thus, no need to delete news that do not have a manager because the thread owner is still there
statementsBuilder.prepared("DELETE FROM actualites.thread" +
" USING (" +
" SELECT DISTINCT t.id, count(ts.member_id) AS managers" +
" FROM actualites.thread AS t" +
" LEFT OUTER JOIN actualites.thread_shares AS ts ON t.id = ts.resource_id AND ts.action = ?" +
" LEFT OUTER JOIN actualites.users AS u ON t.owner = u.id" +
" WHERE u.deleted = true" +
" GROUP BY t.id" +
" ) a" +
" WHERE actualites.thread.id = a.id" +
" AND a.managers = 0"
, new JsonArray().add(MANAGE_RIGHT_ACTION));
Sql.getInstance().transaction(statementsBuilder.build(), SqlResult.validRowsResultHandler(new Handler<Either<String, JsonObject>>() {
@Override
public void handle(Either<String, JsonObject> event) {
if (event.isRight()) {
log.info("[ActualitesRepositoryEvents][cleanDataBase] The resources created by users are deleted");
} else {
log.error("[ActualitesRepositoryEvents][cleanDataBase] Error deleting the resources created by users. Message : " + event.left().getValue());
}
}
}));
} else {
log.warn("[ActualitesRepositoryEvents][deleteUsers] users is empty");
}
}
示例15: handleEvent
import org.vertx.java.core.json.JsonArray; //导入方法依赖的package包/类
@Override
protected void handleEvent(final JsonObject batchEvent) {
try {
if (isStarted()) {
int available = connections().getAvailableCount();
logger().trace("Received event: {} batch-size: {} available servers: {}",
batchEvent.getString(EVENT_FIELD_ID),
batchEvent.getInteger(EVENT_FIELD_BATCH_SIZE, 0),
available);
if (available > 0) {
IConnection<HttpClient> connection = connections().next();
//
// 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);
}
// Dweet away
for (int i = 0; i < batch.size(); i++) {
JsonObject event = batch.get(i);
// Dweetify dsname and value for easy access in freeboard
m_dweets.put(
event.getString(EVENT_FIELD_DSNAME),
event.getValue(EVENT_FIELD_VALUE));
JsonObject dweet = new JsonObject(m_dweets);
DweetPublisher handler = new DweetPublisher(
connection,
m_thingName,
m_dweetPath,
dweet);
connection.doRequest(handler);
}
}
}
} catch (ConnectionException e) {
logger().error("Failed to publish event: {}",
batchEvent.getString(EVENT_FIELD_ID), e);
}
}