1 5 14 package com.teamkonzept.lib.templates; 15 16 import java.io.*; 17 import com.oroinc.text.regex.*; 18 19 import com.teamkonzept.lib.*; 20 21 26 public class TKCaseTag extends TKLabelTag { 27 28 public TKTemplateSyntax caseText; 29 static final int TAG_TYPE = TKTrimTag.TAG_TYPE+1; 30 31 40 public TKCaseTag( TKTemplateSyntax parent, String def, PatternMatcherInput matcherInput, boolean hasSubTags ) throws TKTemplateSyntaxException 41 { 42 43 super( parent, def, hasSubTags ); 44 try { 45 caseText = parent.newChild( matcherInput, parent.getSource() ); 46 } 47 catch (ArrayIndexOutOfBoundsException e) { throw new TKTemplateSyntaxException(parent.getSource(),"NOEND","CASE", def); 49 } 50 checkError(caseText,"CASE", def); 51 } 52 53 60 public String apply( TKTemplateData td ) throws TKTemplateSyntaxException 61 { 62 String value = expandVariable (getLabel( td ),td,null); 63 64 if( value != null && value.length() > 0 ) { 65 return caseText.apply( td ); 66 } 67 return null; 68 } 69 70 77 public void apply(TKTemplateData td, Writer writer) 78 throws TKTemplateSyntaxException, IOException 79 { 80 StringWriter tmpWriter = new StringWriter(); 81 expandVariable (getLabel(td), td, null, tmpWriter); 82 StringBuffer value = tmpWriter.getBuffer(); 83 84 if( value != null && value.length() > 0 ) 85 { 86 caseText.apply(td, writer); 87 } 88 } 89 90 } 92 | Popular Tags |