/* $$ 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.link;
import java.util.List;
import org.apache.tapestry.IActionListener;
import org.apache.tapestry.IBinding;
import org.apache.tapestry.IDirect;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.Tapestry;
import org.apache.tapestry.engine.ILink;
/**
* A component for creating a link using the direct service; used for actions that
* are not dependant on dynamic page state.
*
* [<a href="../../../../../ComponentReference/DirectLink.html">Component Reference</a>]
*
* @author Howard Lewis Ship
*
**/
public abstract class DirectLink extends AbstractLinkComponent implements IDirect
{public static com.cortexeb.tools.clover.d __CLOVER_176_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);
public abstract IBinding getStatefulBinding();
public abstract IActionListener getListener();
/**
* Returns true if the stateful parameter is bound to
* a true value. If stateful is not bound, also returns
* the default, true. May be invoked when not renderring.
*
**/
public boolean isStateful()
{try { __CLOVER_176_0.M[891]++;
__CLOVER_176_0.S[4252]++;IBinding statefulBinding = getStatefulBinding();
__CLOVER_176_0.S[4253]++;if ((((statefulBinding == null) && (++__CLOVER_176_0.CT[785] != 0)) || (++__CLOVER_176_0.CF[785] == 0))){
__CLOVER_176_0.S[4254]++;return true;}
__CLOVER_176_0.S[4255]++;return statefulBinding.getBoolean();
} finally { }}
public ILink getLink(IRequestCycle cycle)
{try { __CLOVER_176_0.M[892]++;
__CLOVER_176_0.S[4256]++;return getLink(cycle, Tapestry.DIRECT_SERVICE, constructServiceParameters(getParameters()));
} finally { }}
/**
* Converts a service parameters value to an array
* of objects.
* This is used by the {@link DirectLink}, {@link ServiceLink}
* and {@link ExternalLink}
* components.
*
* @param parameterValue the input value which may be
* <ul>
* <li>null (returns null)
* <li>An array of Object (returns the array)
* <li>A {@link List} (returns an array of the values in the List})
* <li>A single object (returns the object as a single-element array)
* </ul>
*
* @return An array representation of the input object.
*
* @since 2.2
**/
public static Object[] constructServiceParameters(Object parameterValue)
{try { __CLOVER_176_0.M[893]++;
__CLOVER_176_0.S[4257]++;if ((((parameterValue == null) && (++__CLOVER_176_0.CT[786] != 0)) || (++__CLOVER_176_0.CF[786] == 0))){
__CLOVER_176_0.S[4258]++;return null;}
__CLOVER_176_0.S[4259]++;if ((((parameterValue instanceof Object[]) && (++__CLOVER_176_0.CT[787] != 0)) || (++__CLOVER_176_0.CF[787] == 0))){
__CLOVER_176_0.S[4260]++;return (Object[]) parameterValue;}
__CLOVER_176_0.S[4261]++;if ((((parameterValue instanceof List) && (++__CLOVER_176_0.CT[788] != 0)) || (++__CLOVER_176_0.CF[788] == 0))){
{
__CLOVER_176_0.S[4262]++;List list = (List) parameterValue;
__CLOVER_176_0.S[4263]++;return list.toArray();
}}
__CLOVER_176_0.S[4264]++;return new Object[] { parameterValue };
} finally { }}
/**
* Invoked by the direct service to trigger the application-specific
* action by notifying the {@link IActionListener listener}.
*
* @throws org.apache.tapestry.StaleSessionException if the component is stateful, and
* the session is new.
*
**/
public void trigger(IRequestCycle cycle)
{try { __CLOVER_176_0.M[894]++;
__CLOVER_176_0.S[4265]++;IActionListener listener = getListener();
__CLOVER_176_0.S[4266]++;if ((((listener == null) && (++__CLOVER_176_0.CT[789] != 0)) || (++__CLOVER_176_0.CF[789] == 0))){
__CLOVER_176_0.S[4267]++;throw Tapestry.createRequiredParameterException(this, "listener");}
__CLOVER_176_0.S[4268]++;listener.actionTriggered(this, cycle);
} finally { }}
/** @since 2.2 **/
public abstract Object getParameters();
}