1 17 package org.alfresco.filesys.server.auth; 18 19 import java.util.Vector ; 20 21 24 public class UserAccountList 25 { 26 27 29 private Vector <UserAccount> m_users; 30 31 34 public UserAccountList() 35 { 36 m_users = new Vector <UserAccount>(); 37 } 38 39 44 public final void addUser(UserAccount user) 45 { 46 47 49 removeUser(user); 50 m_users.add(user); 51 } 52 53 59 public final UserAccount findUser(String user) 60 { 61 62 64 for (int i = 0; i < m_users.size(); i++) 65 { 66 UserAccount acc = m_users.get(i); 67 if (acc.getUserName().equalsIgnoreCase(user)) 68 return acc; 69 } 70 71 73 return null; 74 } 75 76 82 public final boolean hasUser(String user) 83 { 84 85 87 for (int i = 0; i < m_users.size(); i++) 88 { 89 UserAccount acc = m_users.get(i); 90 if (acc.getUserName().compareTo(user) == 0) 91 return true; 92 } 93 94 96 return false; 97 } 98 99 105 public final UserAccount getUserAt(int idx) 106 { 107 if (idx >= m_users.size()) 108 return null; 109 return m_users.get(idx); 110 } 111 112 117 public final int numberOfUsers() 118 { 119 return m_users.size(); 120 } 121 122 125 public final void removeAllUsers() 126 { 127 m_users.removeAllElements(); 128 } 129 130 135 public final void removeUser(UserAccount userAcc) 136 { 137 138 140 for (int i = 0; i < m_users.size(); i++) 141 { 142 UserAccount acc = m_users.get(i); 143 if (acc.getUserName().compareTo(userAcc.getUserName()) == 0) 144 { 145 m_users.remove(i); 146 return; 147 } 148 } 149 } 150 151 156 public final void removeUser(String user) 157 { 158 159 161 for (int i = 0; i < m_users.size(); i++) 162 { 163 UserAccount acc = m_users.get(i); 164 if (acc.getUserName().compareTo(user) == 0) 165 { 166 m_users.remove(i); 167 return; 168 } 169 } 170 } 171 172 177 public String toString() 178 { 179 StringBuffer str = new StringBuffer (); 180 181 str.append("["); 182 str.append(m_users.size()); 183 str.append(":"); 184 185 for (int i = 0; i < m_users.size(); i++) 186 { 187 UserAccount acc = m_users.get(i); 188 str.append(acc.getUserName()); 189 str.append(","); 190 } 191 str.append("]"); 192 193 return str.toString(); 194 } 195 } | Popular Tags |