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

org.opencds.cqf.cql.engine.debug.DebugLibraryResultEntry Maven / Gradle / Ivy

Go to download

The engine library for the Clinical Quality Language Java reference implementation

There is a newer version: 3.18.0
Show newest version
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);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy