mcommons / mcommons4j

Java Client Library for the Mobile Commons API

 
benstein (author)
Thu Aug 20 12:05:19 -0700 2009
commit  1227684624f7a84a9afcfe83b1cc9d686a33e9a5
tree    492a55a32e6a5335e6cf48994bd08c970ee3b75d
parent  6028d7c58b54bc782633c6d26cb3e37350064d9e
mcommons4j / Group.java
100644 52 lines (46 sloc) 1.269 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
import org.apache.commons.lang.builder.ToStringBuilder;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
 
public class Group {
  private String name;
  private String id;
  private Integer size;
  enum GroupType { FILTERED_GROUP, UPLOADED_GROUP } ;
  private GroupType type;
  
  public Group(Node node) throws Exception{
    Element groupElem = (Element) node;
    id = groupElem.getAttribute("id");
    
    String tp = groupElem.getAttribute("type");
    if (tp.equals("UploadedGroup")){
      type = GroupType.UPLOADED_GROUP;
    }
    else if (tp.equals("FilteredGroup")){
      type = GroupType.FILTERED_GROUP;
    }
    
    name = MobileCommons.getValueFromChildNodeByNodeName(groupElem, "name");
    size = Integer.parseInt(MobileCommons.getValueFromChildNodeByNodeName(groupElem, "size"));
  }
  
  
  public String getName(){
    return name;
  }
  public String getId(){
    return id;
  }
  public Integer getSize(){
    return size;
  }
  public GroupType getType(){
    return type;
  }
  public String getTypeString(){
    return type.toString();
  }
  public String toString() {
   return new ToStringBuilder(this).
   append("name", name).
   append("id", id).
   append("size", size).
   append("type", type.toString()).
   toString();
  }
}