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