All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.gridkit.jvmtool.jfr_jdk.parser.EventSource Maven / Gradle / Ivy

There is a newer version: 0.9
Show newest version
package org.gridkit.jvmtool.jfr_jdk.parser;

import java.io.IOException;
import java.util.Collection;

import org.gridkit.jvmtool.spi.parsers.JsonEventSource;
import org.gridkit.jvmtool.util.json.JsonStreamWriter;

import jdk.jfr.consumer.RecordingFile;

class EventSource implements JsonEventSource {

	private final RecordingFile rec;
	private final JsonEventAdapter adapter;
	
	public EventSource(RecordingFile rec, int maxJsonDepth) {
		this.rec = rec;
		this.adapter = new JsonEventAdapter(maxJsonDepth);
	}
	
	public void setWhiteList(Collection list) {
		adapter.setWhiteList(list);
	}
	
	public void setBlackList(Collection list) {
		adapter.setBlackList(list);
	}
	
	@Override
	public boolean readNext(JsonStreamWriter writer) throws IOException {
		if (!rec.hasMoreEvents()) {
			return false;
		}
		else {
			adapter.encodeEvent(rec.readEvent(), writer);
			return true;
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy