- public static byte[] bytesForString(final String ipv6Address) {
- /*
- * Do not modify this routine to take direct strings input!!!
- * Key checks have been removed based on the assumption that
- * the input is validated via regexps in Ipv6Prefix()
- */
-
- String [] address = (ipv6Address).split("%");
-
- int colonp;
- char ch;
- boolean saw_xdigit;
-
- /* Isn't it fun - the above variable names are the same in BSD and Sun sources */
-
- int val;
-
- char[] src = address[0].toCharArray();
-
- byte[] dst = new byte[INADDR6SZ];
-
- int src_length = src.length;
-
- colonp = -1;
- int i = 0, j = 0;
+ public static @Nonnull byte[] bytesForString(final @Nonnull String addrStr) {
+ final int percentPos = addrStr.indexOf('%');
+ final int addrStrLen = percentPos == -1 ? addrStr.length() : percentPos;