1 16 package org.apache.commons.jelly.impl; 17 18 import org.apache.commons.jelly.JellyContext; 19 import org.apache.commons.jelly.JellyTagException; 20 import org.apache.commons.jelly.Script; 21 import org.apache.commons.jelly.XMLOutput; 22 23 import org.xml.sax.SAXException ; 24 25 30 public class TextScript implements Script { 31 32 33 private String text; 34 35 public TextScript() { 36 } 37 38 public TextScript(String text) { 39 this.text = text; 40 } 41 42 public String toString() { 43 return super.toString() + "[text=" + text + "]"; 44 } 45 46 49 public void trimWhitespace() { 50 if(text.trim().length()==0) 51 this.text = ""; 52 } 53 54 55 public String getText() { 56 return text; 57 } 58 59 60 public void setText(String text) { 61 this.text = text; 62 } 63 64 public Script compile() { 67 return this; 68 } 69 70 71 public void run(JellyContext context, XMLOutput output) throws JellyTagException { 72 if ( text != null ) { 73 try { 74 output.write(text); 75 } catch (SAXException e) { 76 throw new JellyTagException("could not write to XMLOutput",e); 77 } 78 } 79 } 80 } 81 | Popular Tags |