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: 128   Methods: 3
NCLOC: 60   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
Hidden.java 100% 84.2% 66.7% 84.6%
coverage coverage
 1    // Copyright 2004, 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.io.IOException;
 18   
 19    import org.apache.hivemind.ApplicationRuntimeException;
 20    import org.apache.tapestry.IActionListener;
 21    import org.apache.tapestry.IForm;
 22    import org.apache.tapestry.IMarkupWriter;
 23    import org.apache.tapestry.IRequestCycle;
 24    import org.apache.tapestry.listener.ListenerInvoker;
 25    import org.apache.tapestry.services.DataSqueezer;
 26   
 27    /**
 28    * Implements a hidden field within a {@link Form}. [ <a
 29    * href="../../../../../ComponentReference/Hidden.html">Component Reference </a>]
 30    *
 31    * @author Howard Lewis Ship
 32    * @author Paul Ferraro
 33    */
 34    public abstract class Hidden extends AbstractFormComponent
 35    {
 36    /**
 37    * @see org.apache.tapestry.form.AbstractFormComponent#renderFormComponent(org.apache.tapestry.IMarkupWriter, org.apache.tapestry.IRequestCycle)
 38    */
 39  4 protected void renderFormComponent(IMarkupWriter writer, IRequestCycle cycle)
 40    {
 41  4 IForm form = getForm();
 42  4 String externalValue = null;
 43   
 44  4 if (getEncode())
 45    {
 46  2 Object value = getValue();
 47   
 48  2 try
 49    {
 50  2 externalValue = getDataSqueezer().squeeze(value);
 51    }
 52    catch (IOException e)
 53    {
 54  0 throw new ApplicationRuntimeException(e.getMessage(), this, null, e);
 55    }
 56    }
 57    else
 58  2 externalValue = (String) getBinding("value").getObject(String.class);
 59   
 60  4 String id = getClientId();
 61   
 62  4 form.addHiddenValue(getName(), id, externalValue);
 63    }
 64   
 65    /**
 66    * @see org.apache.tapestry.form.AbstractFormComponent#rewindFormComponent(org.apache.tapestry.IRequestCycle)
 67    */
 68  4 protected void rewindFormComponent(IMarkupWriter writer, IRequestCycle cycle)
 69    {
 70  4 String parameter = cycle.getParameter(getName());
 71   
 72  4 Object value = parameter;
 73   
 74  4 if (getEncode())
 75    {
 76  2 try
 77    {
 78  2 value = getDataSqueezer().unsqueeze(parameter);
 79    }
 80    catch (IOException ex)
 81    {
 82  0 throw new ApplicationRuntimeException(ex.getMessage(), this, null, ex);
 83    }
 84    }
 85   
 86    // A listener is not always necessary ... it's easy to code
 87    // the synchronization as a side-effect of the accessor method.
 88   
 89  4 setValue(value);
 90   
 91  4 getListenerInvoker().invokeListener(getListener(), this, cycle);
 92    }
 93   
 94    /** @since 2.2 * */
 95    public abstract DataSqueezer getDataSqueezer();
 96   
 97    public abstract Object getValue();
 98   
 99    public abstract void setValue(Object value);
 100   
 101    public abstract IActionListener getListener();
 102   
 103    /**
 104    * Injected.
 105    *
 106    * @since 4.0
 107    */
 108   
 109    public abstract ListenerInvoker getListenerInvoker();
 110   
 111    /**
 112    * Returns false. Hidden components are never disabled.
 113    *
 114    * @since 2.2
 115    */
 116  0 public boolean isDisabled()
 117    {
 118  0 return false;
 119    }
 120   
 121    /**
 122    * Returns true if the compent encodes object values using a
 123    * {@link org.apache.tapestry.util.io.DataSqueezerImpl}, false if values are always Strings.
 124    *
 125    * @since 2.2
 126    */
 127    public abstract boolean getEncode();
 128    }