/* $$ 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.pageload;
import java.util.Iterator;
import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.hivemind.ClassResolver;
import org.apache.tapestry.IBinding;
import org.apache.tapestry.IComponent;
import org.apache.tapestry.binding.ExpressionBinding;
import org.apache.tapestry.spec.IComponentSpecification;
import org.apache.tapestry.spec.IParameterSpecification;
/**
* For all parameters in the examined component that have default values, but are not bound,
* automatically add an ExpressionBinding with the default value.
*
* @author mindbridge
* @since 3.0
*/
public class EstablishDefaultParameterValuesVisitor implements IComponentVisitor
{public static com.cortexeb.tools.clover.d __CLOVER_191_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 ClassResolver _resolver;
public EstablishDefaultParameterValuesVisitor(ClassResolver resolver)
{try { __CLOVER_191_0.M[953]++;
__CLOVER_191_0.S[4479]++;_resolver = resolver;
} finally { }}
/**
* @see org.apache.tapestry.pageload.IComponentVisitor#visitComponent(org.apache.tapestry.IComponent)
*/
public void visitComponent(IComponent component)
{try { __CLOVER_191_0.M[954]++;
__CLOVER_191_0.S[4480]++;IComponentSpecification spec = component.getSpecification();
__CLOVER_191_0.S[4481]++;Iterator i = spec.getParameterNames().iterator();
__CLOVER_191_0.S[4482]++;while ((((i.hasNext()) && (++__CLOVER_191_0.CT[826] != 0)) || (++__CLOVER_191_0.CF[826] == 0))){
{
__CLOVER_191_0.S[4483]++;String name = (String) i.next();
__CLOVER_191_0.S[4484]++;IParameterSpecification parameterSpec = spec.getParameter(name);
__CLOVER_191_0.S[4485]++;String defaultValue = parameterSpec.getDefaultValue();
__CLOVER_191_0.S[4486]++;if ((((defaultValue == null) && (++__CLOVER_191_0.CT[827] != 0)) || (++__CLOVER_191_0.CF[827] == 0))){
__CLOVER_191_0.S[4487]++;continue;}
// the parameter has a default value, so it must not be required
__CLOVER_191_0.S[4488]++;if ((((parameterSpec.isRequired()) && (++__CLOVER_191_0.CT[828] != 0)) || (++__CLOVER_191_0.CF[828] == 0))){
__CLOVER_191_0.S[4489]++;throw new ApplicationRuntimeException(
PageloadMessages.parameterMustHaveNoDefaultValue(component, name),
component,
parameterSpec.getLocation(),
null);}
// if there is no binding for this parameter, bind it to the default value
__CLOVER_191_0.S[4490]++;if ((((component.getBinding(name) == null) && (++__CLOVER_191_0.CT[829] != 0)) || (++__CLOVER_191_0.CF[829] == 0))){
{
__CLOVER_191_0.S[4491]++;IBinding binding =
new ExpressionBinding(
_resolver,
component,
defaultValue,
parameterSpec.getLocation());
__CLOVER_191_0.S[4492]++;component.setBinding(name, binding);
}}
}}
} finally { }}
}