package javax.faces.component;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.io.IOException;
import java.io.Serializable;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.AbstractCollection;
import java.util.AbstractSet;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.WeakHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.el.ELException;
import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
import javax.faces.event.FacesListener;
import javax.faces.render.RenderKit;
import javax.faces.render.Renderer;
public abstract class UIComponentBase extends UIComponent
{
private static Logger log;
private static Map<Class<?>, Map<String, PropertyDescriptor>> descriptors;
private Map<String, PropertyDescriptor> pdMap = null;
private static Object[] empty;
private AttributesMap attributes = null;
private String clientId = null;
private String id = null;
private UIComponent parent = null;
private boolean rendered = true;
private boolean renderedSet = false;
private String rendererType = null;
private List<UIComponent> children = null;
private static final String SEPARATOR_STRING = ":";
private Map<String, UIComponent> facets = null;
private List<FacesListener> listeners;
private static final int MY_STATE = 0;
private static final int CHILD_STATE = 1;
private Object[] values;
private boolean transientFlag = false;
private static final Object[] EMPTY_ARRAY;
private static final Iterator EMPTY_ITERATOR;
public UIComponentBase()
{
populateDescriptorsMapIfNecessary();
}
private void populateDescriptorsMapIfNecessary() {
Class clazz = getClass();
this.transientFlag = ((Map)descriptors.get(clazz));
if (null != this.transientFlag) {
return;
}
PropertyDescriptor[] pd = getPropertyDescriptors();
if (pd != null) {
this.transientFlag = new WeakHashMap(pd.length);
PropertyDescriptor[] arr$ = pd; int len$ = arr$.length; for (int i$ = 0; i$ < len$; ++i$) { PropertyDescriptor aPd = arr$[i$];
this.transientFlag.put(aPd.getName(), aPd);
}
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE, "fine.component.populating_descriptor_map", new Object[] { clazz, Thread.currentThread().getName() });
}
Map reCheckMap = (Map)descriptors.get(clazz);
if (null != reCheckMap)
return;
descriptors.put(clazz, this.transientFlag);
}
}
private PropertyDescriptor getPropertyDescriptor(String name)
{
if (this.transientFlag != null)
return ((PropertyDescriptor)this.transientFlag.get(name));
return null;
}
private PropertyDescriptor[] getPropertyDescriptors()
{
PropertyDescriptor[] pd = null;
try {
pd = Introspector.getBeanInfo(getClass()).getPropertyDescriptors();
}
catch (IntrospectionException e) {
throw new FacesException(e);
}
return pd;
}
public Map<String, Object> getAttributes()
{
if (this.attributes == null)
this.attributes = new AttributesMap(this, null);
return this.attributes;
}
/**
* @deprecated
*/
public ValueBinding getValueBinding(String name)
{
if (name == null)
throw new NullPointerException();
ValueBinding result = null;
ValueExpression ve = null;
if (null != (ve = getValueExpression(name)))
{
if (ve.getClass() == ValueExpressionValueBindingAdapter.class) {
result = ((ValueExpressionValueBindingAdapter)ve).getWrapped();
}
else
{
result = new ValueBindingValueExpressionAdapter(ve);
}
}
return result;
}
/**
* @deprecated
*/
public void setValueBinding(String name, ValueBinding binding)
{
if (name == null)
throw new NullPointerException();
if (binding != null) {
ValueExpressionValueBindingAdapter adapter = new ValueExpressionValueBindingAdapter(binding);
setValueExpression(name, adapter);
}
else setValueExpression(name, null);
}
public ValueExpression getValueExpression(String name)
{
return super.getValueExpression(name);
}
public void setValueExpression(String name, ValueExpression binding)
{
super.setValueExpression(name, binding);
}
public String getClientId(FacesContext context)
{
if (context == null) {
throw new NullPointerException();
}
if (this.clientId == null) {
UIComponent parent = getNamingContainer();
String parentId = null;
if (parent != null) {
parentId = parent.getContainerClientId(context);
}
this.clientId = this.id;
if (this.clientId == null)
this.clientId = context.getViewRoot().createUniqueId();
if (parentId != null) {
this.clientId = parentId + ':' + this.clientId;
}
Renderer renderer = getRenderer(context);
if (renderer != null)
this.clientId = renderer.convertClientId(context, this.clientId);
}
return this.clientId;
}
private UIComponent getNamingContainer()
{
UIComponent namingContainer = getParent();
while (namingContainer != null) {
if (namingContainer instanceof NamingContainer)
return namingContainer;
namingContainer = namingContainer.getParent();
}
return null;
}
public String getId()
{
return this.id;
}
public void setId(String id)
{
validateId(id);
this.id = id;
this.clientId = null;
}
public UIComponent getParent()
{
return this.parent;
}
public void setParent(UIComponent parent)
{
this.parent = parent;
}
public boolean isRendered()
{
if (this.renderedSet)
return this.rendered;
ValueExpression ve = getValueExpression("rendered");
if (ve != null) {
boolean result = false;
try {
result = !(Boolean.FALSE.equals(ve.getValue(getFacesContext().getELContext())));
}
catch (ELException e) {
throw new FacesException(e);
}
return result;
}
return this.rendered;
}
public void setRendered(boolean rendered)
{
this.rendered = rendered;
this.renderedSet = true;
}
public String getRendererType()
{
if (this.rendererType != null)
return this.rendererType;
ValueExpression ve = getValueExpression("rendererType");
if (ve != null) {
String result = null;
try {
result = (String)ve.getValue(getFacesContext().getELContext());
}
catch (ELException e) {
throw new FacesException(e);
}
return result;
}
return null;
}
public void setRendererType(String rendererType)
{
this.rendererType = rendererType;
}
public boolean getRendersChildren()
{
boolean result = false;
Renderer renderer = null;
if (getRendererType() != null)
if (null != (renderer = getRenderer(getFacesContext())))
{
result = renderer.getRendersChildren();
}
return result;
}
public List<UIComponent> getChildren()
{
if (this.children == null)
this.children = new