/** * Verifies a sequence of codepoints using the specified profile */ public static void verify(char[] s, Profile profile) throws InvalidCharacterException { if (s == null) return; verify(CodepointIterator.forCharArray(s), profile); }
/** * Verifies a sequence of codepoints using the specified profile */ public static void verify(String s, Profile profile) throws InvalidCharacterException { if (s == null) return; verify(CodepointIterator.forCharSequence(s), profile); }
private void parseAuthority() { if (authority != null) { Matcher auth = AUTHORITYPATTERN.matcher(authority); if (auth.find()) { userinfo = auth.group(1); host = auth.group(2); if (auth.group(3) != null) port = Integer.parseInt(auth.group(3)); else port = -1; } try { CharUtils.verify(userinfo, Profile.IUSERINFO); CharUtils.verify(host, Profile.IHOST); } catch (InvalidCharacterException e) { throw new IRISyntaxException(e); } } }
private static void verify(String[] tags) { if (tags.length == 0) throw new InvalidLangTagSyntax(); String primary = tags[0]; try { CharUtils.verify(primary, Profile.ALPHA); } catch (InvalidCharacterException e) { throw new InvalidLangTagSyntax(); } for (int n = 1; n < tags.length; n++) { try { CharUtils.verify(tags[n], Profile.ALPHANUM); } catch (InvalidCharacterException e) { throw new InvalidLangTagSyntax(); } } }
private void parse(String iri) { try { SchemeRegistry reg = SchemeRegistry.getInstance(); Matcher irim = IRIPATTERN.matcher(iri); if (irim.find()) { scheme = irim.group(1); _scheme = reg.getScheme(scheme); authority = irim.group(2); path = irim.group(3); query = irim.group(4); fragment = irim.group(5); parseAuthority(); try { CharUtils.verify(scheme, Profile.SCHEME); CharUtils.verify(path, Profile.IPATH); CharUtils.verify(query, Profile.IQUERY); CharUtils.verify(fragment, Profile.IFRAGMENT); } catch (InvalidCharacterException e) { throw new IRISyntaxException(e); } } else { throw new IRISyntaxException("Invalid Syntax"); } } catch (IRISyntaxException e) { throw e; } catch (Exception e) { throw new IRISyntaxException(e); } }
public static String prep(String s) { NameprepCodepointIterator r = null; try { StringBuilder buf = new StringBuilder(); CodepointIterator ci = CodepointIterator.forCharSequence(s); r = new NameprepCodepointIterator(ci); while (r.hasNext()) { Codepoint cp = r.next(); int i = cp != null ? cp.getValue() : -1; if (i != -1) { CharUtils.append(buf, cp); } } String n = Normalizer.normalize(buf.toString(), Normalizer.Form.KC).toString(); CharUtils.verify(CodepointIterator.forCharSequence(n), new Filter() { public boolean accept(int c) { return isProhibited(c); } }); return n; } catch (Throwable e) { return null; } }