Java Code Examples for org.json.simple.JSONObject#forEach()

The following examples show how to use org.json.simple.JSONObject#forEach() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArtemisDataReader.java    From maestro-java with Apache License 2.0 6 votes vote down vote up
/**
 * Reads runtime information information (might be JVM-specific)
 * @return operating system information
 * @throws MalformedObjectNameException JMX internal/specific error
 * @throws J4pException if unable to read (ie: forbidden to read the value)
 */
@SuppressWarnings("unchecked")
public RuntimeInfo runtimeInformation() throws MalformedObjectNameException, J4pException {
    JSONObject jo = getJsonObject("java.lang:type=Runtime", "");

    Map<String, Object> osProperties = new HashMap<>();
    JolokiaConverter jolokiaConverter = new MapConverter(osProperties);
    jo.forEach((key, value) -> defaultJolokiaParser.parse(jolokiaConverter, key, value));

    return new RuntimeInfo(osProperties);
}
 
Example 2
Source File: BigQueryLoader.java    From quetzal with Eclipse Public License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public JSONObject apply(Iterable<JSONObject> input) {
	JSONObject x = new JSONObject();

	for(JSONObject y : input) {
		y.forEach((Object t, Object u) -> {
			String pred = (String) t;
			T v = (T) u;
			if (! x.containsKey(pred)) {
				x.put(pred, v);
			} else {
				x.put(pred, merge.merge((T)x.get(pred), v));
			}
		});
	}

	return x;
}
 
Example 3
Source File: ServiceBuilder.java    From sepia-assist-server with MIT License 5 votes vote down vote up
/**
 * Add all result info key-value pairs to this resultInfo. This is usually done when taking a resultInfo from a MASTER service
 * and add the values to the interview resultInfo.
 */
@SuppressWarnings("unchecked")
public void resultInfoAddAll(JSONObject resultInfo){
	resultInfo.forEach((k, v)->{
		this.resultInfo.put(k, v);
	});
}
 
Example 4
Source File: ArtemisDataReader.java    From maestro-java with Apache License 2.0 5 votes vote down vote up
/**
 * Reads JVM Heap heap memory information information (might be JVM-specific)
 * @return JVM heap memory information
 * @throws MalformedObjectNameException JMX internal/specific error
 * @throws J4pException if unable to read (ie: forbidden to read the value)
 */
@SuppressWarnings("unchecked")
public List<JVMMemoryInfo> jvmMemoryAreas() throws MalformedObjectNameException, J4pException {
    JSONObject jo = getJsonObject("java.lang:name=*,type=MemoryPool", "Usage");

    List<JVMMemoryInfo> jvmMemoryInfos = new LinkedList<>();
    JolokiaConverter jolokiaConverter = new JVMMemoryConverter(jvmMemoryInfos, "Usage");
    jo.forEach((key, value) -> defaultJolokiaParser.parse(jolokiaConverter, key, value));

    return jvmMemoryInfos;
}
 
Example 5
Source File: ArtemisDataReader.java    From maestro-java with Apache License 2.0 5 votes vote down vote up
/**
 * Reads operating system information information (might be JVM-specific)
 * @return operating system information
 * @throws MalformedObjectNameException JMX internal/specific error
 * @throws J4pException if unable to read (ie: forbidden to read the value)
 */
@SuppressWarnings("unchecked")
public OSInfo operatingSystem() throws MalformedObjectNameException, J4pException {
    JSONObject jo = getJsonObject("java.lang:type=OperatingSystem", "");

    Map<String, Object> osProperties = new HashMap<>();
    JolokiaConverter jolokiaConverter = new MapConverter(osProperties);
    jo.forEach((key, value) -> defaultJolokiaParser.parse(jolokiaConverter, key, value));

    return new OSInfo(osProperties);
}
 
Example 6
Source File: ArtemisDataReader.java    From maestro-java with Apache License 2.0 5 votes vote down vote up
/**
 * Read queue information
 * @return queue information
 * @throws MalformedObjectNameException JMX internal/specific error
 * @throws J4pException if unable to read (ie: forbidden to read the value)
 */
@SuppressWarnings("unchecked")
public QueueInfo queueInformation() throws MalformedObjectNameException, J4pException {
    JSONObject jo = getJsonObject("org.apache.activemq.artemis:address=*,broker=*,component=addresses,queue=*,*", "");

    Map<String, Object> queueProperties = new HashMap<>();
    QueueInfoConverter jolokiaConverter = new QueueInfoConverter(queueProperties);
    jo.forEach((key, value) -> defaultJolokiaParser.parseQueueInfo(jolokiaConverter, key, value));

    return new QueueInfo(queueProperties);
}
 
Example 7
Source File: ArtemisDataReader.java    From maestro-java with Apache License 2.0 5 votes vote down vote up
/**
 * Read product information
 * @return the product information
 * @throws MalformedObjectNameException JMX internal/specific error
 * @throws J4pException if unable to read (ie: forbidden to read the value)
 */
@SuppressWarnings("unchecked")
public ProductInfo productInformation() throws MalformedObjectNameException, J4pException {
    JSONObject jo = getJsonObject("org.apache.activemq.artemis:broker=*", "Version");

    Map<String, Object> productProperties = new HashMap<>();
    JolokiaConverter converter = new MapConverter(productProperties);
    jo.forEach((key, value) -> defaultJolokiaParser.parse(converter, key, value));

    return new ArtemisProductInfo(productProperties);
}
 
Example 8
Source File: MessageBuilder.java    From metron with Apache License 2.0 2 votes vote down vote up
/**
 * Adds all of the fields from a message to this message.
 *
 * @param prototype The other message that is treated as a prototype.
 * @return A {@link MessageBuilder}
 */
public MessageBuilder withFields(JSONObject prototype) {
  prototype.forEach((key, val) -> this.fields.put(key, val));
  return this;
}