1
2
3
4
5
6
7
8
9
10
11 package org.csveed.bean.conversion;
12
13 import java.util.regex.Matcher;
14 import java.util.regex.Pattern;
15
16
17
18
19 public class Coordinate {
20
21
22 private final Integer x;
23
24
25 private final Integer y;
26
27
28
29
30
31
32
33
34
35 public Coordinate(Integer x, Integer y) {
36 this.x = x;
37 this.y = y;
38 }
39
40
41
42
43
44
45 public Integer getX() {
46 return x;
47 }
48
49
50
51
52
53
54 public Integer getY() {
55 return y;
56 }
57
58
59
60
61
62
63
64
65
66 public static Coordinate fromString(String coordinateText) {
67 Pattern r = Pattern.compile("(\\d+)/(\\d+)");
68 Matcher m = r.matcher(coordinateText);
69 if (m.find()) {
70 return new Coordinate(Integer.parseInt(m.group(1)), Integer.parseInt(m.group(2)));
71 }
72 return null;
73 }
74
75 @Override
76 public String toString() {
77 return x + "/" + y;
78 }
79
80 }