Clover coverage report - Code Coverage for tapestry release 4.0-alpha-3
Coverage timestamp: Mon May 16 2005 09:05:49 EDT
file stats: LOC: 79   Methods: 1
NCLOC: 34   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
Upload.java 87.5% 93.8% 100% 92%
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 org.apache.tapestry.IForm;
 18   
 import org.apache.tapestry.IMarkupWriter;
 19   
 import org.apache.tapestry.IRequestCycle;
 20   
 import org.apache.tapestry.multipart.MultipartDecoder;
 21   
 import org.apache.tapestry.request.IUploadFile;
 22   
 
 23   
 /**
 24   
  * Form element used to upload files. For the momement, it is necessary to explicitly set the form's
 25   
  * enctype to "multipart/form-data". [ <a
 26   
  * href="../../../../../ComponentReference/Upload.html">Component Reference </a>]
 27   
  * 
 28   
  * @author Howard Lewis Ship
 29   
  * @since 1.0.8
 30   
  */
 31   
 
 32   
 public abstract class Upload extends AbstractFormComponent
 33   
 {
 34  6
     protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
 35   
     {
 36  6
         IForm form = getForm(cycle);
 37   
 
 38  6
         if (form.wasPrerendered(writer, this))
 39  0
             return;
 40   
 
 41  6
         String name = form.getElementId(this);
 42   
 
 43  6
         if (form.isRewinding())
 44   
         {
 45  4
             if (!isDisabled())
 46   
             {
 47  3
                 IUploadFile file = getDecoder().getFileUpload(name);
 48   
 
 49  3
                 setFile(file);
 50   
             }
 51   
 
 52  4
             return;
 53   
         }
 54   
 
 55   
         // Force the form to use the correct encoding type for
 56   
         // file uploads.
 57   
 
 58  2
         form.setEncodingType("multipart/form-data");
 59   
 
 60  2
         writer.beginEmpty("input");
 61  2
         writer.attribute("type", "file");
 62  2
         writer.attribute("name", name);
 63   
 
 64  2
         if (isDisabled())
 65  1
             writer.attribute("disabled", "disabled");
 66   
 
 67   
         // Size, width, etc. can be specified as informal parameters
 68   
         // (Not making the same mistake here that was made with TextField
 69   
         // and friends).
 70   
 
 71  2
         renderInformalParameters(writer, cycle);
 72   
     }
 73   
 
 74   
     public abstract boolean isDisabled();
 75   
 
 76   
     public abstract void setFile(IUploadFile file);
 77   
 
 78   
     public abstract MultipartDecoder getDecoder();
 79   
 }