KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > server > plugins > preferences > MergedPreferenceSet


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.server.plugins.preferences;
10
11 import java.util.Set JavaDoc;
12
13 import org.jboss.portal.common.value.Value;
14
15 /**
16  * Implements a preference set that use an merge strategy.
17  *
18  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
19  * @version $Revision: 1.2 $
20  */

21 public class MergedPreferenceSet
22    implements PreferenceSet
23 {
24
25    private final MergeStrategy strategy;
26    private final PreferenceSet[] sets;
27
28    public MergedPreferenceSet(PreferenceSet[] sets, MergeStrategy strategy)
29    {
30       this.sets = sets;
31       this.strategy = strategy;
32    }
33
34    public Preference getPreference(String JavaDoc key)
35    {
36       return strategy.getPreference(sets, key);
37    }
38
39    public Value getValue(String JavaDoc key)
40    {
41       Preference pref = getPreference(key);
42       if (pref != null)
43       {
44          return pref.getValue();
45       }
46       else
47       {
48          return null;
49       }
50    }
51
52    public boolean isReadOnly(String JavaDoc key)
53    {
54       return strategy.isReadOnly(sets, key);
55    }
56
57    public Set JavaDoc keySet()
58    {
59       return strategy.getKeySet(sets);
60    }
61
62    public void setReadOnly(String JavaDoc key, boolean readOnly)
63    {
64       throw new UnsupportedOperationException JavaDoc();
65    }
66
67    public void setValue(String JavaDoc key, Value value)
68    {
69       throw new UnsupportedOperationException JavaDoc();
70    }
71 }
72
Popular Tags