1 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 36 public class DefaultTag extends TagSupport { 37 38 public DefaultTag() { 39 } 40 41 44 public void setFallThru(boolean fallThru) { 45 this.fallThru = fallThru; 46 } 47 48 public void doTag(XMLOutput output) throws JellyTagException { 49 SwitchTag tag = (SwitchTag)findAncestorWithClass(SwitchTag.class); 50 if(null == tag) { 51 throw new JellyTagException("This tag must be enclosed inside a <switch> tag" ); 52 } 53 if(tag.hasDefaultBeenEncountered()) { 54 throw new JellyTagException("Only one <default> tag is allowed per <switch>."); 55 } 56 tag.defaultEncountered(); 57 if(tag.isFallingThru() || (!tag.hasSomeCaseMatched())) { 58 tag.caseMatched(); 59 tag.setFallingThru(fallThru); 60 invokeBody(output); 61 } 62 } 63 64 private boolean fallThru = false; 67 68 } 69 | Popular Tags |