mcommons / mcommons4j

Java Client Library for the Mobile Commons API

This URL has Read+Write access

 
benstein (author)
Thu Aug 20 12:05:19 -0700 2009
commit  1227684624f7a84a9afcfe83b1cc9d686a33e9a5
tree    492a55a32e6a5335e6cf48994bd08c970ee3b75d
parent  6028d7c58b54bc782633c6d26cb3e37350064d9e
mcommons4j / CampaignSubscriber.java
100644 49 lines (36 sloc) 1.201 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
import java.text.DateFormat;
import java.text.SimpleDateFormat;
 
import org.apache.commons.lang.builder.ToStringBuilder;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
 
import java.util.Date;
 
public class CampaignSubscriber{
  private String id;
  private String phoneNumber;
  private Date activatedAt;
  
  public CampaignSubscriber(Node node) throws Exception{
    Element subElem = (Element) node;
    id = MobileCommons.getValueFromChildNodeByNodeName(subElem, "id");
    phoneNumber = MobileCommons.getValueFromChildNodeByNodeName(subElem, "phone_number");
    
    String dateString = MobileCommons.getValueFromChildNodeByNodeName(subElem, "activated_at");
    
    if (!dateString.equals("")){
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss zzz");
    activatedAt = df.parse(dateString);
    }
  }
  
  
  public String getId(){
    return id;
  }
  
  public String getPhoneNumber(){
    return phoneNumber;
  }
  
  public Date getActivatedAt(){
    return activatedAt;
  }
  
  
  
  public String toString() {
   return new ToStringBuilder(this).
   append("id", id).
   append("phoneNumber", phoneNumber).
   append("activatedAt", activatedAt).toString();
  }
}