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

org.cqframework.cql.cql2elm.CqlTranslatorOptionsMapper Maven / Gradle / Ivy

Go to download

The cql-to-elm library for the Clinical Quality Language Java reference implementation

There is a newer version: 3.18.0
Show newest version
package org.cqframework.cql.cql2elm;

import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.*;

public class CqlTranslatorOptionsMapper {
    private static ObjectMapper om = new ObjectMapper();

    public static CqlTranslatorOptions fromFile(String fileName) {
        FileReader fr = null;
        try {
            fr = new FileReader(fileName);
            return fromReader(fr);
        } catch (IOException e) {
            throw new RuntimeException(String.format("Errors occurred reading options: %s", e.getMessage()));
        }
    }

    public static CqlTranslatorOptions fromReader(Reader reader) {
        try {
            return om.readValue(reader, CqlTranslatorOptions.class);
        } catch (IOException e) {
            throw new RuntimeException(String.format("Errors occurred reading options: %s", e.getMessage()));
        }
    }

    public static void toFile(String fileName, CqlTranslatorOptions options) {
        FileWriter fw = null;
        try {
            fw = new FileWriter(fileName);
            toWriter(fw, options);
        } catch (IOException e) {
            throw new RuntimeException(String.format("Errors occurred writing options: %s", e.getMessage()));
        }
    }

    public static void toWriter(Writer writer, CqlTranslatorOptions options) {
        ObjectMapper om = new ObjectMapper();
        try {
            om.writeValue(writer, options);
        } catch (IOException e) {
            throw new RuntimeException(String.format("Errors occurred writing options: %s", e.getMessage()));
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy