01: package com.teamkonzept.lib.templates;
02:
03: import java.io.*;
04:
05: import com.oroinc.text.regex.*;
06:
07: import com.teamkonzept.lib.*;
08:
09: /**
10: * Ein TK_Tag wird aus dem Template gefiltert
11: * @author $Author: alex $
12: * @version $Revision: 1.12 $
13: */
14: public class TKTagDefinitionTag extends TKLabelTag {
15: public TKTemplateSyntax definitionText;
16: static final int TAG_TYPE = TKIncludeTag.TAG_TYPE + 1;
17:
18: /*******************************************************************
19: /**
20: * Konstruktor 1
21: * Ein Syntaxbaum fuer ein Template wird erzeugt.
22: *
23: * @param String def, Name des Tags
24: * @param PatternMatcherInput matcherInput,
25: * @param boolean hasSubTags
26: */
27: public TKTagDefinitionTag(TKTemplateSyntax parent, String def,
28: PatternMatcherInput matcherInput, boolean hasSubTags)
29: throws TKTemplateSyntaxException {
30: super (parent, def, hasSubTags);
31: try {
32: definitionText = parent.newChild(matcherInput, parent
33: .getSource());
34: } catch (ArrayIndexOutOfBoundsException e) { //thrown by TKTemplateSyntax.newTag()
35: throw new TKTemplateSyntaxException(parent.getSource(),
36: "NOEND", "TAGDEF", def);
37: }
38: checkError(definitionText, "TAGDEF", def);
39: }
40:
41: /**
42: * Der entsprechende Body-Part des Templates wird bearbeitet
43: *
44: * @param TKTemplateData td
45: * @return den String, der den bearbeiteten Body-Part enthaelt
46: */
47: public String apply(TKTemplateData td)
48: throws TKTemplateSyntaxException {
49: td.setLocalVariable("TAG_DEFINITION_" + getLabel(td),
50: definitionText);
51:
52: return null;
53: }
54:
55: /*******************************************************************
56: /**
57: * Der entsprechende Body-Part des Templates wird bearbeitet
58: *
59: * @param td TKTemplateData
60: * @param writer Writer, in den der bearbeiteten Body-Part geschrieben wird.
61: */
62: public void apply(TKTemplateData td, Writer writer)
63: throws TKTemplateSyntaxException, IOException {
64: td.setLocalVariable("TAG_DEFINITION_" + getLabel(td),
65: definitionText);
66: }
67:
68: }//end class
|