KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > teamkonzept > lib > templates > TKCaseTag


1 /*
2  * $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/lib/templates/TKCaseTag.java,v 1.10 2001/08/14 13:48:49 mischa Exp $
3  *
4  */

5 /**
6  *
7  *
8  * Aufbau: name="TK_CLASSNAME[par_name;class_name:class_value;...]" value="..."
9  * ------------ ----------
10  * primaere Klasse Sekundaere Klasse
11  *
12  * Bsp: name="TK_EV[THE_EVENT;QOR:0.8_0.5]" value="..."
13  */

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 /**
22  * Ein TK_CASE wird aus dem Template gefiltert
23  * @author $Author: mischa $
24  * @version $Revision: 1.10 $
25  */

26 public class TKCaseTag extends TKLabelTag {
27     
28     public TKTemplateSyntax caseText;
29     static final int TAG_TYPE = TKTrimTag.TAG_TYPE+1;
30
31     /*******************************************************************
32     /**
33      * Konstruktor 1
34      * Ein Syntaxbaum fuer ein Template wird erzeugt.
35      *
36      * @param String def, Name des Tags
37      * @param PatternMatcherInput matcherInput,
38      * @param boolean hasSubTags
39      */

40     public TKCaseTag( TKTemplateSyntax parent, String JavaDoc 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 JavaDoc e) { //thrown by TKTemplateSyntax.newTag()
48
throw new TKTemplateSyntaxException(parent.getSource(),"NOEND","CASE", def);
49         }
50         checkError(caseText,"CASE", def);
51     }
52     
53     /*******************************************************************
54     /**
55      * Der entsprechende CASE-Part des Templates wird bearbeitet
56      *
57      * @param TKTemplateData td
58      * @return den String, der den bearbeiteten Case-Part enthaelt
59      */

60     public String JavaDoc apply( TKTemplateData td ) throws TKTemplateSyntaxException
61     {
62         String JavaDoc 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     /*******************************************************************
71     /**
72      * Der entsprechende CASE-Part des Templates wird bearbeitet
73      *
74      * @param TKTemplateData td
75      * @param Writer writer
76      */

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 JavaDoc value = tmpWriter.getBuffer();
83         
84         if( value != null && value.length() > 0 )
85         {
86             caseText.apply(td, writer);
87         }
88     }
89
90 }//end class
91

92
Popular Tags