Coverage report

  %line %branch
org.apache.commons.jelly.tags.core.DefaultTag
88% 
100% 

 1  
 /*
 2  
  * Copyright 2002,2004 The Apache Software Foundation.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.apache.commons.jelly.tags.core;
 17  
 
 18  
 import org.apache.commons.jelly.JellyTagException;
 19  
 import org.apache.commons.jelly.TagSupport;
 20  
 import org.apache.commons.jelly.XMLOutput;
 21  
 
 22  
 
 23  
 /**
 24  
  * A tag which conditionally evaluates its body if
 25  
  * none of its preceeding sibling {@link CaseTag <case>}
 26  
  * tags have been evaluated.
 27  
  *
 28  
  * This tag must be contained within the body of some
 29  
  * {@link SwitchTag <switch>} tag.
 30  
  *
 31  
  * @see SwitchTag
 32  
  *
 33  
  * @author Rodney Waldhoff
 34  
  * @version $Revision: 155420 $ $Date: 2005-02-27 00:06:03 +1100 (Sun, 27 Feb 2005) $
 35  
  */
 36  
 public class DefaultTag extends TagSupport {
 37  
 
 38  195
     public DefaultTag() {
 39  195
     }
 40  
 
 41  
     // Tag interface
 42  
     //-------------------------------------------------------------------------
 43  
 
 44  
     public void setFallThru(boolean fallThru) {
 45  0
         this.fallThru = fallThru;
 46  0
     }
 47  
 
 48  
     public void doTag(XMLOutput output) throws JellyTagException {
 49  221
         SwitchTag tag = (SwitchTag)findAncestorWithClass(SwitchTag.class);
 50  208
         if(null == tag) {
 51  13
             throw new JellyTagException("This tag must be enclosed inside a <switch> tag" );
 52  
         }
 53  195
         if(tag.hasDefaultBeenEncountered()) {
 54  13
             throw new JellyTagException("Only one <default> tag is allowed per <switch>.");
 55  
         }
 56  182
         tag.defaultEncountered();
 57  182
         if(tag.isFallingThru() || (!tag.hasSomeCaseMatched())) {
 58  65
             tag.caseMatched();
 59  65
             tag.setFallingThru(fallThru);
 60  65
             invokeBody(output);
 61  
         }
 62  182
     }
 63  
 
 64  
     // Attributes
 65  
     //-------------------------------------------------------------------------
 66  195
     private boolean fallThru = false;
 67  
 
 68  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.