1 16 package org.apache.commons.jelly.tags.core; 17 18 import org.apache.commons.jelly.JellyTagException; 19 import org.apache.commons.jelly.MissingAttributeException; 20 import org.apache.commons.jelly.TagSupport; 21 import org.apache.commons.jelly.XMLOutput; 22 import org.apache.commons.jelly.expression.Expression; 23 24 25 36 public class SwitchTag extends TagSupport { 37 38 public SwitchTag() { 39 } 40 41 44 50 public void setOn(Expression on) { 51 this.on = on; 52 } 53 54 public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { 55 this.defaultEncountered = false; 56 this.someCaseMatched = false; 57 this.fallingThru = false; 58 59 if(null == on) { 60 throw new MissingAttributeException("on"); 61 } else { 62 value = on.evaluate(context); 63 invokeBody(output); 64 } 65 } 66 67 protected boolean hasSomeCaseMatched() { 70 return this.someCaseMatched; 71 } 72 73 protected void caseMatched() { 74 this.someCaseMatched = true; 75 } 76 77 protected boolean isFallingThru() { 78 return this.fallingThru; 79 } 80 81 protected void setFallingThru(boolean fallingThru) { 82 this.fallingThru = fallingThru; 83 } 84 85 protected Object getValue() { 86 return value; 87 } 88 89 protected boolean hasDefaultBeenEncountered() { 90 return defaultEncountered; 91 } 92 93 protected void defaultEncountered() { 94 this.defaultEncountered = true; 95 } 96 97 private boolean someCaseMatched = false; 100 private boolean fallingThru = false; 101 private boolean defaultEncountered = false; 102 private Expression on = null; 103 private Object value = null; 104 105 } 106 | Popular Tags |