Skip to content
Snippets Groups Projects
Commit 53f38d9a authored by Rick Herrick's avatar Rick Herrick
Browse files

XNAT-4393 Removed special characters from code due to problems caused

when cloning the repo with different character encoding. Replaced ad hoc
implementation with commons-lang3 method.
parent 118811ac
No related branches found
No related tags found
No related merge requests found
...@@ -93,74 +93,31 @@ public final class DicomHeaderDump { ...@@ -93,74 +93,31 @@ public final class DicomHeaderDump {
/** /**
* Convert a tag into a row of the XFTTable. * Convert a tag into a row of the XFTTable.
* @param o Necessary so we can get to the description of the tag * @param object Necessary so we can get to the description of the tag
* @param e The current DICOM element * @param element The current DICOM element
* @param parentTag If non null, this is a nested DICOM tag. * @param parentTag If non null, this is a nested DICOM tag.
* @param maxLen The maximum number of characters to read from the description and value * @param maxLen The maximum number of characters to read from the description and value
* @return * @return The strings that comprise the row for the DICOM tag.
*/ */
String[] makeRow(DicomObject o, DicomElement e, String parentTag , int maxLen) { String[] makeRow(final DicomObject object, final DicomElement element, final String parentTag, final int maxLen) {
String tag = TagUtils.toString(e.tag()); final String tag = TagUtils.toString(element.tag());
String value = "";
// If this element has nested tags it doesn't have a value and trying to // If this element has nested tags it doesn't have a value and trying to
// extract one using dcm4che will result in an UnsupportedOperationException // extract one using dcm4che will result in an UnsupportedOperationException
// so check first. // so check first.
if (!e.hasDicomObjects()) { final String value = !element.hasDicomObjects() ? escapeHTML(element.getValueAsString(null, maxLen)) : "";
value = escapeHTML(e.getValueAsString(null, maxLen));
}
else {
value = "";
}
String vr = e.vr().toString(); final String vr = element.vr().toString();
String desc = o.nameOf(e.tag());
// This fixes the unfortunate tendency of DICOM tags to use good typographical but poor programming practices. // This fixes the unfortunate tendency of DICOM tags to use good typographical but poor programming practices.
if (desc.contains("&")) { final String desc = escapeHTML(object.nameOf(element.tag()));
desc = desc.replace("&", "&");
}
if (desc.contains("'")) {
desc = desc.replace("‘", "'");
}
if (desc.contains("‘")) {
desc = desc.replace("‘", "'");
}
if (desc.contains("’")) {
desc = desc.replace("’", "'");
}
if (desc.contains("\"")) {
desc = desc.replace("”", """);
}
if (desc.contains("”")) {
desc = desc.replace("”", """);
}
if (desc.contains("”")) {
desc = desc.replace("”", "'");
}
if (desc.contains("<")) {
desc = desc.replace("”", "&lt;");
}
if (desc.contains(">")) {
desc = desc.replace("”", "&gt;");
}
List<String> l = new ArrayList<>(); final List<String> strings = new ArrayList<>(parentTag == null ? Arrays.asList(tag, "", vr, value, desc) : Arrays.asList(parentTag, tag, vr, value, desc));
if (parentTag == null) { return strings.toArray(new String[strings.size()]);
String[] _s = {tag,"",vr,value,desc};
l.addAll(Arrays.asList(_s));
}
else {
String[] _s = {parentTag, tag, vr, value, desc};
l.addAll(Arrays.asList(_s));
}
String[] row = l.toArray(new String[l.size()]);
return row;
} }
public static String escapeHTML(String o){ public static String escapeHTML(final String value) {
return (o==null)?null: StringEscapeUtils.escapeHtml4(o); return value == null ? null : StringEscapeUtils.escapeHtml4(value);
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment