Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update IExtraMetadataWriter.setExtraMetadata(...) to accept an Object #4243

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);

}