View Javadoc

1   package org.opensync.engine.server;
2   
3   import java.util.*;
4   import org.opensync.engine.util.I18n;
5   
6   /***
7    * This class represents a list of synchronization.
8    * It's just a helper class.
9    */
10  
11  public class Synchronizations extends Hashtable {
12  
13    /***
14     * Construct a Synchronizations object
15     *
16     */
17    public Synchronizations() {
18    }
19    /***
20     * Add a synchronization to the list
21     *
22     * @param	sync the synchornization to add
23     */
24    public void add(Synchronization sync){
25      if(get(sync.getName()) != null){
26        throw new IllegalArgumentException(
27          I18n.getInstance().format(
28            "error.config.synchronization.already-bound",new Object[]{sync.getName()}
29          )
30        );
31      }
32      put(sync.getName(),sync);
33    }
34    /***
35     * Get a synchronization
36     *
37     * @param	name the name of the synchronization to get
38     *
39     */
40    public Synchronization get(String name){
41      return (Synchronization)super.get(name);
42    }
43  
44    /*
45    public long lastModified() throws OpenSyncException, IOException {
46      long lastModified = -1;
47      for (Enumeration e = keys(); e.hasMoreElements();) {
48        Synchronization aSync = (Synchronization)(get(e.nextElement()));
49        lastModified = Math.max(lastModified, aSync.lastModified());
50      }
51      System.out.println("Sources "+lastModified);
52      return lastModified;
53    }
54    */
55  
56    /***
57     * Use for debug only
58     *
59     */
60    public String toString(){
61      StringBuffer buffer = new StringBuffer();
62      buffer.append("Synchronizations{\n");
63      Iterator iterator = values().iterator();
64      while(iterator.hasNext()){
65        buffer.append(iterator.next().toString());
66      }
67      buffer.append("}\n");
68      return buffer.toString();
69    }
70  }