1 18 19 package sync4j.framework.core.dm.ddf; 20 21 import java.util.Iterator ; 22 import java.util.Map ; 23 import java.util.Set ; 24 25 import org.apache.commons.collections.map.ListOrderedMap; 26 27 34 public class DMAcc implements java.io.Serializable { 35 36 38 40 private Map dmAccounts; 41 42 43 44 46 public DMAcc() {} 47 48 54 public DMAcc(final DMAccount dmAccount, final String accountName) { 55 this.dmAccounts = new ListOrderedMap(); 56 this.dmAccounts.put(accountName, dmAccount); 57 } 58 59 60 62 67 public void addDMAccount(final DMAccount dmAccount, final String accountName) { 68 this.dmAccounts.put(accountName, dmAccount); 69 } 70 71 77 public DMAccount getDMAccount(final String accountName) { 78 return (DMAccount)this.dmAccounts.get(accountName); 79 } 80 81 82 88 public void renameDMAccount(String oldAccountName, String newAccountName) { 89 90 if (dmAccounts == null) { 91 return ; 93 } 94 95 Set keys = dmAccounts.keySet(); 100 Iterator itKeys = keys.iterator(); 101 String accountName = null; 102 Map newDmAccounts = new ListOrderedMap(); 103 while (itKeys.hasNext()) { 104 accountName = (String )itKeys.next(); 105 if (accountName.equalsIgnoreCase(oldAccountName)) { 106 newDmAccounts.put(newAccountName, dmAccounts.get(oldAccountName)); 107 } else { 108 newDmAccounts.put(accountName, dmAccounts.get(accountName)); 109 } 110 } 111 this.dmAccounts = newDmAccounts; 112 } 113 114 115 120 public Map getDMAccounts() { 121 return dmAccounts; 122 } 123 124 129 public void setDMAccounts(Map dmAccounts) { 130 this.dmAccounts = dmAccounts; 131 } 132 133 134 139 public int numberOfDMAccounts() { 140 return dmAccounts.size(); 141 } 142 143 144 } | Popular Tags |