View Javadoc

1   package zeus.concepts.xmlobject.acc;
2   
3   import java.util.List;
4   import java.util.Vector;
5   
6   import org.w3c.dom.Node;
7   import org.w3c.dom.NodeList;
8   
9   public class Contacts {
10  
11      private List contacts;
12  
13      public Contacts() {
14          ;
15      }
16  
17      public void setContacts(List contacts) {
18          this.contacts = contacts;
19      }
20  
21      public List getContacts() {
22          if(contacts == null) {
23              setContacts(new Vector());
24          }
25          return contacts;
26      }
27  
28      public String toString() {
29          return toString("");
30      }
31  
32      public String toString(String indent) {
33          String output = indent = "<contacts>\n";
34  
35          for(int index = 0 ; index < getContacts().size() ; index++ ) {
36              Contact contact = (Contact)getContacts().get(index);
37              output += contact.toString(indent + "  ");
38          }
39  
40          output += indent + "</contacts>\n";
41          return output;
42      }
43  
44      public void translate(Node node) {
45          NodeList children = node.getChildNodes();
46          for(int index = 0 ; index < children.getLength() ; index++ ) {
47              Node child = children.item(index);
48              if(child.getNodeName().equals("contact")) {
49                  Contact contact = new Contact();
50                  contact.translate(child);
51                  getContacts().add(contact);
52              }
53              else {
54                  ;//Unknown node name
55              }
56          }
57      }
58      
59  }