KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > module > sitemesh > Page


1 /*
2  * Title: Page
3  * Description:
4  *
5  * This software is published under the terms of the OpenSymphony Software
6  * License version 1.1, of which a copy has been included with this
7  * distribution in the LICENSE.txt file.
8  */

9
10 package com.opensymphony.module.sitemesh;
11
12 import javax.servlet.http.HttpServletRequest JavaDoc;
13 import java.io.IOException JavaDoc;
14 import java.io.Writer JavaDoc;
15 import java.util.Map JavaDoc;
16
17 /**
18  * The Page object wraps the contents of the original (undecorated) page.
19  *
20  * <p>The original data in its entirity can be written using the writePage()
21  * methods. It may also contain a set of properties - these vary among
22  * different {@link com.opensymphony.module.sitemesh.PageParser} implementations.</p>
23  *
24  * <p>Typically a Page is no use to a {@link com.opensymphony.module.sitemesh.Decorator} as it needs
25  * specific details relevant to the content-type of that page (<i>e.g.</i> HTML
26  * pages). The appropriate {@link com.opensymphony.module.sitemesh.PageParser} is responsible
27  * for returning extended implementations of pages such as {@link com.opensymphony.module.sitemesh.HTMLPage}
28  * which are of more use to the Decorator. New media types (<i>e.g.</i> WML) could
29  * be added to the system by extending Page and implementing an appropriate PageParser.</p>
30  *
31  * @author <a HREF="mailto:joe@truemesh.com">Joe Walnes</a>
32  * @version $Revision: 1.3 $
33  */

34 public interface Page {
35     /**
36      * Write the entire contents of the <code>Page</code>, in the format before
37      * it was parsed, to the <code>Writer</code>.
38      *
39      * @param out Writer to write to.
40      * @exception java.io.IOException Rethrown if cannot write to writer.
41      */

42     void writePage(Writer JavaDoc out) throws IOException JavaDoc;
43
44     /**
45      * Convenience method to return the contents of the <code>Page</code> in its original format.
46      *
47      * @since 2.1.1
48      * @see #writePage(java.io.Writer)
49      */

50     String JavaDoc getPage();
51
52     /**
53      * Write the contents of the <code>&lt;body&gt;</code> tag.
54      */

55     void writeBody(Writer JavaDoc out) throws IOException JavaDoc;
56
57     /**
58      * Convenience method to return the contents of the <code>&lt;body&gt;</code> tag.
59      *
60      * @since 2.1.1
61      * @see #writeBody(java.io.Writer)
62      */

63     String JavaDoc getBody();
64
65     /**
66      * Get the Title of the document
67      */

68     String JavaDoc getTitle();
69
70     /**
71      * Length of the <code>Page</code>, in the format before
72      * it was parsed.
73      *
74      * @return Length of page data (in number of bytes).
75      */

76     int getContentLength();
77
78     /**
79      * Get a property embedded into the <code>Page</code> as a <code>String</code>.
80      *
81      * @param name Name of property
82      * @return Property value
83      */

84     String JavaDoc getProperty(String JavaDoc name);
85
86     /**
87      * Get a property embedded into the <code>Page</code> as an <code>int</code>.
88      * Returns 0 if property not specified or not valid number.
89      *
90      * @param name Name of property
91      * @return Property value
92      */

93     int getIntProperty(String JavaDoc name);
94
95     /**
96      * Get a property embedded into the <code>Page</code> as a <code>long</code>.
97      * Returns 0L if property not specified or not valid number.
98      *
99      * @param name Name of property
100      * @return Property value
101      */

102     long getLongProperty(String JavaDoc name);
103
104     /**
105      * Get a property embedded into the <code>Page</code> as a <code>boolean</code>.
106      * Returns true if value starts with '1', 't' or 'y' (case-insensitive) -
107      * otherwise returns false.
108      *
109      * @param name Name of property
110      * @return Property value
111      */

112     boolean getBooleanProperty(String JavaDoc name);
113
114     /**
115      * Determine whether a property embedded into the <code>Page</code> has been set.
116      *
117      * @param name Name of property
118      * @return Whether it has been set
119      */

120     boolean isPropertySet(String JavaDoc name);
121
122     /**
123      * Get all available property keys for the <code>Page</code>.
124      *
125      * @return Property keys
126      */

127     String JavaDoc[] getPropertyKeys();
128
129     /**
130      * Get a <code>Map</code> representing all the properties in the <code>Page</code>.
131      *
132      * @return Properties map
133      */

134     Map JavaDoc getProperties();
135
136     /**
137      * Return the request of the original page.
138      */

139     HttpServletRequest JavaDoc getRequest();
140
141     /**
142      * Create snapshot of Request. Subsequent modifications to the request by
143      * the servlet container will not be returned by {@link #getRequest()}
144      */

145     void setRequest(HttpServletRequest JavaDoc request);
146
147     /**
148      * Manually add a property to page.
149      */

150     void addProperty(String JavaDoc name, String JavaDoc value);
151 }
Popular Tags