01: /*
02: * Copyright 2000,2005 wingS development team.
03: *
04: * This file is part of wingS (http://wingsframework.org).
05: *
06: * wingS is free software; you can redistribute it and/or modify
07: * it under the terms of the GNU Lesser General Public License
08: * as published by the Free Software Foundation; either version 2.1
09: * of the License, or (at your option) any later version.
10: *
11: * Please see COPYING for the complete licence.
12: */
13: package org.wings.template;
14:
15: import org.wings.template.parser.ParseContext;
16: import org.wings.template.parser.PositionReader;
17: import org.wings.template.parser.SGMLTag;
18:
19: import java.io.IOException;
20:
21: /**
22: * A TemplateTagHandler
23: *
24: * @author <A href="mailto:zeller@think.de">Henner Zeller</A>
25: */
26: public class SimpleTagHandler extends TemplateTagHandler {
27: /**
28: * Parse special tag.
29: *
30: * @param context The ParseContext
31: * @param input The PositionReader, located after the Name token of the Tag
32: * @param startPosition The Position parsing of this token began
33: * @param tag the SGMLTag found in the file.
34: */
35: public SGMLTag parseTag(ParseContext context, PositionReader input,
36: long startPosition, SGMLTag tag) throws IOException {
37: /*
38: * parse the full tag to get all parameters
39: * (i.e. an optional 'format'-parameter)
40: * and to place the Reader at the position
41: * after the closing '>'
42: */
43: tag.parse(input);
44:
45: /*
46: * The Offset is the space the reader skipped
47: * before it reached the opening '<'
48: * <!-- a comment --> some garbage <DATE>
49: * ^----- offset --------------------^
50: */
51: startPos = startPosition + tag.getOffset();
52:
53: /*
54: * get required properties
55: */
56: name = tag.value("NAME", null);
57: if (name == null)
58: return null;
59:
60: /*
61: * special handling for radio buttons. They react on the
62: * constraint name "NAME=VALUE"
63: */
64: String type = tag.value("TYPE", null);
65: if (type != null && "RADIO".equals(type.toUpperCase())) {
66: String value = tag.value("VALUE", null);
67: if (value != null)
68: name = name + "=" + value;
69: }
70:
71: endPos = input.getPosition();
72:
73: properties = tag.getAttributes();
74: properties.remove("NAME");
75: properties.remove("TYPE");
76: properties.remove("VALUE");
77:
78: return tag;
79: }
80: }
|