@Test public void nfkcSafeMaker_givenNormalizableToken_encodesAsExpected() { String input = "StandaardGeluidsruimteDagInDb_a_M²"; String expected = "StandaardGeluidsruimteDagInDb_a_M2"; String actual = nfkcSafeMaker.apply(input); assertEquals(expected, actual); }
@Override public String apply(String s) { StringBuilder result = new StringBuilder(); s = Normalizer.normalize(s, normalizationForm); s.codePoints().flatMap(c -> { if ( Character.isAlphabetic(c) || Character.isDigit(c) || c == '-' || c == '.' || c == '_' || c == '~' || ranges.stream().anyMatch(r -> r.includes(c)) ) return IntStream.of(c); String hex = Integer.toHexString(c); hex = upperCaseHex ? hex.toUpperCase() : hex; return ("%" + hex).codePoints(); }) .forEach(c -> result.append((char) c)); return result.toString(); }
IriSafeMaker implements Function<String, String> { @Override public String apply(String s) { StringBuilder result = new StringBuilder(); s = Normalizer.normalize(s, normalizationForm); s.codePoints().flatMap(c -> { if ( Character.isAlphabetic(c) || Character.isDigit(c) || c == '-' || c == '.' || c == '_' || c == '~' || ranges.stream().anyMatch(r -> r.includes(c)) ) return IntStream.of(c); String hex = Integer.toHexString(c); hex = upperCaseHex ? hex.toUpperCase() : hex; return ("%" + hex).codePoints(); }) .forEach(c -> result.append((char) c)); return result.toString(); } }
IriSafeMaker implements Function<String, String> { @Override public String apply(String s) { StringBuilder result = new StringBuilder(); s = Normalizer.normalize(s, normalizationForm); s.codePoints().flatMap(c -> { if ( Character.isAlphabetic(c) || Character.isDigit(c) || c == '-' || c == '.' || c == '_' || c == '~' || ranges.stream().anyMatch(r -> r.includes(c)) ) return IntStream.of(c); String hex = Integer.toHexString(c); hex = upperCaseHex ? hex.toUpperCase() : hex; return ("%" + hex).codePoints(); }) .forEach(c -> result.append((char) c)); return result.toString(); } IriSafeMaker(List<Range> ranges, Form normalizationForm, boolean upperCaseHex); }
IriSafeMaker implements Function<String, String> { @Override public String apply(String s) { StringBuilder result = new StringBuilder(); s = Normalizer.normalize(s, normalizationForm); s.codePoints().flatMap(c -> { if ( Character.isAlphabetic(c) || Character.isDigit(c) || c == '-' || c == '.' || c == '_' || c == '~' || ranges.stream().anyMatch(r -> r.includes(c)) ) return IntStream.of(c); String hex = Integer.toHexString(c); hex = upperCaseHex ? hex.toUpperCase() : hex; return ("%" + hex).codePoints(); }) .forEach(c -> result.append((char) c)); return result.toString(); } IriSafeMaker(List<Range> ranges, Form normalizationForm, boolean upperCaseHex); static String makeSafe(String input, Form normalizationForm, boolean upperCaseHex); static IriSafeMaker create(Form normalizationForm, boolean upperCaseHex); static IriSafeMaker create(); @Override String apply(String s); }
IriSafeMaker implements Function<String, String> { @Override public String apply(String s) { StringBuilder result = new StringBuilder(); s = Normalizer.normalize(s, normalizationForm); s.codePoints().flatMap(c -> { if ( Character.isAlphabetic(c) || Character.isDigit(c) || c == '-' || c == '.' || c == '_' || c == '~' || ranges.stream().anyMatch(r -> r.includes(c)) ) return IntStream.of(c); String hex = Integer.toHexString(c); hex = upperCaseHex ? hex.toUpperCase() : hex; return ("%" + hex).codePoints(); }) .forEach(c -> result.append((char) c)); return result.toString(); } IriSafeMaker(List<Range> ranges, Form normalizationForm, boolean upperCaseHex); static String makeSafe(String input, Form normalizationForm, boolean upperCaseHex); static IriSafeMaker create(Form normalizationForm, boolean upperCaseHex); static IriSafeMaker create(); @Override String apply(String s);  }