1 17 18 package org.apache.james.fetchmail; 19 20 import java.util.ArrayList ; 21 import java.util.List ; 22 23 import javax.mail.Session ; 24 import javax.mail.internet.ParseException ; 25 26 import org.apache.avalon.framework.configuration.ConfigurationException; 27 import org.apache.mailet.MailAddress; 28 29 37 class Account implements Comparable 38 { 39 42 private String fieldPassword; 43 44 47 private MailAddress fieldRecipient; 48 49 52 private String fieldUser; 53 54 57 private ParsedConfiguration fieldParsedConfiguration; 58 59 63 private List fieldDeferredRecipientNotFoundMessageIDs; 64 65 68 private int fieldSequenceNumber; 69 70 73 private boolean fieldIgnoreRecipientHeader; 74 75 78 79 private Session fieldSession; 80 83 private Account() 84 { 85 super(); 86 } 87 88 100 101 public Account( 102 int sequenceNumber, 103 ParsedConfiguration parsedConfiguration, 104 String user, 105 String password, 106 String recipient, 107 boolean ignoreRecipientHeader, 108 Session session) 109 throws ConfigurationException 110 { 111 this(); 112 setSequenceNumber(sequenceNumber); 113 setParsedConfiguration(parsedConfiguration); 114 setUser(user); 115 setPassword(password); 116 setRecipient(recipient); 117 setIgnoreRecipientHeader(ignoreRecipientHeader); 118 setSession(session); 119 } 120 121 125 public String getPassword() 126 { 127 return fieldPassword; 128 } 129 130 134 public MailAddress getRecipient() 135 { 136 return fieldRecipient; 137 } 138 139 143 public String getUser() 144 { 145 return fieldUser; 146 } 147 148 152 protected void setPassword(String password) 153 { 154 fieldPassword = password; 155 } 156 157 161 protected void setRecipient(MailAddress recipient) 162 { 163 fieldRecipient = recipient; 164 } 165 166 170 protected void setRecipient(String recipient) throws ConfigurationException 171 { 172 if (null == recipient) 173 { 174 fieldRecipient = null; 175 return; 176 } 177 178 try 179 { 180 setRecipient(new MailAddress(recipient)); 181 } 182 catch (ParseException pe) 183 { 184 throw new ConfigurationException( 185 "Invalid recipient address specified: " + recipient); 186 } 187 } 188 189 190 191 192 196 protected void setUser(String user) 197 { 198 fieldUser = user; 199 } 200 201 205 protected void setIgnoreRecipientHeader(boolean ignoreRecipientHeader) 206 { 207 fieldIgnoreRecipientHeader = ignoreRecipientHeader; 208 } 209 210 214 public boolean isIgnoreRecipientHeader() 215 { 216 return fieldIgnoreRecipientHeader; 217 } 218 219 223 public int getSequenceNumber() 224 { 225 return fieldSequenceNumber; 226 } 227 228 232 protected void setSequenceNumber(int sequenceNumber) 233 { 234 fieldSequenceNumber = sequenceNumber; 235 } 236 237 244 public int compareTo(Object o) 245 { 246 return getSequenceNumber() - ((Account) o).getSequenceNumber(); 247 } 248 249 253 public List getDeferredRecipientNotFoundMessageIDs() 254 { 255 List messageIDs = null; 256 if (null 257 == (messageIDs = getDeferredRecipientNotFoundMessageIDsBasic())) 258 { 259 updateDeferredRecipientNotFoundMessageIDs(); 260 return getDeferredRecipientNotFoundMessageIDs(); 261 } 262 return messageIDs; 263 } 264 265 269 private List getDeferredRecipientNotFoundMessageIDsBasic() 270 { 271 return fieldDeferredRecipientNotFoundMessageIDs; 272 } 273 274 278 protected List computeDeferredRecipientNotFoundMessageIDs() 279 { 280 return new ArrayList (16); 281 } 282 283 286 protected void updateDeferredRecipientNotFoundMessageIDs() 287 { 288 setDeferredRecipientNotFoundMessageIDs(computeDeferredRecipientNotFoundMessageIDs()); 289 } 290 291 295 protected void setDeferredRecipientNotFoundMessageIDs(List defferedRecipientNotFoundMessageIDs) 296 { 297 fieldDeferredRecipientNotFoundMessageIDs = 298 defferedRecipientNotFoundMessageIDs; 299 } 300 301 305 public ParsedConfiguration getParsedConfiguration() 306 { 307 return fieldParsedConfiguration; 308 } 309 310 314 protected void setParsedConfiguration(ParsedConfiguration parsedConfiguration) 315 { 316 fieldParsedConfiguration = parsedConfiguration; 317 } 318 319 323 public Session getSession() 324 { 325 return fieldSession; 326 } 327 328 332 protected void setSession(Session session) 333 { 334 fieldSession = session; 335 } 336 337 } 338
| Popular Tags
|