Esempio n. 1
0
 public static synchronized void saveProperties(MailboxBuffer mb) {
   MailboxURL url = mb.getUrl();
   if (url == null) {
     Debug.bug();
     return;
   }
   String name = url.getCanonicalName();
   if (name == null) {
     Debug.bug();
     return;
   }
   if (name.length() == 0) {
     Debug.bug();
     return;
   }
   PropertyList properties = mb.getProperties();
   if (properties == null || properties.size() == 0) {
     Log.debug("MailboxProperties.saveProperties no properties set");
     return;
   }
   if (list == null) initialize();
   Entry newEntry = new Entry(name, properties);
   final int limit = list.size();
   for (int i = 0; i < limit; i++) {
     Entry entry = list.get(i);
     if (entry.name.equals(name)) {
       if (i == 0) {
         list.set(0, newEntry);
         save();
         return;
       }
       list.remove(i);
       break;
     }
   }
   // Add new entry.
   list.add(0, newEntry);
   save();
 }
Esempio n. 2
0
 String toXml() {
   StringBuilder sb = new StringBuilder("  <mailbox name=\"");
   sb.append(name);
   sb.append("\"");
   sb.append(" when=\"");
   sb.append(String.valueOf(when));
   sb.append("\"");
   sb.append(">");
   sb.append(lineSeparator);
   if (properties != null) {
     Iterator<Property> it = properties.keyIterator();
     if (it != null) {
       while (it.hasNext()) {
         Property property = it.next();
         Object value = properties.getProperty(property);
         if (value != null) {
           sb.append(propertyToXml(property.getDisplayName(), value.toString()));
         }
       }
     }
   }
   sb.append("  </mailbox>");
   return sb.toString();
 }