Skip to content

Commit

Permalink
merge master -Dorg -Ssuccess-only: PR 4243 (Update IExtraMetadataWrit…
Browse files Browse the repository at this point in the history
…er.setExtraMetadata(...) to accept an Object)
  • Loading branch information
snoopycrimecop committed Nov 6, 2024
2 parents caea88a + 1b27afa commit 9b99358
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
27 changes: 18 additions & 9 deletions components/formats-bsd/src/loci/formats/out/DicomWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,14 @@ public DicomWriter() {

// -- IExtraMetadataWriter API methods --

/**
* Add a tag provider.
*
* tagSource is expected to be either an ITagProvider,
* or a String file name that can be read by DicomJSONProvider.
*/
@Override
public void setExtraMetadata(String tagSource) {
public void setExtraMetadata(Object tagSource) {
FormatTools.assertId(currentId, false, 1);

StopWatch metadataWatch = stopWatch();
Expand All @@ -157,20 +163,23 @@ public void setExtraMetadata(String tagSource) {

if (tagSource != null) {
ITagProvider provider = null;
if (checkSuffix(tagSource, "json")) {
if (tagSource instanceof ITagProvider) {
provider = (ITagProvider) tagSource;
}
else if (tagSource instanceof String && checkSuffix((String) tagSource, "json")) {
provider = new DicomJSONProvider();
try {
provider.readTagSource((String) tagSource);
}
catch (IOException e) {
LOGGER.error("Could not parse extra metadata: " + tagSource, e);
}
}
else {
throw new IllegalArgumentException("Unknown tag format: " + tagSource);
}

try {
provider.readTagSource(tagSource);
tagProviders.add(provider);
}
catch (IOException e) {
LOGGER.error("Could not parse extra metadata: " + tagSource, e);
}
tagProviders.add(provider);
}
metadataWatch.stop("parsed extra metadata from " + tagSource);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ public interface IExtraMetadataWriter {
*
* All calls to this method must occur before setId is called.
*/
void setExtraMetadata(String metadataSource);
void setExtraMetadata(Object metadataSource);

}

0 comments on commit 9b99358

Please sign in to comment.