01: /*
02: * Created on Mar 4, 2005
03: */
04: package com.sun.portal.wireless.htmlconversion.processors;
05:
06: import java.util.HashMap;
07:
08: import org.w3c.dom.Element;
09:
10: import com.sun.portal.wireless.htmlconversion.ParserState;
11:
12: /**
13: * Tag processor for AmlTable tag.
14: *
15: * @author ashwin.mathew@sun.com
16: */
17: public class AmlTableTagProcessor extends BaseTagProcessor {
18:
19: public static final String AML_TABLE = "AmlTable";
20:
21: // Attributes for AmlTable tag
22: public static final String ATTR_HALIGN = "halign";
23: public static final String ATTR_BORDER = "border";
24:
25: // Attributes for HTML table tag
26: public static final String TABLE_ATTR_ALIGN = "align";
27: public static final String TABLE_ATTR_BORDER = "border";
28:
29: private static final String[] supportedTags = { "table" };
30:
31: /* (non-Javadoc)
32: * @see com.sun.portal.wireless.htmlconversion.TagProcessor#getAmlTag()
33: */
34: public String getAmlTag() {
35: return AML_TABLE;
36: }
37:
38: /* (non-Javadoc)
39: * @see com.sun.portal.wireless.htmlconversion.TagProcessor#getSupportedTags()
40: */
41: public String[] getSupportedTags() {
42: return supportedTags;
43: }
44:
45: /* (non-Javadoc)
46: * @see com.sun.portal.wireless.htmlconversion.TagProcessor#canHaveChildren(com.sun.portal.wireless.htmlconversion.ParserState)
47: */
48: public boolean canHaveChildren(ParserState state) {
49: return true;
50: }
51:
52: /* (non-Javadoc)
53: * @see com.sun.portal.wireless.htmlconversion.TagProcessor#startTag(java.lang.String, java.util.HashMap, com.sun.portal.wireless.htmlconversion.ParserState)
54: */
55: public Element startTag(String tagName, HashMap attributes,
56: ParserState state) {
57: Element amlTable = state.newElement(AML_TABLE);
58:
59: String align = (String) attributes.get(TABLE_ATTR_ALIGN);
60: if (align != null) {
61: // Ok, so I'm being a little lazy - by rights I should
62: // have had constants for all values for these attrs from
63: // AmlTable and Table, done a match, and then populated the
64: // right value, but since the value strings look the same,
65: // I'm not going to bother.
66: amlTable.setAttribute(ATTR_HALIGN, align);
67: }
68:
69: String border = (String) attributes.get(TABLE_ATTR_BORDER);
70: if (border != null) {
71: amlTable.setAttribute(ATTR_BORDER, border);
72: }
73:
74: state.getLayoutManager().onStartAmlTableTag(amlTable);
75:
76: return amlTable;
77: }
78:
79: /* (non-Javadoc)
80: * @see com.sun.portal.wireless.htmlconversion.TagProcessor#endTag(java.lang.String, com.sun.portal.wireless.htmlconversion.ParserState)
81: */
82: public Element endTag(String tag, ParserState state) {
83: state.getLayoutManager().onEndAmlTableTag();
84:
85: return null;
86: }
87: }
|