1 20 21 package org.jivesoftware.smackx; 22 23 import java.util.*; 24 25 34 public class RemoteRosterEntry { 35 36 private String user; 37 private String name; 38 private List groupNames = new ArrayList(); 39 40 48 public RemoteRosterEntry(String user, String name, String [] groups) { 49 this.user = user; 50 this.name = name; 51 if (groups != null) { 52 groupNames = new ArrayList(Arrays.asList(groups)); 53 } 54 } 55 56 61 public String getUser() { 62 return user; 63 } 64 65 70 public String getName() { 71 return name; 72 } 73 74 80 public Iterator getGroupNames() { 81 synchronized (groupNames) { 82 return Collections.unmodifiableList(groupNames).iterator(); 83 } 84 } 85 86 92 public String [] getGroupArrayNames() { 93 synchronized (groupNames) { 94 return (String []) 95 (Collections 96 .unmodifiableList(groupNames) 97 .toArray(new String [groupNames.size()])); 98 } 99 } 100 101 public String toXML() { 102 StringBuffer buf = new StringBuffer (); 103 buf.append("<item jid=\"").append(user).append("\""); 104 if (name != null) { 105 buf.append(" name=\"").append(name).append("\""); 106 } 107 buf.append(">"); 108 synchronized (groupNames) { 109 for (int i = 0; i < groupNames.size(); i++) { 110 String groupName = (String ) groupNames.get(i); 111 buf.append("<group>").append(groupName).append("</group>"); 112 } 113 } 114 buf.append("</item>"); 115 return buf.toString(); 116 } 117 118 } 119 | Popular Tags |