diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/ComparisonRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/ComparisonRenderer.java index 2e69deade..59344bac9 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/ComparisonRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/ComparisonRenderer.java @@ -115,14 +115,14 @@ public class ComparisonRenderer implements IEvaluationContext { } private void dumpBinaries() throws IOException { - if (contextLeft != null && contextLeft.getBinaries() != null) { - for (String k : contextLeft.getBinaries().keySet()) { - TextFile.bytesToFile(contextLeft.getBinaries().get(k), Utilities.path(folder, k)); + if (contextLeft != null && contextLeft.getBinaryKeysAsSet() != null) { + for (String k : contextLeft.getBinaryKeysAsSet()) { + TextFile.bytesToFile(contextLeft.getBinaryForKey(k), Utilities.path(folder, k)); } } - if (contextRight != null && contextRight.getBinaries() != null) { - for (String k : contextRight.getBinaries().keySet()) { - TextFile.bytesToFile(contextRight.getBinaries().get(k), Utilities.path(folder, k)); + if (contextRight != null && contextRight.getBinaryKeysAsSet() != null) { + for (String k : contextRight.getBinaryKeysAsSet()) { + TextFile.bytesToFile(contextRight.getBinaryForKey(k), Utilities.path(folder, k)); } } } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java index 0849cd7e2..ec56f847f 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java @@ -2161,10 +2161,18 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte } @Override - public Map getBinaries() { - return binaries; + public Set getBinaryKeysAsSet() { return binaries.keySet(); } + + @Override + public boolean hasBinaryKey(String binaryKey) { + return binaries.containsKey(binaryKey); } - + + @Override + public byte[] getBinaryForKey(String binaryKey) { + return binaries.get(binaryKey); + } + public void finishLoading() { for (StructureDefinition sd : listStructures()) { try { diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java index 020ddc8b9..3521f353d 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java @@ -833,7 +833,28 @@ public interface IWorkerContext { public void setUcumService(UcumService ucumService); public String getLinkForUrl(String corePath, String s); - public Map getBinaries(); + + /** + * Returns a set of keys that can be used to get binaries from this context. + * + * @return a set of binaries or null + */ + public Set getBinaryKeysAsSet(); + + /** + * Returns true if this worker context contains a binary for this key. + * + * @param binaryKey + * @return true if binary is available for this key + */ + public boolean hasBinaryKey(String binaryKey); + + /** + * Returns the binary for the key + * @param binaryKey + * @return + */ + public byte[] getBinaryForKey(String binaryKey); /** * Load relevant resources of the appropriate types (as specified by the loader) from the nominated package diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/XVerExtensionManager.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/XVerExtensionManager.java index 7e577452b..071676dc8 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/XVerExtensionManager.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/XVerExtensionManager.java @@ -52,9 +52,9 @@ public class XVerExtensionManager { String v = url.substring(20, 23); String e = url.substring(54); if (!lists.containsKey(v)) { - if (context.getBinaries().containsKey("xver-paths-"+v+".json")) { + if (context.hasBinaryKey("xver-paths-"+v+".json")) { try { - lists.put(v, JsonTrackingParser.parseJson(context.getBinaries().get("xver-paths-"+v+".json"))); + lists.put(v, JsonTrackingParser.parseJson(context.getBinaryForKey("xver-paths-"+v+".json"))); } catch (IOException e1) { throw new FHIRException(e); } diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/services/ComparisonService.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/services/ComparisonService.java index 795739d76..be5907233 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/services/ComparisonService.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/services/ComparisonService.java @@ -67,11 +67,11 @@ public class ComparisonService { System.out.println("Generating output to " + dest + "..."); Utilities.createDirectory(dest); ComparisonRenderer cr = new ComparisonRenderer(validator.getContext(), validator.getContext(), dest, session); - cr.getTemplates().put("CodeSystem", new String(validator.getContext().getBinaries().get("template-comparison-CodeSystem.html"))); - cr.getTemplates().put("ValueSet", new String(validator.getContext().getBinaries().get("template-comparison-ValueSet.html"))); - cr.getTemplates().put("Profile", new String(validator.getContext().getBinaries().get("template-comparison-Profile.html"))); - cr.getTemplates().put("Index", new String(validator.getContext().getBinaries().get("template-comparison-index.html"))); - cr.getTemplates().put("CapabilityStatement", new String(validator.getContext().getBinaries().get("template-comparison-CapabilityStatement.html"))); + cr.getTemplates().put("CodeSystem", new String(validator.getContext().getBinaryForKey("template-comparison-CodeSystem.html"))); + cr.getTemplates().put("ValueSet", new String(validator.getContext().getBinaryForKey("template-comparison-ValueSet.html"))); + cr.getTemplates().put("Profile", new String(validator.getContext().getBinaryForKey("template-comparison-Profile.html"))); + cr.getTemplates().put("Index", new String(validator.getContext().getBinaryForKey("template-comparison-index.html"))); + cr.getTemplates().put("CapabilityStatement", new String(validator.getContext().getBinaryForKey("template-comparison-CapabilityStatement.html"))); File htmlFile = cr.render(left, right); Desktop.getDesktop().browse(htmlFile.toURI()); System.out.println("Done");