summaryrefslogtreecommitdiff
path: root/src/com/google/wireless/gdata/contacts/data/ContactEntry.java
blob: 716a5fed3285c5965b5eefd5bc8f01aa97f0d536 (plain)
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
// Copyright 2007 The Android Open Source Project

package com.google.wireless.gdata.contacts.data;

import com.google.wireless.gdata.data.Entry;
import com.google.wireless.gdata.data.ExtendedProperty;
import com.google.wireless.gdata.data.StringUtils;
import com.google.wireless.gdata.parser.ParseException;

import java.util.Vector;
import java.util.Enumeration;

/**
 * Entry containing information about a contact.
 */
public class ContactEntry extends Entry {
  private String linkPhotoHref;
  private String linkEditPhotoHref;
  private String linkPhotoType;
  private String linkEditPhotoType;
  private final Vector emailAddresses = new Vector();
  private final Vector imAddresses = new Vector();
  private final Vector phoneNumbers = new Vector();
  private final Vector postalAddresses = new Vector();
  private final Vector organizations = new Vector();
  private final Vector extendedProperties = new Vector();
  private final Vector groups = new Vector();
  private String yomiName;

  public ContactEntry() {
    super();
  }

  public void setLinkEditPhoto(String href, String type) {
    this.linkEditPhotoHref = href;
    this.linkEditPhotoType = type;
  }

  public String getLinkEditPhotoHref() {
    return linkEditPhotoHref;
  }

  public String getLinkEditPhotoType() {
    return linkEditPhotoType;
  }

  public void setLinkPhoto(String href, String type) {
    this.linkPhotoHref = href;
    this.linkPhotoType = type;
  }

  public String getLinkPhotoHref() {
    return linkPhotoHref;
  }

  public String getLinkPhotoType() {
    return linkPhotoType;
  }

  public void addEmailAddress(EmailAddress emailAddress) {
    emailAddresses.addElement(emailAddress);
  }

  public Vector getEmailAddresses() {
    return emailAddresses;
  }

  public void addImAddress(ImAddress imAddress) {
    imAddresses.addElement(imAddress);
  }

  public Vector getImAddresses() {
    return imAddresses;
  }

  public void addPostalAddress(PostalAddress postalAddress) {
    postalAddresses.addElement(postalAddress);
  }

  public Vector getPostalAddresses() {
    return postalAddresses;
  }

  public void addPhoneNumber(PhoneNumber phoneNumber) {
    phoneNumbers.addElement(phoneNumber);
  }

  public Vector getPhoneNumbers() {
    return phoneNumbers;
  }

  public void addOrganization(Organization organization) {
    organizations.addElement(organization);
  }

  public Vector getExtendedProperties() {
    return extendedProperties;
  }

  public void addExtendedProperty(ExtendedProperty extendedProperty) {
    extendedProperties.addElement(extendedProperty);
  }

  public Vector getGroups() {
    return groups;
  }

  public void addGroup(GroupMembershipInfo group) {
    groups.addElement(group);
  }

  public Vector getOrganizations() {
    return organizations;
  }

  public void setYomiName(String yomiName) {
    this.yomiName = yomiName;
  }

  public String getYomiName() {
    return yomiName;
  }

  /*
  * (non-Javadoc)
  * @see com.google.wireless.gdata.data.Entry#clear()
  */
  public void clear() {
    super.clear();
    linkEditPhotoHref = null;
    linkEditPhotoType = null;
    linkPhotoHref = null;
    linkPhotoType = null;
    emailAddresses.removeAllElements();
    imAddresses.removeAllElements();
    phoneNumbers.removeAllElements();
    postalAddresses.removeAllElements();
    organizations.removeAllElements();
    extendedProperties.removeAllElements();
    groups.removeAllElements();
    yomiName = null;
  }

  protected void toString(StringBuffer sb) {
    super.toString(sb);
    sb.append("\n");
    sb.append("ContactEntry:");
    if (!StringUtils.isEmpty(linkPhotoHref)) {
      sb.append(" linkPhotoHref:").append(linkPhotoHref).append("\n");
    }
    if (!StringUtils.isEmpty(linkPhotoType)) {
      sb.append(" linkPhotoType:").append(linkPhotoType).append("\n");
    }
    if (!StringUtils.isEmpty(linkEditPhotoHref)) {
      sb.append(" linkEditPhotoHref:").append(linkEditPhotoHref).append("\n");
    }
    if (!StringUtils.isEmpty(linkEditPhotoType)) {
      sb.append(" linkEditPhotoType:").append(linkEditPhotoType).append("\n");
    }
    for (Enumeration iter = emailAddresses.elements();
        iter.hasMoreElements(); ) {
      sb.append("  ");
      ((EmailAddress) iter.nextElement()).toString(sb);
      sb.append("\n");
    }
    for (Enumeration iter = imAddresses.elements();
        iter.hasMoreElements(); ) {
      sb.append("  ");
      ((ImAddress) iter.nextElement()).toString(sb);
      sb.append("\n");
    }
    for (Enumeration iter = postalAddresses.elements();
        iter.hasMoreElements(); ) {
      sb.append("  ");
      ((PostalAddress) iter.nextElement()).toString(sb);
      sb.append("\n");
    }
    for (Enumeration iter = phoneNumbers.elements();
        iter.hasMoreElements(); ) {
      sb.append("  ");
      ((PhoneNumber) iter.nextElement()).toString(sb);
      sb.append("\n");
    }
    for (Enumeration iter = organizations.elements();
        iter.hasMoreElements(); ) {
      sb.append("  ");
      ((Organization) iter.nextElement()).toString(sb);
      sb.append("\n");
    }
    for (Enumeration iter = extendedProperties.elements();
        iter.hasMoreElements(); ) {
      sb.append("  ");
      ((ExtendedProperty) iter.nextElement()).toString(sb);
      sb.append("\n");
    }
    for (Enumeration iter = groups.elements();
        iter.hasMoreElements(); ) {
      sb.append("  ");
      ((GroupMembershipInfo) iter.nextElement()).toString(sb);
      sb.append("\n");
    }
    if (!StringUtils.isEmpty(yomiName)) {
      sb.append(" yomiName:").append(yomiName).append("\n");
    }
  }

  public void validate() throws ParseException {
    super.validate();
    for (Enumeration iter = emailAddresses.elements(); iter.hasMoreElements(); ) {
      ((EmailAddress) iter.nextElement()).validate();
    }
    for (Enumeration iter = imAddresses.elements(); iter.hasMoreElements(); ) {
      ((ImAddress) iter.nextElement()).validate();
    }
    for (Enumeration iter = postalAddresses.elements(); iter.hasMoreElements(); ) {
      ((PostalAddress) iter.nextElement()).validate();
    }
    for (Enumeration iter = phoneNumbers.elements(); iter.hasMoreElements(); ) {
      ((PhoneNumber) iter.nextElement()).validate();
    }
    for (Enumeration iter = organizations.elements(); iter.hasMoreElements(); ) {
      ((Organization) iter.nextElement()).validate();
    }
    for (Enumeration iter = extendedProperties.elements(); iter.hasMoreElements(); ) {
      ((ExtendedProperty) iter.nextElement()).validate();
    }
    for (Enumeration iter = groups.elements(); iter.hasMoreElements(); ) {
      ((GroupMembershipInfo) iter.nextElement()).validate();
    }
  }
}