/** * Changes problematic ip6 uris in StyleSheet per indexes before DOM object is serialized. * Indexes follow pattern "ipv6i0f", "ipv6i1f", ..., "ipv6iNf". * * @param styleSheet StyleSheet object representing a CSS DOM to extract ip6 explicit uris * @param ip6Uris List of Strings where ip6 uris will be stored */ public static void saveIp6Uris(CssTree.StyleSheet styleSheet, List<String> ip6Uris) { if (styleSheet == null || ip6Uris == null) { // This case should not happen return; } List<CssTree.UriLiteral> uris = descendants(styleSheet, CssTree.UriLiteral.class); for (CssTree.UriLiteral uri : uris) { String sUri = uri.getValue(); String ip6 = extractIp6(sUri); if (ip6 != null) { int count = ip6Uris.indexOf(ip6); if (count == -1) { ip6Uris.add(ip6); count = ip6Uris.size() - 1; } String index = "ipv6i" + count + "f"; uri.setValue(sUri.replace(ip6, index)); } } }