org.opencds.cqf.cql.engine.debug.DebugLibraryResultEntry Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of engine Show documentation
Show all versions of engine Show documentation
The engine library for the Clinical Quality Language Java reference implementation
package org.opencds.cqf.cql.engine.debug;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.hl7.elm.r1.Element;
public class DebugLibraryResultEntry {
private String libraryName;
public String getLibraryName() {
return this.libraryName;
}
public DebugLibraryResultEntry(String libraryName) {
this.libraryName = libraryName;
this.results = new HashMap>();
}
private Map> results;
public Map> getResults() {
return results;
}
private void logDebugResult(DebugLocator locator, Object result) {
if (!results.containsKey(locator)) {
results.put(locator, new ArrayList());
}
List debugResults = results.get(locator);
debugResults.add(new DebugResultEntry(result));
}
public void logDebugResultEntry(Element node, Object result) {
if (node instanceof Element) {
Element element = (Element) node;
if (element.getLocalId() != null) {
DebugLocator locator = new DebugLocator(DebugLocator.DebugLocatorType.NODE_ID, element.getLocalId());
logDebugResult(locator, result);
}
if (element.getLocator() != null) {
DebugLocator locator = new DebugLocator(Location.fromLocator(element.getLocator()));
logDebugResult(locator, result);
}
} else {
DebugLocator locator = new DebugLocator(
DebugLocator.DebugLocatorType.NODE_TYPE, node.getClass().getSimpleName());
logDebugResult(locator, result);
}
}
}