All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ajax4jsf.framework.skin.SkinBean Maven / Gradle / Ivy

Go to download

Ajax4jsf is an open source extension to the JavaServer Faces standard that adds AJAX capability to JSF applications without requiring the writing of any JavaScript.

The newest version!
/**
 * 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.framework.skin;

import java.nio.ByteBuffer;
import java.util.AbstractMap;
import java.util.Collections;
import java.util.Set;

import javax.faces.context.FacesContext;

/**
 * @author shura (latest modification by $Author: alexsmirnov $)
 * @version $Revision: 1.5 $ $Date: 2006/09/18 17:17:22 $
 *
 */
public class SkinBean extends AbstractMap implements Skin {

	/* (non-Javadoc)
	 * @see org.ajax4jsf.framework.skin.Skin#hashCode(javax.faces.context.FacesContext)
	 */
	public int hashCode(FacesContext context) {
		// TODO Auto-generated method stub
		return getSkin().hashCode(context);
	}
	
	
	

	/* (non-Javadoc)
	 * @see java.util.AbstractMap#entrySet()
	 */
	public Set entrySet() {
		// TODO Auto-generated method stub
		return Collections.EMPTY_SET;
	}

	/* (non-Javadoc)
	 * @see java.util.AbstractMap#containsKey(java.lang.Object)
	 */
	public boolean containsKey(Object key) {
		if(null == key) {
			return false;
		}
		return getSkin().containsProperty(key.toString());
	}

	/* (non-Javadoc)
	 * @see java.util.AbstractMap#get(java.lang.Object)
	 */
	public Object get(Object key) {
		if(null == key) {
			return null;
		}
		return getSkin().getParameter(FacesContext.getCurrentInstance(),key.toString());
	}

	private Skin getSkin() {
		FacesContext context = FacesContext.getCurrentInstance();
		return SkinFactory.getInstance().getSkin(context);
	}

	/* (non-Javadoc)
	 * @see java.util.AbstractMap#toString()
	 */
	public String toString() {
		return getSkin().toString();
	}

	/* (non-Javadoc)
	 * @see java.util.AbstractMap#isEmpty()
	 */
	public boolean isEmpty() {
		// TODO Auto-generated method stub
		return false;
	}

	/* (non-Javadoc)
	 * @see org.ajax4jsf.framework.skin.Skin#getRenderKitId(javax.faces.context.FacesContext)
	 */
	public String getRenderKitId(FacesContext context) {
		return getSkin().getRenderKitId(context);
	}

	/* (non-Javadoc)
	 * @see org.ajax4jsf.framework.skin.Skin#getParameter(javax.faces.context.FacesContext, java.lang.String)
	 */
	public Object getParameter(FacesContext context, String name) {
		return getSkin().getParameter(context,name);
	}

	
	public Object getParameter(FacesContext context, String name, Object defaultValue) {
		
		return getSkin().getParameter(context, name, defaultValue);
	}




	/* (non-Javadoc)
	 * @see org.ajax4jsf.framework.skin.Skin#containsProperty(java.lang.String)
	 */
	public boolean containsProperty(String name) {
		return getSkin().containsProperty(name);
	}
	
	/* Static methods for manipulate skins */
	
	public static Object skinHashCode(){
		FacesContext context = FacesContext.getCurrentInstance();
		int hashCode = SkinFactory.getInstance().getSkin(context).hashCode(context);
		byte[] bs = ByteBuffer.allocate(4).putInt(hashCode).array();
		return bs;
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy