Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.sitemesh.parser
Class AbstractPage  view AbstractPage download AbstractPage.java

java.lang.Object
  extended bycom.sitemesh.parser.AbstractPage
All Implemented Interfaces:
com.sitemesh.Page
Direct Known Subclasses:
AbstractHTMLPage, UnParsedPage

public abstract class AbstractPage
extends java.lang.Object
implements com.sitemesh.Page

Abstract implementation of com.sitemesh.Page .

Contains base methods for storing and accessing page properties. Also stores pageData 55 as byte[] and implements write???() methods.

Concrete implementations need only set the pageData 55 and call addProperty(java.lang.String,java.lang.String) 55 to add all the required information.

Version:
$Revision: 1.7 $

Field Summary
protected  byte[] pageData
          Date of page contents.
private  java.util.Map properties
          Map of all properties.
 javax.servlet.http.HttpServletRequest request
          RequestURI of original Page.
 
Constructor Summary
AbstractPage()
           
 
Method Summary
protected  void addProperty(java.lang.String name, java.lang.String value)
          Add a property to the properties list.
 boolean getBooleanProperty(java.lang.String name)
          Get a property embedded into the Page as a boolean.
 int getContentLength()
          Length of the Page, in the format before it was parsed.
 int getIntProperty(java.lang.String name)
          Get a property embedded into the Page as an int.
 long getLongProperty(java.lang.String name)
          Get a property embedded into the Page as a long.
 java.lang.String[] getProperties(java.lang.String name)
          Get properties embedded into the Page as a String[].
 java.lang.String getProperty(java.lang.String name)
          Get a property embedded into the Page as a String.
 java.lang.String[] getPropertyKeys()
          Get all available property keys for the Page.
 int getPropertySize(java.lang.String name)
          Determine the number of properties embedded into the Page with a given name.
 javax.servlet.http.HttpServletRequest getRequest()
          Return the request of the original page.
 boolean isPropertySet(java.lang.String name)
          Determine whether a property embedded into the Page has been set.
protected  java.lang.String noNull(java.lang.String in)
          Return String as is, or "" if null.
 void setRequest(javax.servlet.http.HttpServletRequest request)
          Create snapshot of Request.
 boolean shouldCache()
          Returns false.
 void writePage(java.io.OutputStream out)
          Write the entire contents of the Page, in the format before it was parsed, to the OutputStream.
 void writePage(java.io.Writer out)
          Write the entire contents of the Page, in the format before it was parsed, to the Writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

properties

private java.util.Map properties
Map of all properties. Key is String. Value is java.util.List of multiple String values.


pageData

protected byte[] pageData
Date of page contents.


request

public javax.servlet.http.HttpServletRequest request
RequestURI of original Page.

Constructor Detail

AbstractPage

public AbstractPage()
Method Detail

writePage

public void writePage(java.io.OutputStream out)
               throws java.io.IOException
Description copied from interface: com.sitemesh.Page
Write the entire contents of the Page, in the format before it was parsed, to the OutputStream.

Specified by:
writePage in interface com.sitemesh.Page

writePage

public void writePage(java.io.Writer out)
               throws java.io.IOException
Description copied from interface: com.sitemesh.Page
Write the entire contents of the Page, in the format before it was parsed, to the Writer.

Specified by:
writePage in interface com.sitemesh.Page

getContentLength

public int getContentLength()
Description copied from interface: com.sitemesh.Page
Length of the Page, in the format before it was parsed.

Specified by:
getContentLength in interface com.sitemesh.Page

getProperty

public java.lang.String getProperty(java.lang.String name)
Description copied from interface: com.sitemesh.Page
Get a property embedded into the Page as a String.

Specified by:
getProperty in interface com.sitemesh.Page

getIntProperty

public int getIntProperty(java.lang.String name)
Description copied from interface: com.sitemesh.Page
Get a property embedded into the Page as an int. Returns 0 if property not specified or not valid number.

Specified by:
getIntProperty in interface com.sitemesh.Page

getLongProperty

public long getLongProperty(java.lang.String name)
Description copied from interface: com.sitemesh.Page
Get a property embedded into the Page as a long. Returns 0L if property not specified or not valid number.

Specified by:
getLongProperty in interface com.sitemesh.Page

getBooleanProperty

public boolean getBooleanProperty(java.lang.String name)
Description copied from interface: com.sitemesh.Page
Get a property embedded into the Page as a boolean. Returns true if value starts with '1', 't' or 'y' (case-insensitive) - otherwise returns false.

Specified by:
getBooleanProperty in interface com.sitemesh.Page

getProperties

public java.lang.String[] getProperties(java.lang.String name)
Description copied from interface: com.sitemesh.Page
Get properties embedded into the Page as a String[]. Returns zero length array if no properties set.

Specified by:
getProperties in interface com.sitemesh.Page

isPropertySet

public boolean isPropertySet(java.lang.String name)
Description copied from interface: com.sitemesh.Page
Determine whether a property embedded into the Page has been set.

Specified by:
isPropertySet in interface com.sitemesh.Page

getPropertySize

public int getPropertySize(java.lang.String name)
Description copied from interface: com.sitemesh.Page
Determine the number of properties embedded into the Page with a given name.

Specified by:
getPropertySize in interface com.sitemesh.Page

getPropertyKeys

public java.lang.String[] getPropertyKeys()
Description copied from interface: com.sitemesh.Page
Get all available property keys for the Page.

Specified by:
getPropertyKeys in interface com.sitemesh.Page

shouldCache

public boolean shouldCache()
Returns false. Override as necessary.

Specified by:
shouldCache in interface com.sitemesh.Page

getRequest

public javax.servlet.http.HttpServletRequest getRequest()
Description copied from interface: com.sitemesh.Page
Return the request of the original page.

Specified by:
getRequest in interface com.sitemesh.Page

setRequest

public void setRequest(javax.servlet.http.HttpServletRequest request)
Create snapshot of Request.

Specified by:
setRequest in interface com.sitemesh.Page

addProperty

protected void addProperty(java.lang.String name,
                           java.lang.String value)
Add a property to the properties list.

Duplicate keys are allowed... property will be given multiple values. Sub-classes should use this for adding properties to the page.


noNull

protected java.lang.String noNull(java.lang.String in)
Return String as is, or "" if null. (Prevents NullPointerExceptions)