Source code: com/sitemesh/parser/AbstractHTMLPage.java
1 package com.sitemesh.parser;
2
3 import com.sitemesh.HTMLPage;
4 import java.io.*;
5 import java.net.MalformedURLException;
6 import java.net.URL;
7
8 /**
9 * Abstract implementation of {@link com.sitemesh.HTMLPage}.
10 *
11 * <p>Adds to {@link com.sitemesh.parser.AbstractPage} some HTML methods.
12 * To implement, follow guidelines of super-class, and implement the 2
13 * abstract methods states below.</p>
14 *
15 * @author <a href="joe@truemesh.com">Joe Walnes</a>
16 * @version $Revision: 1.5 $
17 *
18 * @see com.sitemesh.parser.AbstractPage
19 * @see com.sitemesh.HTMLPage
20 */
21 public abstract class AbstractHTMLPage extends AbstractPage implements HTMLPage {
22
23 /**
24 * Write data of html <code><head></code> tag.
25 *
26 * <p>Must be implemented. Data written should not actually contain the
27 * head tags, but all the data in between.
28 */
29 public abstract void writeHead( Writer out ) throws IOException;
30
31 /**
32 * Write data of html <code><body></code> tag.
33 *
34 * <p>Must be implemented. Data written should not actually contain the
35 * body tags, but all the data in between.
36 */
37 public abstract void writeBody( Writer out ) throws IOException;
38
39 /**
40 * Calls {@link #writeHead(java.io.Writer)}
41 */
42 public void writeHead( OutputStream out ) throws IOException {
43 writeHead( new OutputStreamWriter( out ) );
44 }
45
46 /**
47 * Calls {@link #writeBody(java.io.Writer)}
48 */
49 public void writeBody( OutputStream out ) throws IOException {
50 writeBody( new OutputStreamWriter( out ) );
51 }
52
53 /**
54 * Return title of from "title" property. Never returns null.
55 */
56 public String getTitle() {
57 return noNull(getProperty( "title" ));
58 }
59
60 /**
61 * Return decorator name of from "decorator" property. Never returns null.
62 */
63 public String getDecoratorName() {
64 return noNull(getProperty( "decorator" ));
65 }
66
67 }