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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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 }