当前位置: 首页>>代码示例>>Java>>正文


Java JsonArray.get方法代码示例

本文整理汇总了Java中org.vertx.java.core.json.JsonArray.get方法的典型用法代码示例。如果您正苦于以下问题:Java JsonArray.get方法的具体用法?Java JsonArray.get怎么用?Java JsonArray.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.vertx.java.core.json.JsonArray的用法示例。


在下文中一共展示了JsonArray.get方法的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;
}
 
开发者ID:OPEN-ENT-NG,项目名称:share-big-files,代码行数:20,代码来源:ShareBigFilesSearchingEvents.java

示例2: 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);
    }
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:26,代码来源:Logback.java

示例3: 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;
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:21,代码来源:Rule.java

示例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);
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:20,代码来源:Modifier.java

示例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;
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:24,代码来源:DsvLineParser.java

示例6: 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;
}
 
开发者ID:OPEN-ENT-NG,项目名称:actualites,代码行数:23,代码来源:ActualitesSearchingEvents.java

示例7: execute

import org.vertx.java.core.json.JsonArray; //导入方法依赖的package包/类
@Override
public void execute(final Message message) {
    // Call verticle undeploy method
    JsonArray args = getArgs();
    final String verticle = (String) args.get(0);

    m_executor.undeployVerticle(
            verticle,
            new Handler<AsyncResult<Void>>() {

                @Override
                public void handle(AsyncResult<Void> ar) {
                    if (ar.failed()) {
                        m_logger.error("Failed to undeploy verticle: {}",
                                verticle, ar.cause());
                        message.reply(Commands.result(
                                        ERR_UNDEPLOY_FAILED,
                                        REASON_UNDEPLOY_FAILED + ar.cause()));
                    } else {
                        message.reply(RESULT_OK);
                    }
                }
            }
    );
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:26,代码来源:AbstractActivator.java

示例8: handleLocalMessage

import org.vertx.java.core.json.JsonArray; //导入方法依赖的package包/类
@Override
protected void handleLocalMessage(final Message events) {

    JsonArray jsonEvents = (JsonArray) events.body();

    for (int i = 0; i < jsonEvents.size(); i++) {

        JsonObject event = jsonEvents.get(i);

        String eventId = event.getString(EVENT_FIELD_ID, "");
        String title = event.getString(EVENT_FIELD_TITLE, "");
        String message = event.getString(EVENT_FIELD_MESSAGE, "");

        logger().trace("Processing notification: {}", eventId);

        // Event priority
        String priority = event.getString(EVENT_FIELD_PRIORITY,
                EVENT_PRIORITY_NORMAL);

        // Destinations
        JsonArray destinations = event.getArray(EVENT_FIELD_DESTINATIONS,
                new JsonArray());

        // Bombs away...
        send(eventId,
                destinations,
                title,
                message,
                priority);
    }
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:32,代码来源:Dispatcher.java

示例9: 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;
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:28,代码来源:NsqHttp.java

示例10: 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);
        }
    }
 
开发者ID:clidev,项目名称:spike.x,代码行数:29,代码来源:CollectdJsonHandler.java

示例11: buildFieldNames

import org.vertx.java.core.json.JsonArray; //导入方法依赖的package包/类
private String[] buildFieldNames(final JsonArray fields) {
    String[] names = new String[fields.size()];
    for (int i = 0; i < fields.size(); i++) {
        JsonArray def = fields.get(i);
        // Sanity check
        if (def == null || def.size() == 0) {
            throw new IllegalArgumentException(CONFIG_FIELD_FIELDS
                    + " is missing field names");
        }
        names[i] = def.get(0);
    }
    return names;
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:14,代码来源:DsvLineParser.java

示例12: 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();
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:51,代码来源:Nsq.java

示例13: doRequest

import org.vertx.java.core.json.JsonArray; //导入方法依赖的package包/类
@Override
protected void doRequest(final HttpClient client) {

    String uri = ES_PUBLISH_URI;
    HttpClientRequest request = doPost(uri, new HttpClientResponseAdapter() {

        @Override
        protected void handleFailure(final HttpClientResponse response) {
            if (response.statusCode() != 200) {
                m_logger.error("Failed to index events: {} (host: {} index: {})",
                        m_batchEvent.getString(EVENT_FIELD_ID),
                        getConnection().getAddress(),
                        m_indexSelector,
                        new IllegalStateException("HTTP post failure: "
                                + response.statusCode()
                                + "/"
                                + response.statusMessage()));
            }
        }
    });

    //
    // Operate on arrays only (batches)
    //
    JsonArray batch = m_batchEvent.getArray(EVENT_FIELD_BATCH_EVENTS, new JsonArray());
    if (!m_batchEvent.containsField(EVENT_FIELD_BATCH_EVENTS)) {
        batch.addObject(m_batchEvent);
    }

    //
    // Build bulk of json data to post
    // https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
    //
    StringBuilder bulk = new StringBuilder();
    for (int i = 0; i < batch.size(); i++) {
        //
        // Translate index name and type from event contents (if needed)
        //
        JsonObject event = batch.get(i);
        String index = String.valueOf(m_variables.translate(event, m_indexSelector));
        String type = String.valueOf(m_variables.translate(event, m_indexType));

        // Action and meta data
        bulk.append("{\"index\":{\"_index\":\"");
        bulk.append(index);
        bulk.append("\",\"_type\":\"");
        bulk.append(type);
        bulk.append("\",\"_id\":\"");
        bulk.append(event.getString(EVENT_FIELD_ID));
        bulk.append("\"}}\n");
        // Index data
        bulk.append(event.toString());
        bulk.append("\n");
    }

    byte[] body = bulk.toString().getBytes();
    request.putHeader(CONTENT_LENGTH, String.valueOf(body.length));
    request.exceptionHandler(new DefaultConnectionExceptionHandler(
            getConnection()));
    request.write(new Buffer(body));
    request.end();
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:63,代码来源:Elasticsearch.java

示例14: 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);
    }
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:54,代码来源:InfluxDb.java

示例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);

            //
            // 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);
    }
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:62,代码来源:InfluxDb.java


注:本文中的org.vertx.java.core.json.JsonArray.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。