01: /*
02: * Created on Feb 21, 2005
03: */
04: package com.sun.portal.wireless.htmlconversion.processors;
05:
06: import java.util.HashMap;
07:
08: import org.w3c.dom.Document;
09: import org.w3c.dom.Element;
10:
11: import com.sun.portal.wireless.htmlconversion.ParserState;
12:
13: /**
14: * Maps the content in the HTML <title> tag to the title attribute of the
15: * root AmlDocument tag.
16: *
17: * @author ashwin.mathew@sun.com
18: */
19: public class AmlDocumentTitleTagProcessor extends BaseTagProcessor {
20:
21: public static final String AML_DOCUMENT = "AmlDocument";
22:
23: public static final String ATTR_TITLE = "title";
24:
25: public static final String HTML_TITLE = "title";
26:
27: private static final String[] supportedTags = { HTML_TITLE };
28:
29: /* (non-Javadoc)
30: * @see com.sun.portal.wireless.htmlconversion.TagProcessor#getAmlTag()
31: */
32: public String getAmlTag() {
33: // Since this implementation does not create any particular AML tag
34: return null;
35: }
36:
37: /* (non-Javadoc)
38: * @see com.sun.portal.wireless.htmlconversion.TagProcessor#getSupportedTags()
39: */
40: public String[] getSupportedTags() {
41: return supportedTags;
42: }
43:
44: /* (non-Javadoc)
45: * @see com.sun.portal.wireless.htmlconversion.TagProcessor#startTag(java.lang.String, java.util.HashMap, com.sun.portal.wireless.htmlconversion.ParserState)
46: */
47: public Element startTag(String tagName, HashMap attributes,
48: ParserState state) {
49: return null;
50: }
51:
52: /* (non-Javadoc)
53: * @see com.sun.portal.wireless.htmlconversion.TagProcessor#endTag(org.w3c.dom.Element, com.sun.portal.wireless.htmlconversion.ParserState)
54: */
55: public Element endTag(String tag, ParserState state) {
56: Document output = state.getOutputDocument();
57:
58: Element amlDocument = output.getDocumentElement();
59: amlDocument.setAttribute(ATTR_TITLE, state.getText());
60:
61: state.clearText();
62:
63: return null;
64: }
65:
66: /* (non-Javadoc)
67: * @see com.sun.portal.wireless.htmlconversion.TagProcessor#canHaveChildren()
68: */
69: public boolean canHaveChildren(ParserState state) {
70: return false;
71: }
72:
73: /* (non-Javadoc)
74: * @see com.sun.portal.wireless.htmlconversion.TagProcessor#isMaintainOnState()
75: */
76: public boolean isMaintainOnState(ParserState state) {
77: return false;
78: }
79: }
|