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

org.gridkit.jvmtool.stacktrace.codec.json.ThreadInfoHandler Maven / Gradle / Ivy

There is a newer version: 0.23
Show newest version
package org.gridkit.jvmtool.stacktrace.codec.json;

import org.gridkit.jvmtool.stacktrace.codec.json.JsonStreamHandler.JsonEntityHandler;
import org.gridkit.jvmtool.stacktrace.codec.json.JsonStreamHandler.JsonObjectHandler;

abstract class ThreadInfoHandler implements JsonObjectHandler {

	protected String javaName;
	protected long osThreadId;
	protected long javaThreadId;

	@Override
	public void onScalarFieldValue(String fieldName, Object val) {
		if (val != null) {
			if ("javaName".equals(fieldName)) {
				javaName = val == null ? null : String.valueOf(val);
			}
			else if ("osThreadId".equals(fieldName)) {
				if (val instanceof Number) {
					osThreadId = ((Number) val).longValue();
				}
			}
			else if ("javaThreadId".equals(fieldName)) {
				Long id = JfrHelper.asLong(val);
				if (id != null) {
					javaThreadId = id;
				}
			}
		}
	}

	@Override
	public JsonEntityHandler onEntityField(String fieldName) {
		return JsonStreamHandler.NULL_HANDLER;
	}

	@Override
	public void onObjectComplete() {
		onComplete();
		javaName = null;
		osThreadId = -1;
		javaThreadId = -1;
	}

	protected abstract void onComplete();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy