/* $$ Clover has instrumented this file $$ */// Copyright 2004 The Apache Software Foundation
//
// Licensed 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 org.apache.tapestry.engine;
import java.util.Locale;
import org.apache.tapestry.IComponent;
import org.apache.tapestry.util.DelegatingPropertySource;
import org.apache.tapestry.util.LocalizedPropertySource;
import org.apache.tapestry.util.PropertyHolderPropertySource;
/**
* The default property source for component configuration properties.
* The search order this property source follows is the following:<br>
* <ul>
* <li>Component specification
* <li>Namespace (library) specification
* <li>the rest of the search path as defined in the application property source
* </ul>
*
* <p>If a locale has been passed to this object, it will first search for
* the localized versions of the requested property (e.g. property_en_us,
* property_en) and will look at the property itself only at the end.
*
* @author mb
* @since 3.1
*/
public class DefaultComponentPropertySource implements IPropertySource
{public static com.cortexeb.tools.clover.d __CLOVER_76_0 = com.cortexeb.tools.clover.aq.getRecorder(new char[] {67,58,92,119,111,114,107,115,112,97,99,101,92,106,97,107,97,114,116,97,45,116,97,112,101,115,116,114,121,92,102,114,97,109,101,119,111,114,107,92,116,97,114,103,101,116,92,99,108,111,118,101,114,45,100,98},1096998272901L);
private IPropertySource _degatingPropertySource;
/**
* Creates a new default component property source with no associate locale.
* The property source will only use the path specified in the class documentation.
*
* @param component the component for which the properties will be looked up
* @param applicationPropertySource the property source for the application
*/
public DefaultComponentPropertySource(IComponent component, IPropertySource applicationPropertySource) {
this(component, applicationPropertySource, null);__CLOVER_76_0.S[1962]++;try { __CLOVER_76_0.M[450]++;
} finally { }}
/**
* Creates a new default component property source that is associated with the given locale.
* The property source will search property path specified in the class documentation for
* the localized versions of the property first.
*
* @param component the component for which the properties will be looked up
* @param applicationPropertySource the property source for the application
* @param locale the locale to be used for localizing the properties
*/
public DefaultComponentPropertySource(IComponent component, IPropertySource applicationPropertySource, Locale locale) {try { __CLOVER_76_0.M[451]++;
__CLOVER_76_0.S[1963]++;DelegatingPropertySource source = new DelegatingPropertySource();
// Search for the encoding property in the following order:
// First search the component specification
__CLOVER_76_0.S[1964]++;source.addSource(new PropertyHolderPropertySource(component.getSpecification()));
// Then search its library specification
__CLOVER_76_0.S[1965]++;source.addSource(new PropertyHolderPropertySource(component.getNamespace().getSpecification()));
// Then search the rest of the standard path
__CLOVER_76_0.S[1966]++;source.addSource(applicationPropertySource);
__CLOVER_76_0.S[1967]++;if ((((locale != null) && (++__CLOVER_76_0.CT[372] != 0)) || (++__CLOVER_76_0.CF[372] == 0))){
__CLOVER_76_0.S[1968]++;source = new LocalizedPropertySource(locale, source);}
__CLOVER_76_0.S[1969]++;_degatingPropertySource = source;
} finally { }}
/**
* @see org.apache.tapestry.engine.IPropertySource#getPropertyValue(java.lang.String)
*/
public String getPropertyValue(String propertyName)
{try { __CLOVER_76_0.M[452]++;
__CLOVER_76_0.S[1970]++;return _degatingPropertySource.getPropertyValue(propertyName);
} finally { }}
}