KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > wings > template > SimpleTagHandler


1 /*
2  * $Id: SimpleTagHandler.java,v 1.5 2005/03/14 13:33:28 neurolabs Exp $
3  * Copyright 2000,2005 wingS development team.
4  *
5  * This file is part of wingS (http://www.j-wings.org).
6  *
7  * wingS is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * Please see COPYING for the complete licence.
13  */

14 package org.wings.template;
15
16 import org.wings.template.parser.ParseContext;
17 import org.wings.template.parser.PositionReader;
18 import org.wings.template.parser.SGMLTag;
19
20 import java.io.IOException JavaDoc;
21
22 /**
23  * A TemplateTagHandler
24  *
25  * @author <A HREF="mailto:zeller@think.de">Henner Zeller</A>
26  * @version $Revision: 1.5 $
27  */

28 public class SimpleTagHandler extends TemplateTagHandler {
29     /**
30      * Parse special tag.
31      *
32      * @param context The ParseContext
33      * @param input The PositionReader, located after the Name token of the Tag
34      * @param startPosition The Position parsing of this token began
35      * @param tag the SGMLTag found in the file.
36      */

37     public SGMLTag parseTag(ParseContext context,
38                             PositionReader input,
39                             long startPosition,
40                             SGMLTag tag)
41             throws IOException JavaDoc {
42         /*
43          * parse the full tag to get all parameters
44          * (i.e. an optional 'format'-parameter)
45          * and to place the Reader at the position
46          * after the closing '>'
47          */

48         tag.parse(input);
49
50         /*
51          * The Offset is the space the reader skipped
52          * before it reached the opening '<'
53          * <!-- a comment --> some garbage <DATE>
54          * ^----- offset --------------------^
55          */

56         startPos = startPosition + tag.getOffset();
57
58         /*
59          * get required properties
60          */

61         name = tag.value("NAME", null);
62         if (name == null)
63             return null;
64         
65         /*
66          * special handling for radio buttons. They react on the
67          * constraint name "NAME=VALUE"
68          */

69         String JavaDoc type = tag.value("TYPE", null);
70         if (type != null && "RADIO".equals(type.toUpperCase())) {
71             String JavaDoc value = tag.value("VALUE", null);
72             if (value != null)
73                 name = name + "=" + value;
74         }
75
76         endPos = input.getPosition();
77
78         properties = tag.getAttributes();
79         properties.remove("NAME");
80         properties.remove("TYPE");
81         properties.remove("VALUE");
82
83         return tag;
84     }
85 }
86
87
88
Popular Tags