use of org.hl7.fhir.r4b.elementmodel.Manager.FhirFormat in project org.hl7.fhir.core by hapifhir.
the class FormatUtilities method loadFile.
public static Resource loadFile(String path) throws FileNotFoundException, IOException, FHIRException {
byte[] src = TextFile.fileToBytes(path);
FhirFormat fmt = determineFormat(src);
ParserBase parser = makeParser(fmt);
return parser.parse(src);
}
use of org.hl7.fhir.r4b.elementmodel.Manager.FhirFormat in project org.hl7.fhir.core by hapifhir.
the class SpecDifferenceEvaluator method saveResource.
private void saveResource(ZipGenerator zip, Resource t, FhirFormat fmt) throws IOException {
ByteArrayOutputStream bs = new ByteArrayOutputStream();
if (fmt == FhirFormat.JSON)
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(bs, t);
else
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(bs, t);
zip.addBytes(t.fhirType() + "-" + t.getId() + "." + fmt.getExtension(), bs.toByteArray(), true);
}
use of org.hl7.fhir.r4b.elementmodel.Manager.FhirFormat in project org.hl7.fhir.core by hapifhir.
the class FormatUtilities method loadFile.
public static Resource loadFile(InputStream source) throws FileNotFoundException, IOException, FHIRException {
byte[] src = TextFile.streamToBytes(source);
FhirFormat fmt = determineFormat(src);
ParserBase parser = makeParser(fmt);
return parser.parse(src);
}
use of org.hl7.fhir.r4b.elementmodel.Manager.FhirFormat in project org.hl7.fhir.core by hapifhir.
the class FormatUtilities method loadFile.
public static Resource loadFile(String path) throws FileNotFoundException, IOException, FHIRException {
byte[] src = TextFile.fileToBytes(path);
FhirFormat fmt = determineFormat(src);
ParserBase parser = makeParser(fmt);
return parser.parse(src);
}
Aggregations