01: /*
02: * $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/lib/templates/TKExistsTag.java,v 1.7 2001/08/14 13:51:16 mischa Exp $
03: *
04: */
05: /**
06: *
07: *
08: * Aufbau: name="TK_CLASSNAME[par_name;class_name:class_value;...]" value="..."
09: * ------------ ----------
10: * primaere Klasse Sekundaere Klasse
11: *
12: * Bsp: name="TK_EV[THE_EVENT;QOR:0.8_0.5]" value="..."
13: */package com.teamkonzept.lib.templates;
14:
15: import java.io.*;
16:
17: import com.teamkonzept.lib.*;
18:
19: /**
20: * Ein TK_EXISTS ueberprueft, ob der als String uebergebene Dateiname
21: * eine existierende Datei referenziert. Wenn ja, wird "1" ersetzt, sonst "0"
22: * @author $Author: mischa $
23: * @version $Revision: 1.7 $
24: */
25: public class TKExistsTag extends TKLabelTag {
26: static final int TAG_TYPE = TKWhileTag.TAG_TYPE + 1;
27: static final String TRUE = "1";
28: static final String FALSE = "0";
29:
30: public TKExistsTag(TKTemplateSyntax parent, String name,
31: boolean hasSubTags) throws TKTemplateSyntaxException {
32: super (parent, name, hasSubTags);
33: }
34:
35: public String apply(TKTemplateData td)
36: throws TKTemplateSyntaxException {
37: String location = getRealLabel(td);
38: String parentLocation = (parent == null ? "" : parent
39: .getSource());
40:
41: return TKTemplateCache.exists(location, parentLocation) ? TRUE
42: : FALSE;
43: }
44:
45: public void apply(TKTemplateData td, Writer writer)
46: throws TKTemplateSyntaxException, IOException {
47: String location = getRealLabel(td);
48: String parentLocation = (parent == null ? "" : parent
49: .getSource());
50:
51: writer
52: .write(TKTemplateCache.exists(location, parentLocation) ? TRUE
53: : FALSE);
54: }
55:
56: }//end class
|