View Javadoc

1   /*
2    * Copyright 2007 Hippo
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" 
12   * BASIS, 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 nl.hippo.portal.cms;
17  
18  import java.util.Collection;
19  import java.util.Collections;
20  import java.util.Iterator;
21  import java.util.LinkedHashMap;
22  import java.util.Map;
23  
24  /***
25   * @version $Id: CMSMetaDataImpl.java 6122 2007-04-18 14:34:48Z pduin $
26   *
27   */
28  public class CMSMetaDataImpl implements CMSMetaData {
29  
30      private String name;
31      private Map data;
32      private Map itemMap;
33  
34      public CMSMetaDataImpl(String name, Map itemMap) {
35          this.name = name;
36          this.itemMap = itemMap;
37          this.data = new LinkedHashMap();
38          for (Iterator iter = itemMap.keySet().iterator(); iter.hasNext();) {
39              String itemId = (String) iter.next();
40              CMSMetaDataItem item = (CMSMetaDataItem) itemMap.get(itemId);
41              data.put(itemId, item.getValue());
42          }
43      }
44  
45      /* (non-Javadoc)
46       * @see nl.hippo.portal.cms.CMSMetaData#getKeys()
47       */
48      public Iterator getKeys() {
49          return data.keySet().iterator();
50      }
51  
52      /* (non-Javadoc)
53       * @see nl.hippo.portal.cms.CMSMetaData#getName()
54       */
55      public String getName() {
56          return name;
57      }
58  
59      public Map getData() {
60          return data;
61      }
62  
63      public Map getAttributes(String key) {
64          CMSMetaDataItem value = getValue(key);
65          return value != null ? value.getAttributes() : Collections.EMPTY_MAP;
66      }
67  
68      /* (non-Javadoc)
69       * @see nl.hippo.portal.cms.CMSMetaData#getValue(java.lang.String)
70       */
71      public CMSMetaDataItem getValue(String key) {
72          CMSMetaDataItem value = (CMSMetaDataItem) itemMap.get(key);
73          return value;
74      }
75  
76      /* (non-Javadoc)
77       * @see nl.hippo.portal.cms.CMSMetaData#size()
78       */
79      public int size() {
80          return data.size();
81      }
82  
83      /* (non-Javadoc)
84       * @see nl.hippo.portal.cms.CMSMetaData#values()
85       */
86      public Collection values() {
87          return data.values();
88      }
89  }