KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/lib/templates/TKExistsTag.java,v 1.7 2001/08/14 13:51:16 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
18 import com.teamkonzept.lib.*;
19
20 /**
21  * Ein TK_EXISTS ueberprueft, ob der als String uebergebene Dateiname
22  * eine existierende Datei referenziert. Wenn ja, wird "1" ersetzt, sonst "0"
23  * @author $Author: mischa $
24  * @version $Revision: 1.7 $
25  */

26 public class TKExistsTag extends TKLabelTag {
27     static final int TAG_TYPE = TKWhileTag.TAG_TYPE+1;
28     static final String JavaDoc TRUE = "1";
29     static final String JavaDoc FALSE = "0";
30
31     public TKExistsTag( TKTemplateSyntax parent, String JavaDoc name, boolean hasSubTags ) throws TKTemplateSyntaxException
32     {
33         super( parent, name, hasSubTags );
34     }
35
36     public String JavaDoc apply( TKTemplateData td ) throws TKTemplateSyntaxException
37     {
38         String JavaDoc location = getRealLabel( td );
39         String JavaDoc parentLocation = ( parent == null ? "" : parent.getSource() );
40
41         return TKTemplateCache.exists( location, parentLocation ) ? TRUE : FALSE;
42     }
43
44     public void apply(TKTemplateData td, Writer writer)
45         throws TKTemplateSyntaxException, IOException
46     {
47         String JavaDoc location = getRealLabel( td );
48         String JavaDoc parentLocation = ( parent == null ? "" : parent.getSource() );
49
50         writer.write(TKTemplateCache.exists( location, parentLocation ) ? TRUE : FALSE);
51     }
52
53
54 }//end class
55

56
Popular Tags