-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProfile.java
More file actions
105 lines (94 loc) · 2.95 KB
/
Profile.java
File metadata and controls
105 lines (94 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import org.apache.commons.lang.builder.ToStringBuilder;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class Profile{
private String id;
private String firstName;
private String lastName;
private String phoneNumber;
private String email;
private Address address;
public Profile(Node node) throws Exception{
Element profileElem = (Element) node;
id = profileElem.getAttribute("id");
firstName = MobileCommons.getValueFromChildNodeByNodeName(profileElem, "first_name");
lastName = MobileCommons.getValueFromChildNodeByNodeName(profileElem, "last_name");
phoneNumber = MobileCommons.getValueFromChildNodeByNodeName(profileElem, "phone_number");
email = MobileCommons.getValueFromChildNodeByNodeName(profileElem, "email");
NodeList addressList = profileElem.getElementsByTagName("address");
Element addressElem = (Element) addressList.item(0);
address = new Address(addressElem);
}
public String getId(){
return id;
}
public String getFirstName(){
return firstName;
}
public String getLastName(){
return lastName;
}
public String getPhoneNumber(){
return phoneNumber;
}
public String getEmail(){
return email;
}
public Address getAddress(){
return address;
}
public class Address{
private String street1;
private String street2;
private String city;
private String state;
private String postalCode;
private String country;
public Address(Element elem) throws Exception{
street1 = MobileCommons.getValueFromChildNodeByNodeName(elem, "street1");
street2 = MobileCommons.getValueFromChildNodeByNodeName(elem, "street2");
city = MobileCommons.getValueFromChildNodeByNodeName(elem, "city");
state = MobileCommons.getValueFromChildNodeByNodeName(elem, "state");
postalCode = MobileCommons.getValueFromChildNodeByNodeName(elem,"postal_code");
country = MobileCommons.getValueFromChildNodeByNodeName(elem, "country");
}
public String getStreet1(){
return street1;
}
public String getStreet2(){
return street2;
}
public String getCity(){
return city;
}
public String getState(){
return state;
}
public String getPostalCode(){
return postalCode;
}
public String getCountry(){
return country;
}
public String toString() {
return new ToStringBuilder(this).
append("street1", street1).
append("street2", street2).
append("city", city).
append("state", state).
append("postalCode", postalCode).
append("country", country).toString();
}
}
public String toString() {
return new ToStringBuilder(this).
append("id", id).
append("firstName", firstName).
append("lastName", lastName).
append("phoneNumber", phoneNumber).
append("email", email).
append(address.toString()).
toString();
}
}