(String name, boolean all)
| 232 | } |
| 233 | |
| 234 | private static Record [] |
| 235 | lookupHostName(String name, boolean all) throws UnknownHostException { |
| 236 | try { |
| 237 | Lookup lookup = new Lookup(name, Type.A); |
| 238 | Record [] a = lookup.run(); |
| 239 | if (a == null) { |
| 240 | if (lookup.getResult() == Lookup.TYPE_NOT_FOUND) { |
| 241 | Record [] aaaa = new Lookup(name, Type.AAAA).run(); |
| 242 | if (aaaa != null) |
| 243 | return aaaa; |
| 244 | } |
| 245 | throw new UnknownHostException("unknown host"); |
| 246 | } |
| 247 | if (! all) |
| 248 | return a; |
| 249 | Record [] aaaa = new Lookup(name, Type.AAAA).run(); |
| 250 | if (aaaa == null) |
| 251 | return a; |
| 252 | Record [] merged = new Record[a.length + aaaa.length]; |
| 253 | System.arraycopy(a, 0, merged, 0, a.length); |
| 254 | System.arraycopy(aaaa, 0, merged, a.length, aaaa.length); |
| 255 | return merged; |
| 256 | } |
| 257 | catch (TextParseException e) { |
| 258 | throw new UnknownHostException("invalid name"); |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | private static InetAddress |
| 263 | addrFromRecord(String name, Record r) throws UnknownHostException { |
no test coverage detected