Clover coverage report - Code Coverage for tapestry release 4.0-beta-2
Coverage timestamp: Sat Jul 9 2005 22:02:17 EDT
file stats: LOC: 111   Methods: 3
NCLOC: 55   Classes: 1
30 day Evaluation License registered to hlship@comcast.net Your 30 day evaluation period has expired. Please visit http://www.cenqua.com to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
AbstractSubmit.java 100% 100% 100% 100%
coverage
 1    // Copyright 2005 The Apache Software Foundation
 2    //
 3    // Licensed under the Apache License, Version 2.0 (the "License");
 4    // you may not use this file except in compliance with the License.
 5    // You may obtain a copy of the License at
 6    //
 7    // http://www.apache.org/licenses/LICENSE-2.0
 8    //
 9    // Unless required by applicable law or agreed to in writing, software
 10    // distributed under the License is distributed on an "AS IS" BASIS,
 11    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12    // See the License for the specific language governing permissions and
 13    // limitations under the License.
 14   
 15    package org.apache.tapestry.form;
 16   
 17    import java.util.Collection;
 18   
 19    import org.apache.tapestry.IActionListener;
 20    import org.apache.tapestry.IForm;
 21    import org.apache.tapestry.IMarkupWriter;
 22    import org.apache.tapestry.IRequestCycle;
 23    import org.apache.tapestry.listener.ListenerInvoker;
 24   
 25    /**
 26    * Superclass for components submitting their form.
 27    *
 28    * @author Richard Lewis-Shell
 29    * @since 4.0
 30    */
 31   
 32    abstract class AbstractSubmit extends AbstractFormComponent
 33    {
 34    /**
 35    * Determine if this submit component was clicked.
 36    *
 37    * @param cycle
 38    * @param name
 39    * @return true if this submit was clicked
 40    */
 41    protected abstract boolean isClicked(IRequestCycle cycle, String name);
 42   
 43    /**
 44    * @see org.apache.tapestry.form.AbstractFormComponent#rewindFormComponent(org.apache.tapestry.IMarkupWriter, org.apache.tapestry.IRequestCycle)
 45    */
 46  5 protected void rewindFormComponent(IMarkupWriter writer, IRequestCycle cycle)
 47    {
 48  5 if (isClicked(cycle, getName()))
 49  3 handleClick(cycle, getForm());
 50    }
 51   
 52  7 void handleClick(final IRequestCycle cycle, IForm form)
 53    {
 54  7 if (isParameterBound("selected"))
 55  3 setSelected(getTag());
 56   
 57  7 final IActionListener listener = getListener();
 58   
 59  7 if (listener == null)
 60  3 return;
 61   
 62  4 final ListenerInvoker listenerInvoker = getListenerInvoker();
 63   
 64  4 Object parameters = getParameters();
 65  4 if (parameters != null)
 66    {
 67  2 if (parameters instanceof Collection)
 68    {
 69  1 cycle.setListenerParameters(((Collection) parameters).toArray());
 70    }
 71    else
 72    {
 73  1 cycle.setListenerParameters(new Object[]
 74    { parameters });
 75    }
 76    }
 77   
 78    // Have a listener; notify it now, or defer for later?
 79   
 80  4 Runnable notify = new Runnable()
 81    {
 82  4 public void run()
 83    {
 84  4 listenerInvoker.invokeListener(listener, AbstractSubmit.this, cycle);
 85    }
 86    };
 87   
 88  4 if (getDefer())
 89  3 form.addDeferredRunnable(notify);
 90    else
 91  1 notify.run();
 92    }
 93   
 94    /** parameter */
 95    public abstract IActionListener getListener();
 96   
 97    /** parameter */
 98    public abstract Object getTag();
 99   
 100    /** parameter */
 101    public abstract void setSelected(Object tag);
 102   
 103    /** parameter */
 104    public abstract boolean getDefer();
 105   
 106    /** parameter */
 107    public abstract Object getParameters();
 108   
 109    /** Injected */
 110    public abstract ListenerInvoker getListenerInvoker();
 111    }