| 2089 | } |
| 2090 | |
| 2091 | public static long parseSubnet(CharSequence sequence) throws NumericException { |
| 2092 | int delim = Chars.indexOf(sequence, 0, '/'); |
| 2093 | if (delim == -1) { |
| 2094 | throw NumericException.instance().put("invalid subnet format, missing '/': ").put(sequence); |
| 2095 | } |
| 2096 | |
| 2097 | int netmaskBits = parseInt0(sequence, delim + 1, sequence.length()); |
| 2098 | return pack(parseSubnet0(sequence, 0, delim, netmaskBits), toNetMask(netmaskBits)); |
| 2099 | } |
| 2100 | |
| 2101 | // test whether the subnet matches the netmaskLength (according to postgres rules) |
| 2102 | // throws NumericException if sequence is not a valid subnet OR the subnet doesn't match the netmaskLength |