kg.apc.jmeter.vizualizers.CompositeModel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jmeter-plugins-cmn-jmeter Show documentation
Show all versions of jmeter-plugins-cmn-jmeter Show documentation
Various utility classes to ease development of plugins
The newest version!
package kg.apc.jmeter.vizualizers;
import java.io.Serializable;
import java.util.Iterator;
import java.util.concurrent.ConcurrentSkipListMap;
import kg.apc.charting.AbstractGraphRow;
import kg.apc.jmeter.graphs.CompositeNotifierInterface;
public class CompositeModel implements Serializable {
private ConcurrentSkipListMap> models = null;
private Iterator emptyIterator = null;
private CompositeNotifierInterface notifier = null;
public CompositeModel() {
models = new ConcurrentSkipListMap<>();
}
//needed to refresh tree if row model changed
public void setNotifier(CompositeNotifierInterface notifier) {
this.notifier = notifier;
}
public void clear() {
models.clear();
}
private synchronized ConcurrentSkipListMap getRowsMap(String vizualizerName) {
ConcurrentSkipListMap rows = models.get(vizualizerName);
if (rows == null) {
rows = new ConcurrentSkipListMap<>();
models.put(vizualizerName, rows);
}
return rows;
}
public void addRow(String vizualizerName, AbstractGraphRow row) {
ConcurrentSkipListMap rows = models.get(vizualizerName);
if (rows == null) {
rows = getRowsMap(vizualizerName);
}
rows.put(row.getLabel(), row);
notifier.refresh();
}
public void clearRows(String vizualizerName) {
models.remove(vizualizerName);
notifier.refresh();
}
public boolean containsVisualizer(String vizualizerName) {
return models.containsKey(vizualizerName);
}
public Iterator getVizualizerNamesIterator() {
return models.keySet().iterator();
}
public Iterator getRowsIterator(String vizualizerName) {
ConcurrentSkipListMap rows = models.get(vizualizerName);
if (rows != null) {
return rows.values().iterator();
} else {
if (emptyIterator == null) {
emptyIterator = new ConcurrentSkipListMap().values().iterator();
}
return emptyIterator;
}
}
public AbstractGraphRow getRow(String testName, String rowName) {
ConcurrentSkipListMap rows = models.get(testName);
if (rows != null) {
return models.get(testName).get(rowName);
} else {
return null;
}
}
}