Skip to content

Commit d889ae5

Browse files
committed
<wbr> between values of multivalued properties
1 parent 7de8b4c commit d889ae5

File tree

2 files changed

+44
-32
lines changed

2 files changed

+44
-32
lines changed

UnicodeJsps/src/main/java/org/unicode/jsp/UnicodeUtilities.java

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,7 +1654,7 @@ private static void showPropertyValue(
16541654
class PropertyAssignment {
16551655
VersionInfo first;
16561656
VersionInfo last;
1657-
String value;
1657+
ArrayList<String> values;
16581658
}
16591659
final boolean isMultivalued = getFactory().getProperty(propName).isMultivalued();
16601660
List<PropertyAssignment> history = new ArrayList<>();
@@ -1684,16 +1684,17 @@ class PropertyAssignment {
16841684
if (property == null) {
16851685
continue;
16861686
}
1687-
String value = property.getValue(codePoint);
1687+
ArrayList<String> values = new ArrayList<>();
1688+
for (String value : property.getValues(codePoint)) {
1689+
values.add(value);
1690+
}
16881691
PropertyAssignment lastAssignment =
16891692
history.isEmpty() ? null : history.get(history.size() - 1);
1690-
if (lastAssignment == null
1691-
|| (value != null && !value.equals(lastAssignment.value))
1692-
|| (value == null && lastAssignment.value != null)) {
1693+
if (lastAssignment == null || (!values.equals(lastAssignment.values))) {
16931694
PropertyAssignment assignment = new PropertyAssignment();
16941695
assignment.first = version;
16951696
assignment.last = version;
1696-
assignment.value = value;
1697+
assignment.values = values;
16971698
history.add(assignment);
16981699
} else {
16991700
lastAssignment.last = version;
@@ -1704,7 +1705,10 @@ class PropertyAssignment {
17041705
var current = new PropertyAssignment();
17051706
current.first = Settings.LAST_VERSION_INFO;
17061707
current.last = Settings.LAST_VERSION_INFO;
1707-
current.value = getFactory().getProperty(propName).getValue(codePoint);
1708+
current.values = new ArrayList<>();
1709+
for (String value : getFactory().getProperty(propName).getValues(codePoint)) {
1710+
current.values.add(value);
1711+
}
17081712
history.add(current);
17091713
}
17101714
out.append(
@@ -1734,29 +1738,36 @@ class PropertyAssignment {
17341738
boolean isNew = assignment.first == Settings.LATEST_VERSION_INFO;
17351739
String versionRange =
17361740
(showVersion ? (isSingleVersion ? first : first + ".." + last) + ": " : "");
1737-
if (assignment.value == null) {
1738-
out.append("<td" + defaultClass + ">" + versionRange + "<i>null</i></td>");
1739-
} else {
1740-
String hValue = toHTML.transliterate(assignment.value);
1741-
out.append(
1742-
"<td"
1743-
+ defaultClass
1744-
+ ">"
1745-
+ (isMultivalued
1746-
? "<span" + (isNew ? " class='changed'" : "") + ">"
1747-
: ("<a target='u' "
1748-
+ (isNew ? "class='changed' " : "")
1749-
+ "href='list-unicodeset.jsp?a=[:"
1750-
+ (isCurrent ? "" : "U" + last + ":")
1751-
+ propName
1752-
+ "="
1753-
+ hValue
1754-
+ ":]'>"))
1755-
+ versionRange
1756-
+ hValue
1757-
+ (isMultivalued ? "</span>" : "</a>")
1758-
+ "</td>");
1741+
var htmlValue = new StringBuilder();
1742+
for (int i = 0; i < assignment.values.size(); ++i) {
1743+
if (i > 0) {
1744+
htmlValue.append("<wbr>|");
1745+
}
1746+
String value = assignment.values.get(i);
1747+
if (value == null) {
1748+
htmlValue.append("<i>null</i>");
1749+
} else {
1750+
htmlValue.append(toHTML.transliterate(value));
1751+
}
17591752
}
1753+
out.append(
1754+
"<td"
1755+
+ defaultClass
1756+
+ ">"
1757+
+ (isMultivalued
1758+
? "<span" + (isNew ? " class='changed'" : "") + ">"
1759+
: ("<a target='u' "
1760+
+ (isNew ? "class='changed' " : "")
1761+
+ "href='list-unicodeset.jsp?a=[:"
1762+
+ (isCurrent ? "" : "U" + last + ":")
1763+
+ propName
1764+
+ "="
1765+
+ htmlValue.toString()
1766+
+ ":]'>"))
1767+
+ versionRange
1768+
+ htmlValue.toString()
1769+
+ (isMultivalued ? "</span>" : "</a>")
1770+
+ "</td>");
17601771
}
17611772
out.append("</tr>");
17621773
}

unicodetools/src/main/java/org/unicode/props/UnicodeProperty.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,10 @@ public String getVersion() {
265265
}
266266

267267
public Iterable<String> getValues(int codepoint) {
268-
return isMultivalued
269-
? delimiterSplitter.split(getValue(codepoint))
270-
: Collections.singleton(getValue(codepoint));
268+
String value = getValue(codepoint);
269+
return isMultivalued && value != null
270+
? delimiterSplitter.split(value)
271+
: Collections.singleton(value);
271272
}
272273

273274
public String getValue(int codepoint) {

0 commit comments

Comments
 (0)