TagW implements Serializable { protected static String getFormattedText(Object value, String format) { if (value == null) { return StringUtil.EMPTY_STRING; } String str; if (value instanceof String) { str = (String) value; } else if (value instanceof String[]) { str = Arrays.asList((String[]) value).stream().collect(Collectors.joining("\\")); } else if (value instanceof TemporalAccessor) { str = TagUtil.formatDateTime((TemporalAccessor) value); } else if (value instanceof TemporalAccessor[]) { str = Stream.of((TemporalAccessor[]) value).map(TagUtil::formatDateTime).collect(Collectors.joining(", ")); } else if (value instanceof float[]) { float[] array = (float[]) value; str = IntStream.range(0, array.length).mapToObj(i -> String.valueOf(array[i])) .collect(Collectors.joining(", ")); } else if (value instanceof double[]) { str = DoubleStream.of((double[]) value).mapToObj(String::valueOf).collect(Collectors.joining(", ")); } else if (value instanceof int[]) { str = IntStream.of((int[]) value).mapToObj(String::valueOf).collect(Collectors.joining(", ")); } else { str = value.toString(); } if (StringUtil.hasText(format) && !"$V".equals(format.trim())) { return formatValue(str, value instanceof Float || value instanceof Double, format); } return str == null ? StringUtil.EMPTY_STRING : str; } TagW(int id, String keyword, String displayedName, TagType type, int vmMin, int vmMax, Object defaultValue);  TagW(int id, String keyword, TagType type, int vmMin, int vmMax);  TagW(int id, String keyword, String displayedName, TagType type);  TagW(int id, String keyword, TagType type);  TagW(String name, TagType type, int vmMin, int vmMax);  TagW(String keyword, String displayedName, TagType type);  TagW(String keyword, TagType type); int getId(); String getKeyword(); String getDisplayedName(); TagType getType(); int getValueMultiplicity(); boolean isTypeCompliant(Object value); static int getValueMultiplicity(Object value); static Object getValueFromIndex(Object value, int index); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode(); void readValue(Object data, Tagable tagable); Object getValue(Object data); boolean isStringFamilyType(); synchronized int getAnonymizationType(); synchronized void setAnonymizationType(int anonymizationType); String getFormattedTagValue(Object value, String format); static void addTag(TagW tag); static TagW get(String keyword); static T getTagValue(TagReadable tagable, TagW tag, Class<T> type); static final String NO_VALUE; static final TagW UnknownTag; static final TagW Group; static final TagW PatientPseudoUID; static final TagW SeriesLoading; static final TagW Thumbnail; static final TagW ThumbnailPath; static final TagW ExplorerModel; static final TagW PresentationModel; static final TagW PresentationModelBirary; static final TagW SplitSeriesNumber; static final TagW SeriesSelected; static final TagW SeriesOpen; static final TagW SeriesFocused; static final TagW ImageWidth; static final TagW ImageHeight; static final TagW ImageDepth; static final TagW ImageOrientationPlane; static final TagW ImageBitsPerPixel; static final TagW ImageCache; static final TagW ShutterFinalShape; static final TagW ShutterRGBColor; static final TagW ShutterPSValue; static final TagW OverlayBitMask; static final TagW OverlayBurninDataPath; static final TagW HasOverlay; static final TagW ObjectToSave; static final TagW WadoCompressionRate; static final TagW WadoTransferSyntaxUID; static final TagW DirectDownloadFile; static final TagW DirectDownloadThumbnail; static final TagW ReadFromDicomdir; static final TagW WadoParameters; static final TagW WadoInstanceReferenceList; static final TagW DicomSpecialElementList; static final TagW SlicePosition; static final TagW SuvFactor; static final TagW RootElement; static final TagW FilePath; static final TagW FileName; static final TagW CurrentFolder; static final TagW Checked; static final TagW SubseriesInstanceUID; static final TagW VOILUTsExplanation; static final TagW VOILUTsData; static final TagW ModalityLUTExplanation; static final TagW ModalityLUTType; static final TagW ModalityLUTData; static final TagW PRLUTsExplanation; static final TagW PRLUTsData; static final TagW MonoChrome; }
@Test public void test_getFormattedText_with_pattern() throws Exception { String value = "Lorem Ipsum"; assertThat(TagW.getFormattedText(value, "")).isEqualTo(value); assertThat(TagW.getFormattedText(value, "$V")).isEqualTo(value); assertThat(TagW.getFormattedText(value, "$V ")).isEqualTo(value); assertThat(TagW.getFormattedText(value, " $V")).isEqualTo(value); assertThat(TagW.getFormattedText(value, "test: $V")).isEqualTo("test: " + value); assertThat(TagW.getFormattedText(value, "test: $V and $V")).isEqualTo("test: " + value + " and $V"); assertThat(TagW.getFormattedText(STRING_ARRAY, "test: $V and $V plus $V")) .isEqualTo("test: " + STRING_ARRAY[0] + "\\" + STRING_ARRAY[1] + " and $V plus $V"); }