org.richfaces.skin.SkinImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of richfaces-core Show documentation
Show all versions of richfaces-core Show documentation
The RichFaces core framework.
The newest version!
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc. and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.richfaces.skin;
import java.util.Map;
import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.context.FacesContext;
import org.ajax4jsf.Messages;
/**
* Singleton ( in respect as collection of different skins ) for produce instances properties for all used skins.
*
* @author shura (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:41 $
*/
final class SkinImpl extends AbstractSkin {
private static final Operation RESOLVE = new Operation() {
public Object executeLocal(FacesContext facesContext, SkinImpl skin, String name) {
Object resolvedParameter = skin.getLocalParameter(facesContext, name);
while (resolvedParameter instanceof String) {
String string = (String) resolvedParameter;
if ((string.length() > 0) && (string.charAt(0) == '&')) {
SkinFactory skinFactory = SkinFactory.getInstance(facesContext);
resolvedParameter = skinFactory.getSkin(facesContext).getParameter(facesContext, string.substring(1));
if (resolvedParameter == null) {
throw new FacesException(Messages.getMessage(Messages.SKIN_ILLEGAL_REFERENCE, name));
}
} else {
break;
}
}
return resolvedParameter;
}
@Override
public Object executeBase(FacesContext facesContext, Skin skin, String name) {
return skin.getParameter(facesContext, name);
}
};
private static final Operation CONTAINS = new Operation() {
public Object executeLocal(FacesContext facesContext, SkinImpl skin, String name) {
return skin.localContainsProperty(facesContext, name) ? Boolean.TRUE : Boolean.FALSE;
}
@Override
public Object executeBase(FacesContext facesContext, Skin skin, String name) {
return skin.containsProperty(name);
}
};
private final Map