/* $$ 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.util;
import java.util.ArrayList;
import java.util.List;
import org.apache.tapestry.engine.IPropertySource;
/**
* An implementation of {@link IPropertySource}
* that delegates to a list of other implementations. This makes
* it possible to create a search path for property values.
*
* @author Howard Lewis Ship
* @since 2.3
*
**/
public class DelegatingPropertySource implements IPropertySource
{public static com.cortexeb.tools.clover.d __CLOVER_393_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 List _sources = new ArrayList();
public DelegatingPropertySource()
{try { __CLOVER_393_0.M[2143]++;
} finally { }}
public DelegatingPropertySource(IPropertySource delegate)
{try { __CLOVER_393_0.M[2144]++;
__CLOVER_393_0.S[8804]++;addSource(delegate);
} finally { }}
/**
* Adds another source to the list of delegate property sources.
* This is typically only done during initialization
* of this DelegatingPropertySource.
*
**/
public void addSource(IPropertySource source)
{try { __CLOVER_393_0.M[2145]++;
__CLOVER_393_0.S[8805]++;_sources.add(source);
} finally { }}
/**
* Re-invokes the method on each delegate property source,
* in order, return the first non-null value found.
*
**/
public String getPropertyValue(String propertyName)
{try { __CLOVER_393_0.M[2146]++;
__CLOVER_393_0.S[8806]++;String result = null;
__CLOVER_393_0.S[8807]++;int count = _sources.size();
__CLOVER_393_0.S[8808]++;for (int i = 0; (((i < count) && (++__CLOVER_393_0.CT[1484] != 0)) || (++__CLOVER_393_0.CF[1484] == 0)); i++){
{
__CLOVER_393_0.S[8809]++;IPropertySource source = (IPropertySource)_sources.get(i);
__CLOVER_393_0.S[8810]++;result = source.getPropertyValue(propertyName);
__CLOVER_393_0.S[8811]++;if ((((result != null) && (++__CLOVER_393_0.CT[1485] != 0)) || (++__CLOVER_393_0.CF[1485] == 0))){
__CLOVER_393_0.S[8812]++;break;}
}}
__CLOVER_393_0.S[8813]++;return result;
} finally { }}
}