org.ajax4jsf.ajax.ResourceBundleMap Maven / Gradle / Ivy
/**
* Licensed under the Common Development and Distribution License,
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.sun.com/cddl/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package org.ajax4jsf.ajax;
import java.util.Collection;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.Set;
import org.ajax4jsf.framework.util.message.Messages;
/**
* Very limited Map decorator to ResourceBundle.
* @author shura
*
*/
public class ResourceBundleMap implements Map {
private ResourceBundle _bundle;
/**
* @param bundle
*/
public ResourceBundleMap(ResourceBundle bundle) {
super();
_bundle = bundle;
}
/* (non-Javadoc)
* @see java.util.Map#size()
*/
public int size() {
return 0;
}
/* (non-Javadoc)
* @see java.util.Map#isEmpty()
*/
public boolean isEmpty() {
return false;
}
/* (non-Javadoc)
* @see java.util.Map#containsKey(java.lang.Object)
*/
public boolean containsKey(Object key) {
try {
_bundle.getObject(key.toString());
return true;
} catch (MissingResourceException e) {
return false;
}
}
/* (non-Javadoc)
* @see java.util.Map#containsValue(java.lang.Object)
*/
public boolean containsValue(Object value) {
// TODO Auto-generated method stub
return false;
}
/* (non-Javadoc)
* @see java.util.Map#get(java.lang.Object)
*/
public Object get(Object key) {
try {
return _bundle.getObject(key.toString());
} catch (MissingResourceException e) {
return key;
}
}
/* (non-Javadoc)
* @see java.util.Map#put(java.lang.Object, java.lang.Object)
*/
public Object put(Object arg0, Object arg1) {
throw new UnsupportedOperationException(Messages.getMessage(Messages.BUNDLE_MAP_NO_PUT_VALUE));
}
/* (non-Javadoc)
* @see java.util.Map#remove(java.lang.Object)
*/
public Object remove(Object key) {
throw new UnsupportedOperationException(Messages.getMessage(Messages.BUNDLE_MAP_NO_REMOVE_VALUE));
}
/* (non-Javadoc)
* @see java.util.Map#putAll(java.util.Map)
*/
public void putAll(Map arg0) {
throw new UnsupportedOperationException(Messages.getMessage(Messages.BUNDLE_MAP_NO_PUT_VALUE));
}
/* (non-Javadoc)
* @see java.util.Map#clear()
*/
public void clear() {
throw new UnsupportedOperationException(Messages.getMessage(Messages.BUNDLE_MAP_NO_REMOVE_VALUE));
}
/* (non-Javadoc)
* @see java.util.Map#keySet()
*/
public Set keySet() {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see java.util.Map#values()
*/
public Collection values() {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see java.util.Map#entrySet()
*/
public Set entrySet() {
// TODO Auto-generated method stub
return null;
}
}