Читаем 2d-адреса через разделитель @param list2d @return
(String list2d)
| 387 | * @return |
| 388 | */ |
| 389 | public static List<Ftn2D> read2D(String list2d) { |
| 390 | List<Ftn2D> ret = new ArrayList<>(); |
| 391 | |
| 392 | if (list2d == null || list2d.length() == 0 |
| 393 | || list2d.trim().length() == 0) { |
| 394 | return ret; |
| 395 | } |
| 396 | |
| 397 | String lastNet = null; |
| 398 | |
| 399 | for (String l2d : list2d.split(" ")) { |
| 400 | String[] part = l2d.split("/"); |
| 401 | |
| 402 | String net; |
| 403 | String node; |
| 404 | |
| 405 | switch (part.length) { |
| 406 | case 2: |
| 407 | // 5020/841 |
| 408 | net = part[0]; |
| 409 | node = part[1]; |
| 410 | break; |
| 411 | case 1: |
| 412 | // 841 |
| 413 | net = lastNet; |
| 414 | node = part[0]; |
| 415 | break; |
| 416 | default: |
| 417 | throw new IllegalArgumentException(MessageFormat.format( |
| 418 | "fail parse 2d address [{0}] in list [{1}]", l2d, |
| 419 | list2d)); |
| 420 | } |
| 421 | |
| 422 | try { |
| 423 | ret.add(Ftn2D.fromString(net, node)); |
| 424 | lastNet = net; |
| 425 | } catch (IllegalArgumentException e) { |
| 426 | lastNet = null; |
| 427 | logger.l1( |
| 428 | MessageFormat |
| 429 | .format("fail parse 2d address [{0}] in list [{1}] - illegal arguments", |
| 430 | l2d, list2d), e); |
| 431 | } catch (RuntimeException e2) { |
| 432 | lastNet = null; |
| 433 | logger.l1( |
| 434 | MessageFormat |
| 435 | .format("fail parse 2d address [{0}] in list [{1}] - unexpected error", |
| 436 | l2d, list2d), e2); |
| 437 | } |
| 438 | } |
| 439 | return ret; |
| 440 | } |
| 441 | |
| 442 | /** |
| 443 | * Читаем 4d-адреса через разделитель |