Class AbstractPage
java.lang.Object
com.opensymphony.module.sitemesh.parser.AbstractPage
- All Implemented Interfaces:
Page
- Direct Known Subclasses:
AbstractHTMLPage
Abstract implementation of
Page
.
Contains base methods for storing and accessing page properties.
Also stores pageData
as byte[] and implements write???()
methods.
Concrete implementations need only set the pageData
and
call addProperty(java.lang.String,java.lang.String)
to
add all the required information.
- Version:
- $Revision: 1.6 $
- Author:
- Joe Walnes
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected char[]
Date of page contents.private final Map
Map of all properties.private javax.servlet.http.HttpServletRequest
RequestURI of original Page. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addProperty
(String name, String value) Add a property to the properties list.getBody()
Convenience method to return the contents of the<body>
tag.boolean
getBooleanProperty
(String name) Get a property embedded into thePage
as aboolean
.int
Length of thePage
, in the format before it was parsed.int
getIntProperty
(String name) Get a property embedded into thePage
as anint
.long
getLongProperty
(String name) Get a property embedded into thePage
as along
.getPage()
Convenience method to return the contents of thePage
in its original format.Get aMap
representing all the properties in thePage
.getProperty
(String name) Get a property embedded into thePage
as aString
.String[]
Get all available property keys for thePage
.javax.servlet.http.HttpServletRequest
Return the request of the original page.getTitle()
Return title of from "title" property.boolean
isPropertySet
(String name) Determine whether a property embedded into thePage
has been set.protected static String
Return String as is, or "" if null.void
setRequest
(javax.servlet.http.HttpServletRequest request) Create snapshot of Request.abstract void
Write data of html<body>
tag.void
Write the entire contents of thePage
, in the format before it was parsed, to theWriter
.
-
Field Details
-
properties
Map of all properties. Key is String. Value is java.util.List of multiple String values. -
pageData
protected char[] pageDataDate of page contents. -
request
private javax.servlet.http.HttpServletRequest requestRequestURI of original Page.
-
-
Constructor Details
-
AbstractPage
public AbstractPage()
-
-
Method Details
-
writePage
Description copied from interface:Page
Write the entire contents of thePage
, in the format before it was parsed, to theWriter
.- Specified by:
writePage
in interfacePage
- Parameters:
out
- Writer to write to.- Throws:
IOException
- Rethrown if cannot write to writer.
-
getPage
Description copied from interface:Page
Convenience method to return the contents of thePage
in its original format. -
writeBody
Write data of html<body>
tag.Must be implemented. Data written should not actually contain the body tags, but all the data in between.
- Specified by:
writeBody
in interfacePage
- Throws:
IOException
-
getBody
Description copied from interface:Page
Convenience method to return the contents of the<body>
tag. -
getTitle
Return title of from "title" property. Never returns null. -
getContentLength
public int getContentLength()Description copied from interface:Page
Length of thePage
, in the format before it was parsed.- Specified by:
getContentLength
in interfacePage
- Returns:
- Length of page data (in number of bytes).
-
getProperty
Description copied from interface:Page
Get a property embedded into thePage
as aString
.- Specified by:
getProperty
in interfacePage
- Parameters:
name
- Name of property- Returns:
- Property value
-
getIntProperty
Description copied from interface:Page
Get a property embedded into thePage
as anint
. Returns 0 if property not specified or not valid number.- Specified by:
getIntProperty
in interfacePage
- Parameters:
name
- Name of property- Returns:
- Property value
-
getLongProperty
Description copied from interface:Page
Get a property embedded into thePage
as along
. Returns 0L if property not specified or not valid number.- Specified by:
getLongProperty
in interfacePage
- Parameters:
name
- Name of property- Returns:
- Property value
-
getBooleanProperty
Description copied from interface:Page
Get a property embedded into thePage
as aboolean
. Returns true if value starts with '1', 't' or 'y' (case-insensitive) - otherwise returns false.- Specified by:
getBooleanProperty
in interfacePage
- Parameters:
name
- Name of property- Returns:
- Property value
-
isPropertySet
Description copied from interface:Page
Determine whether a property embedded into thePage
has been set.- Specified by:
isPropertySet
in interfacePage
- Parameters:
name
- Name of property- Returns:
- Whether it has been set
-
getPropertyKeys
Description copied from interface:Page
Get all available property keys for thePage
.- Specified by:
getPropertyKeys
in interfacePage
- Returns:
- Property keys
-
getProperties
Description copied from interface:Page
Get aMap
representing all the properties in thePage
.- Specified by:
getProperties
in interfacePage
- Returns:
- Properties map
-
getRequest
public javax.servlet.http.HttpServletRequest getRequest()Description copied from interface:Page
Return the request of the original page.- Specified by:
getRequest
in interfacePage
- See Also:
-
setRequest
public void setRequest(javax.servlet.http.HttpServletRequest request) Create snapshot of Request.- Specified by:
setRequest
in interfacePage
- See Also:
-
addProperty
Add a property to the properties list.- Specified by:
addProperty
in interfacePage
- Parameters:
name
- Name of propertyvalue
- Value of property
-
noNull
Return String as is, or "" if null. (Prevents NullPointerExceptions)
-