KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > pluto > om > common > PreferenceUtil


1 /*
2  * Copyright 2004,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.portal.pluto.om.common;
17
18 import java.util.Collection JavaDoc;
19 import java.util.HashMap JavaDoc;
20 import java.util.Iterator JavaDoc;
21
22 import org.apache.pluto.om.common.Preference;
23
24 /**
25  *
26  *
27  * @author <a HREF="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
28  *
29  * @version CVS $Id: PreferenceUtil.java 123407 2004-12-27 13:51:59Z cziegeler $
30  */

31 public class PreferenceUtil {
32
33     /**
34      * Returns the preferences as map with name as the preference's name and value as
35      * the preference object itself.
36      *
37      * @param preferences the preferences to be converted
38      * @return the preferences as map
39      */

40     static public HashMap JavaDoc createPreferenceMap(Collection JavaDoc preferences) {
41         HashMap JavaDoc returnValue = new HashMap JavaDoc();
42         Iterator JavaDoc iterator = preferences.iterator();
43         while (iterator.hasNext()) {
44             Preference preference = (Preference)iterator.next();
45             returnValue.put(preference.getName(), preference.getValues());
46         }
47         return returnValue;
48     }
49
50 }
51
Popular Tags