Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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 jakarta.faces.component;
import java.beans.BeanInfo;
import java.beans.PropertyDescriptor;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import jakarta.el.ValueExpression;
import jakarta.faces.FacesException;
import jakarta.faces.application.Resource;
import jakarta.faces.context.FacesContext;
import java.util.function.BiConsumer;
import java.util.function.Function;
import org.apache.myfaces.core.api.shared.lang.Assert;
import org.apache.myfaces.core.api.shared.lang.LambdaPropertyDescriptor;
import org.apache.myfaces.core.api.shared.lang.PropertyDescriptorUtils;
import org.apache.myfaces.core.api.shared.lang.PropertyDescriptorWrapper;
/**
*
* A custom implementation of the Map interface, where get and put calls
* try to access getter/setter methods of an associated UIComponent before
* falling back to accessing a real Map object.
*
*
* Some of the behaviours of this class don't really comply with the
* definitions of the Map class; for example the key parameter to all
* methods is required to be of type String only, and after clear(),
* calls to get can return non-null values. However the Faces spec
* requires that this class behave in the way implemented below. See
* UIComponent.getAttributes for more details.
*
*
* The term "property" is used here to refer to real javabean properties
* on the underlying UIComponent, while "attribute" refers to an entry
* in the associated Map.
*
*/
class _ComponentAttributesMap implements Map, Serializable
{
private static final long serialVersionUID = -9106832179394257866L;
private static final Object[] EMPTY_ARGS = new Object[0];
private final static String MARK_CREATED = "oam.vf.MARK_ID";
private final static String FACET_NAME_KEY = "facelets.FACET_NAME";
public final static String FACET_CREATED_UIPANEL_MARKER = "oam.vf.createdUIPanel";
private final static String COMPONENT_ADDED_BY_HANDLER_MARKER = "oam.vf.addedByHandler";
public static final String PROPERTY_DESCRIPTOR_MAP_KEY = "oam.cc.beanInfo.PDM";
/**
* This variable works as a check to indicate the minimun lenght we need to check
* for the special attributes, and save some time in get(), containsKey() and
* put() operations.
*/
private final static int MIN_LENGHT_CHECK = MARK_CREATED.length();
// The component that is read/written via this map.
private UIComponentBase _component;
// A cached hashmap of propertyName => PropertyDescriptor object for all
// the javabean properties of the associated component. This is built by
// introspection on the associated UIComponent. Don't serialize this as
// it can always be recreated when needed.
private transient Map _propertyDescriptorMap = null;
private boolean _isCompositeComponent;
private boolean _isCompositeComponentSet;
private BeanInfo _ccBeanInfo;
/**
* Create a map backed by the specified component.
*
* This method is expected to be called when a component is first created.
*/
_ComponentAttributesMap(UIComponentBase component)
{
_component = component;
}
/**
* Return the number of attributes in this map. Properties of the
* underlying UIComponent are not counted.
*
* Note that because the get method can read properties of the
* UIComponent and evaluate value-bindings, it is possible to have
* size return zero while calls to the get method return non-null
* values.
*/
@Override
public int size()
{
return getUnderlyingMap().size();
}
/**
* Clear all the attributes in this map. Properties of the
* underlying UIComponent are not modified.
*
* Note that because the get method can read properties of the
* UIComponent and evaluate value-bindings, it is possible to have
* calls to the get method return non-null values immediately after
* a call to clear.
*/
@Override
public void clear()
{
getUnderlyingMap().clear();
}
/**
* Return true if there are no attributes in this map. Properties
* of the underlying UIComponent are not counted.
*
* Note that because the get method can read properties of the
* UIComponent and evaluate value-bindings, it is possible to have
* isEmpty return true, while calls to the get method return non-null
* values.
*/
@Override
public boolean isEmpty()
{
return getUnderlyingMap().isEmpty();
}
/**
* Return true if there is an attribute with the specified name,
* but false if there is a javabean property of that name on the
* associated UIComponent.
*
* Note that it should be impossible for the attributes map to contain
* an entry with the same name as a javabean property on the associated
* UIComponent.
*
* @param key must be a String. Anything else will cause a
* ClassCastException to be thrown.
*/
@Override
public boolean containsKey(Object key)
{
checkKey(key);
int keyLength = ((String)key).length();
if (keyLength >= MIN_LENGHT_CHECK)
{
if (MARK_CREATED.length() == keyLength &&
MARK_CREATED.equals(key))
{
return _component.getOamVfMarkCreated() != null;
}
else if (FACET_NAME_KEY.length() == keyLength &&
FACET_NAME_KEY.equals(key))
{
return _component.getOamVfFacetName() != null;
}
else if (COMPONENT_ADDED_BY_HANDLER_MARKER.length() == keyLength &&
COMPONENT_ADDED_BY_HANDLER_MARKER.equals(key))
{
return _component.isOamVfAddedByHandler();
}
else if (FACET_CREATED_UIPANEL_MARKER.length() == keyLength &&
FACET_CREATED_UIPANEL_MARKER.equals(key))
{
return _component.isOamVfFacetCreatedUIPanel();
}
// The most common call to this method comes from UIComponent.isCompositeComponent()
// to reduce the impact. This is better than two lookups, once over property descriptor map
// and the other one from the underlying map.
if (Resource.COMPONENT_RESOURCE_KEY.length() == keyLength &&
Resource.COMPONENT_RESOURCE_KEY.equals(key))
{
if (!_isCompositeComponentSet)
{
// Note we are not setting _isCompositeComponentSet, because when the component tree is built
// using Faces 1.2 state saving, PostAddToViewEvent is propagated and the component is check
// if is a composite component, but the state is not restored, so the check return always
// false. A check for processing events was added to prevent that scenario, but anyway that
// makes invalid set _isCompositeComponentSet to true on this location.
_isCompositeComponent = getUnderlyingMap().containsKey(Resource.COMPONENT_RESOURCE_KEY);
}
return _isCompositeComponent;
}
}
PropertyDescriptorWrapper pd = getPropertyDescriptor((String) key);
return pd == null || pd.getReadMethod() == null
? getUnderlyingMap().containsKey(key)
: false;
}
/**
* Returns true if there is an attribute with the specified
* value. Properties of the underlying UIComponent aren't examined,
* nor value-bindings.
*
* @param value null is allowed
*/
@Override
public boolean containsValue(Object value)
{
return getUnderlyingMap().containsValue(value);
}
/**
* Return a collection of the values of all attributes. Property
* values are not included, nor value-bindings.
*/
@Override
public Collection