1 package org.kohsuke.stapler.jelly; 2 3 import org.apache.commons.jelly.JellyTagException; 4 import org.apache.commons.jelly.MissingAttributeException; 5 import org.apache.commons.jelly.TagSupport; 6 import org.apache.commons.jelly.XMLOutput; 7 import org.apache.commons.jelly.expression.Expression; 8 import org.xml.sax.SAXException ; 9 10 17 public class OutTag extends TagSupport { 18 private Expression value; 19 20 public void setValue(Expression value) { 21 this.value = value; 22 } 23 24 public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { 25 final String text = value.evaluateAsString(context); 26 if (text != null) { 27 StringBuilder buf = new StringBuilder (text.length()); 28 for (int i=0; i<text.length(); i++ ) { 29 char ch = text.charAt(i); 30 switch(ch) { 31 case '<': buf.append("<"); break; 32 case '&': buf.append("&"); break; 33 default: buf.append(ch); 34 } 35 } 36 37 try { 38 output.write(buf.toString()); 39 } 40 catch (SAXException e) { 41 throw new JellyTagException("could not write the XMLOutput",e); 42 } 43 } 44 } 45 } 46 | Popular Tags |