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 sources.
8    * It's just a helper class.
9    */
10  
11  public class Sources extends Hashtable {
12  
13    /***
14     * Construct a Sources object
15     *
16     */
17    public Sources() {
18    }
19    /***
20     * Add a source to the list
21     *
22     * @param	src
23     */
24    public void add(Source src){
25      if(get(src.getName()) != null){
26        throw new IllegalArgumentException(
27          I18n.getInstance().format(
28            "error.config.source.already-bound",new Object[]{src.getName()}
29          )
30        );
31      }
32      put(src.getName(),src);
33    }
34    /***
35     * Get a source
36     *
37     * @param	name the name of the source to get
38     */
39    public Source get(String name){
40      return (Source)super.get(name);
41    }
42  
43  
44    /*
45    public void validate() throws OpenSyncException {
46      for (Enumeration e = keys(); e.hasMoreElements();) {
47        Source aSource = (Source)(get(e.nextElement()));
48        aSource.getConnector().validate();
49      }
50    }
51    */
52  
53    /*
54    public long lastModified() throws OpenSyncException, IOException {
55      long lastModified = -1;
56      for (Enumeration e = keys(); e.hasMoreElements();) {
57        Source aSource = (Source)(get(e.nextElement()));
58        lastModified = Math.max(lastModified, aSource.lastModified());
59      }
60      System.out.println("Sources "+lastModified);
61      return lastModified;
62    }*/
63  
64    /***
65     * Use for debug only
66     *
67     */
68    public String toString(){
69      StringBuffer buffer = new StringBuffer();
70      buffer.append("Sources{\n");
71      Iterator iterator = values().iterator();
72      while(iterator.hasNext()){
73        buffer.append(iterator.next().toString());
74      }
75      buffer.append("}\n");
76      return buffer.toString();
77    }
78  }