Class AbstractPage
- java.lang.Object
-
- com.opensymphony.module.sitemesh.parser.AbstractPage
-
- All Implemented Interfaces:
Page
- Direct Known Subclasses:
AbstractHTMLPage,UnParsedPage
public abstract class AbstractPage extends java.lang.Object implements Page
Abstract implementation ofPage.Contains base methods for storing and accessing page properties. Also stores
pageDataas byte[] and implements write???() methods.Concrete implementations need only set the
pageDataand calladdProperty(java.lang.String,java.lang.String)to add all the required information.- Version:
- $Revision: 1.2 $
- Author:
- Joe Walnes
- See Also:
Page
-
-
Field Summary
Fields Modifier and Type Field Description (package private) char[]pageDataDate of page contents.private java.util.MappropertiesMap of all properties.private jakarta.servlet.http.HttpServletRequestrequestRequestURI of original Page.
-
Constructor Summary
Constructors Constructor Description AbstractPage()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddProperty(java.lang.String name, java.lang.String value)Add a property to the properties list.booleangetBooleanProperty(java.lang.String name)Get a property embedded into thePageas aboolean.intgetContentLength()Length of thePage, in the format before it was parsed.intgetIntProperty(java.lang.String name)Get a property embedded into thePageas anint.longgetLongProperty(java.lang.String name)Get a property embedded into thePageas along.java.util.MapgetProperties()Get aMaprepresenting all the properties in thePage.java.lang.StringgetProperty(java.lang.String name)Get a property embedded into thePageas aString.java.lang.String[]getPropertyKeys()Get all available property keys for thePage.jakarta.servlet.http.HttpServletRequestgetRequest()Return the request of the original page.java.lang.StringgetTitle()Return title of from "title" property.booleanisPropertySet(java.lang.String name)Determine whether a property embedded into thePagehas been set.protected static java.lang.StringnoNull(java.lang.String in)Return String as is, or "" if null.voidsetRequest(jakarta.servlet.http.HttpServletRequest request)Create snapshot of Request.abstract voidwriteBody(java.io.Writer out)Write data of html<body>tag.voidwritePage(java.io.Writer out)Write the entire contents of thePage, in the format before it was parsed, to theWriter.
-
-
-
Method Detail
-
writePage
public void writePage(java.io.Writer out) throws java.io.IOExceptionDescription copied from interface:PageWrite the entire contents of thePage, in the format before it was parsed, to theWriter.
-
writeBody
public abstract void writeBody(java.io.Writer out) throws java.io.IOExceptionWrite data of html<body>tag.Must be implemented. Data written should not actually contain the body tags, but all the data in between.
-
getTitle
public java.lang.String getTitle()
Return title of from "title" property. Never returns null.
-
getContentLength
public int getContentLength()
Description copied from interface:PageLength of thePage, in the format before it was parsed.- Specified by:
getContentLengthin interfacePage- Returns:
- Length of page data (in number of bytes).
-
getProperty
public java.lang.String getProperty(java.lang.String name)
Description copied from interface:PageGet a property embedded into thePageas aString.- Specified by:
getPropertyin interfacePage- Parameters:
name- Name of property- Returns:
- Property value
-
getIntProperty
public int getIntProperty(java.lang.String name)
Description copied from interface:PageGet a property embedded into thePageas anint. Returns 0 if property not specified or not valid number.- Specified by:
getIntPropertyin interfacePage- Parameters:
name- Name of property- Returns:
- Property value
-
getLongProperty
public long getLongProperty(java.lang.String name)
Description copied from interface:PageGet a property embedded into thePageas along. Returns 0L if property not specified or not valid number.- Specified by:
getLongPropertyin interfacePage- Parameters:
name- Name of property- Returns:
- Property value
-
getBooleanProperty
public boolean getBooleanProperty(java.lang.String name)
Description copied from interface:PageGet a property embedded into thePageas aboolean. Returns true if value starts with '1', 't' or 'y' (case-insensitive) - otherwise returns false.- Specified by:
getBooleanPropertyin interfacePage- Parameters:
name- Name of property- Returns:
- Property value
-
isPropertySet
public boolean isPropertySet(java.lang.String name)
Description copied from interface:PageDetermine whether a property embedded into thePagehas been set.- Specified by:
isPropertySetin interfacePage- Parameters:
name- Name of property- Returns:
- Whether it has been set
-
getPropertyKeys
public java.lang.String[] getPropertyKeys()
Description copied from interface:PageGet all available property keys for thePage.- Specified by:
getPropertyKeysin interfacePage- Returns:
- Property keys
-
getProperties
public java.util.Map getProperties()
Description copied from interface:PageGet aMaprepresenting all the properties in thePage.- Specified by:
getPropertiesin interfacePage- Returns:
- Properties map
-
getRequest
public jakarta.servlet.http.HttpServletRequest getRequest()
Description copied from interface:PageReturn the request of the original page.- Specified by:
getRequestin interfacePage- See Also:
Page.getRequest()
-
setRequest
public void setRequest(jakarta.servlet.http.HttpServletRequest request)
Create snapshot of Request.- Specified by:
setRequestin interfacePage- See Also:
Page.getRequest()
-
addProperty
public void addProperty(java.lang.String name, java.lang.String value)Add a property to the properties list.- Specified by:
addPropertyin interfacePage- Parameters:
name- Name of propertyvalue- Value of property
-
noNull
protected static java.lang.String noNull(java.lang.String in)
Return String as is, or "" if null. (Prevents NullPointerExceptions)
-
-