Skip to content

Commit 4fced4d

Browse files
authored
Miscellaneous character.jsp cleanups (#1063)
* Highlight changes to multivalued properties * <wbr> between values of multivalued properties * After Markus’s review * <span></a>
1 parent e9af64b commit 4fced4d

File tree

2 files changed

+34
-33
lines changed

2 files changed

+34
-33
lines changed

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

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import java.util.TreeSet;
4242
import java.util.regex.Matcher;
4343
import java.util.regex.Pattern;
44+
import java.util.stream.Collectors;
4445
import org.unicode.cldr.tool.TablePrinter;
4546
import org.unicode.cldr.util.Predicate;
4647
import org.unicode.cldr.util.UnicodeSetPrettyPrinter;
@@ -1654,7 +1655,7 @@ private static void showPropertyValue(
16541655
class PropertyAssignment {
16551656
VersionInfo first;
16561657
VersionInfo last;
1657-
String value;
1658+
ArrayList<String> values;
16581659
}
16591660
final boolean isMultivalued = getFactory().getProperty(propName).isMultivalued();
16601661
List<PropertyAssignment> history = new ArrayList<>();
@@ -1684,16 +1685,15 @@ class PropertyAssignment {
16841685
if (property == null) {
16851686
continue;
16861687
}
1687-
String value = property.getValue(codePoint);
1688+
ArrayList<String> values = new ArrayList<>();
1689+
property.getValues(codePoint).forEach(values::add);
16881690
PropertyAssignment lastAssignment =
16891691
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)) {
1692+
if (lastAssignment == null || (!values.equals(lastAssignment.values))) {
16931693
PropertyAssignment assignment = new PropertyAssignment();
16941694
assignment.first = version;
16951695
assignment.last = version;
1696-
assignment.value = value;
1696+
assignment.values = values;
16971697
history.add(assignment);
16981698
} else {
16991699
lastAssignment.last = version;
@@ -1704,7 +1704,8 @@ class PropertyAssignment {
17041704
var current = new PropertyAssignment();
17051705
current.first = Settings.LAST_VERSION_INFO;
17061706
current.last = Settings.LAST_VERSION_INFO;
1707-
current.value = getFactory().getProperty(propName).getValue(codePoint);
1707+
current.values = new ArrayList<>();
1708+
getFactory().getProperty(propName).getValues(codePoint).forEach(current.values::add);
17081709
history.add(current);
17091710
}
17101711
out.append(
@@ -1734,29 +1735,28 @@ class PropertyAssignment {
17341735
boolean isNew = assignment.first == Settings.LATEST_VERSION_INFO;
17351736
String versionRange =
17361737
(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-
? ""
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 ? "" : "</a>")
1758-
+ "</td>");
1759-
}
1738+
String htmlValue =
1739+
assignment.values.stream()
1740+
.map(v -> v == null ? "<i>null</i>" : toHTML.transliterate(v))
1741+
.collect(Collectors.joining("<wbr>|"));
1742+
out.append(
1743+
"<td"
1744+
+ defaultClass
1745+
+ ">"
1746+
+ (isMultivalued || htmlValue.contains("<")
1747+
? "<span" + (isNew ? " class='changed'" : "") + ">"
1748+
: ("<a target='u' "
1749+
+ (isNew ? "class='changed' " : "")
1750+
+ "href='list-unicodeset.jsp?a=[:"
1751+
+ (isCurrent ? "" : "U" + last + ":")
1752+
+ propName
1753+
+ "="
1754+
+ htmlValue
1755+
+ ":]'>"))
1756+
+ versionRange
1757+
+ htmlValue
1758+
+ (isMultivalued || htmlValue.contains("<") ? "</span>" : "</a>")
1759+
+ "</td>");
17601760
}
17611761
out.append("</tr>");
17621762
}

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)