001    package org.apache.myfaces.tobago.util;
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one or more
005     * contributor license agreements.  See the NOTICE file distributed with
006     * this work for additional information regarding copyright ownership.
007     * The ASF licenses this file to You under the Apache License, Version 2.0
008     * (the "License"); you may not use this file except in compliance with
009     * the License.  You may obtain a copy of the License at
010     *
011     *      http://www.apache.org/licenses/LICENSE-2.0
012     *
013     * Unless required by applicable law or agreed to in writing, software
014     * distributed under the License is distributed on an "AS IS" BASIS,
015     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016     * See the License for the specific language governing permissions and
017     * limitations under the License.
018     */
019    
020    import org.apache.myfaces.tobago.context.ResourceManagerUtil;
021    
022    import javax.faces.context.FacesContext;
023    import java.util.Map;
024    import java.util.Set;
025    import java.util.Collection;
026    
027    /*
028     * Created by IntelliJ IDEA.
029     * User: bommel
030     * Date: 20.04.2006
031     * Time: 19:31:21
032     */
033    public class BundleMapWrapper implements Map {
034    
035      private String basename;
036    
037      public BundleMapWrapper(String basename) {
038        this.basename = basename;
039      }
040    
041      public void clear() {
042        throw new UnsupportedOperationException();
043      }
044    
045      public boolean containsKey(Object key) {
046        if (null == key) {
047          return false;
048        }
049        String value = ResourceManagerUtil.getPropertyNotNull(
050            FacesContext.getCurrentInstance(), basename, key.toString());
051        return value != null;
052      }
053    
054      public boolean containsValue(Object value) {
055        throw new UnsupportedOperationException();
056      }
057    
058      public Set entrySet() {
059        throw new UnsupportedOperationException();
060      }
061    
062      public Object get(Object key) {
063        if (null == key) {
064          return null;
065        }
066        String value = ResourceManagerUtil.getPropertyNotNull(
067            FacesContext.getCurrentInstance(), basename, key.toString());
068        return value;
069      }
070    
071      public int hashCode() {
072        return basename.hashCode();
073      }
074    
075      public boolean isEmpty() {
076        throw new UnsupportedOperationException();
077      }
078    
079      public Set keySet() {
080        throw new UnsupportedOperationException();
081      }
082    
083      public Object put(Object k, Object v) {
084        throw new UnsupportedOperationException();
085      }
086    
087      public void putAll(Map t) {
088        throw new UnsupportedOperationException();
089      }
090    
091      public Object remove(Object k) {
092        throw new UnsupportedOperationException();
093      }
094    
095      public int size() {
096        throw new UnsupportedOperationException();
097      }
098    
099      public Collection values() {
100        throw new UnsupportedOperationException();
101      }
102    }
103