com.pepper.platform.page
Class PepperPage

java.lang.Object
  extended by com.pepper.platform.page.PepperPage
All Implemented Interfaces:
Page
Direct Known Subclasses:
SectionPage

public class PepperPage
extends Object
implements Page

This class implements the Page interface. It manages page persistence, including encryption, indexing and external file references.

See Also:
Page

Field Summary
protected static org.apache.commons.logging.Log log
           
 
Constructor Summary
protected PepperPage(File file)
          Creates a PepperPage from the given File instance.
protected PepperPage(InputStream in)
          Creates a PepperPage from the given InputStream instance.
protected PepperPage(String id, String packageId)
          Creates a PepperPage using the given parameters.
protected PepperPage(String id, String name, com.pepper.platform.page.PageService pageService, String template, org.jdom.Document pageData)
          Instantiates a new PepperPage using the given parameters.
 
Method Summary
 boolean exists()
          Returns true if the Page exists either in the original jar file or on disk
 boolean getBackup()
          Returns true if the Page is marked to for backup.
 File getBaseDir()
          Returns the base directory used when constructing absolute paths from a Page's name.
 Date getCreateDate()
          Returns the page's create date.
 String getDefaultType()
          Returns the defaultPageType of this page, usually a section.
 boolean getForceAutoSave()
          Get the state of the forceAutoSave flag.
 String getId()
          Returns the id of this Page.
 long getLastSaveTime()
          Gets the timestamp that the Page was last saved via the save() method.
 String getName()
          Returns the name of this Page.
 int getNoCache()
          Get the value which controls how the page will be redisplayed when it has been previously loaded into a tab.
 String getPackageName()
          Returns the package name of this Page.
 String getPackageVersion()
          Returns the package version of this Page.
 org.jdom.Document getPageData()
          Returns the application specific XML page data.
 boolean getProcessBody()
          Returns a boolean indicating whether or not this page is setup to honor page processing attributes (eg index, secure, reference ) on an individual element basis.
 String getRootAttrValue(String attrName)
          Returns the value of the specified attribute on the root element (ie page, section) in the document
 List getSupportedPageTypes()
          Returns a list of supported page types that this page may contain.
 String getTemplate()
          Returns the XSLT template of this Page.
 String getType()
          Returns the type of this page.
 boolean isAutoSaveEnabled()
          Returns true if the Page has autoSave enabled.
 boolean isDeletable()
          Returns true if the Page is marked as deletable.
 boolean isHidden()
          Returns true if the Page is marked as hidden.
 boolean isLoaded()
          Returns true if the Page has been loaded from disk, or has had it's XML page data set directly by a call to setPageData().
 boolean isPageTypeSupported(String pageType)
          Indicates whether the specified page type may be contained by this page.
 boolean isReadOnly()
          Returns true if the Page is marked as read-only.
 boolean isSecure()
          Returns true if the Page is marked as secure.
 org.jdom.Document load()
          Loads the Page from disk.
 void save()
          Causes the Page to be serialized to disk.
 void setAutoSaveEnabled(boolean autoSaveEnabled)
          Sets the state of the autoStateEnabled flag
 void setBackup(boolean backup)
          Sets or clears the backup attribute.
 void setBaseDir(String baseDir)
          Sets the base directory used when constructing absolute paths from a Page's name.
 void setClassLoader(ClassLoader cl)
          Sets the class loader of this page.
 void setDefaultType(String type)
           
 void setDeletable(boolean isDeletable)
          Sets or clears the deletable attribute.
 void setForceAutoSave(boolean state)
          If true, this will force the auto save and program framework to save the page the next time such an event is triggered, regardless if other criteria (such as modified components) is met or not.
 void setHidden(boolean isHidden)
          Sets or clears the hidden attribute.
 void setId(String id)
          Sets the id of this Page.
 void setLastSaveTime(long time)
          Sets the timestamp when the page was last saved.
 void setName(String name)
          Sets the name of this Page.
 void setNoCache(int options)
          Set the value which controls how the page will be redisplayed when it has been previously loaded into a tab.
 void setPackageName(String name)
          Sets the package name of this Page.
 void setPackageVersion(String version)
          Sets the package version of this Page.
 void setPageData(org.jdom.Document pageData)
          Sets the application specific XML page data.
 void setProcessBody(boolean processBody)
          Sets the processBody attribute; a boolean value indicating whether or not element-specific page processing attributes ( eg index, secure, reference ) are enabled.
 void setReadOnly(boolean isReadOnly)
          Sets or clears the read-only attribute.
 void setSecure(boolean isSecure)
          Sets or clears the secure attribute.
 void setSupportedPageTypes(List supportedPageTypes)
          Sets the supported page types this page may contain.
 void setTemplate(String template)
          Sets the XSLT template of this Page.
 void setTemplateOverride(String template)
          Sets a temporary template that overrides the value found in the Page.
 void setType(String type)
          Sets the type element of this page.
 String toString()
          Debug method to dump contents of Page.
 void unload()
          Causes the page to unload it's page data so that it can be freed during GC.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log
Constructor Detail

PepperPage

protected PepperPage(String id,
                     String packageId)
Creates a PepperPage using the given parameters. This ctor is primarily used when creating a PepperPage instance that will be initialized from disk via a load() call.

Parameters:
id - The page id. Used to create the file name of the main XML output file and any associated referenced files. Also used as to tie together all indexed elements.
packageId - The packageId of the package requesting the PepperPage creation. PackageId is used to look up the AbstractPepperProgram from which the PageMgr can be found. PageMgr is used for synchronization and locking.

PepperPage

protected PepperPage(File file)
              throws IOException
Creates a PepperPage from the given File instance.

Parameters:
file - a File instance.
Throws:
IOException

PepperPage

protected PepperPage(InputStream in)
Creates a PepperPage from the given InputStream instance.

Parameters:
in - an InputStream instance.

PepperPage

protected PepperPage(String id,
                     String name,
                     com.pepper.platform.page.PageService pageService,
                     String template,
                     org.jdom.Document pageData)
Instantiates a new PepperPage using the given parameters.

Parameters:
id - a String specifying the id of the new page; also used as the relative pathname of the serialized version of the page.
name - a String specifying the page name.
pageService - The PageService object associated with this request. PackageName and PackageVersion will be obtained via the PageService.
template - a String specifying the relative path of the page's XSLT template.
pageData - A JDOM Document which represents the current page's data.
Method Detail

setId

public void setId(String id)
Description copied from interface: Page
Sets the id of this Page. In serialized form, the id is stored as an attribute of the top-level element of the page data.

Specified by:
setId in interface Page
Parameters:
id - a String containing the id of the page; id is also used as the relative path of the serialized page on disk.
See Also:
Page

getId

public String getId()
Description copied from interface: Page
Returns the id of this Page. In serialized form, the id is stored as an attribute of the top-level element of the page data.

Specified by:
getId in interface Page
Returns:
a String containing the Page's id.
See Also:
Page

setName

public void setName(String name)
Description copied from interface: Page
Sets the name of this Page. In serialized form, the name is stored as an attribute of the top-level element of the page data.

Specified by:
setName in interface Page
Parameters:
name - a String containing the name.
See Also:
Page

getName

public String getName()
Description copied from interface: Page
Returns the name of this Page. In serialized form, the name is stored as an attribute of the top-level element of the page data.

Specified by:
getName in interface Page
Returns:
a String containing the Page's name.
See Also:
Page

setType

public void setType(String type)
Description copied from interface: Page
Sets the type element of this page. In serialized form, type is stored as an attribute of the top-level element of the page data.

Specified by:
setType in interface Page
Parameters:
type - a String containing the the page type.
See Also:
Page

getType

public String getType()
Description copied from interface: Page
Returns the type of this page. In serialized form, type is stored as an attribute of the top-level element of the page data.

Specified by:
getType in interface Page
Returns:
a String containing the value of the root element's type attribute, or null if the the root element does not contain a type attribute.
See Also:
Page

setPackageName

public void setPackageName(String name)
Description copied from interface: Page
Sets the package name of this Page.

Specified by:
setPackageName in interface Page
Parameters:
name - a String containing the package name.
See Also:
Page

getPackageName

public String getPackageName()
Description copied from interface: Page
Returns the package name of this Page.

Specified by:
getPackageName in interface Page
Returns:
a String containing the package name.
See Also:
Page

setPackageVersion

public void setPackageVersion(String version)
Description copied from interface: Page
Sets the package version of this Page.

Specified by:
setPackageVersion in interface Page
Parameters:
version - a String containing the name.
See Also:
Page

getPackageVersion

public String getPackageVersion()
Description copied from interface: Page
Returns the package version of this Page.

Specified by:
getPackageVersion in interface Page
Returns:
a String containing the version.
See Also:
Page

setTemplate

public void setTemplate(String template)
Description copied from interface: Page
Sets the XSLT template of this Page.

Specified by:
setTemplate in interface Page
Parameters:
template - a String containing the the relative path of the page template.
See Also:
Page

setTemplateOverride

public void setTemplateOverride(String template)
Description copied from interface: Page
Sets a temporary template that overrides the value found in the Page. The template override will not be saved with the page, but will be returned by calls to getTemplate

Specified by:
setTemplateOverride in interface Page
Parameters:
template - a String containing the the relative path of the page template.
See Also:
Page

getLastSaveTime

public long getLastSaveTime()
Description copied from interface: Page
Gets the timestamp that the Page was last saved via the save() method. Note - this is not the same as the xml file's timestamp. If the page has never been saved via save(), this method will return 0. If the page has been loaded and saved, it will return the timestamp when the save() last occurred.

Specified by:
getLastSaveTime in interface Page
Returns:
a long value
See Also:
Page

setLastSaveTime

public void setLastSaveTime(long time)
Description copied from interface: Page
Sets the timestamp when the page was last saved. Last save time automatically gets set when save() is called. This method provides another way to set the time if the caller does not want to call save()

Specified by:
setLastSaveTime in interface Page
Parameters:
time - a long value
See Also:
Page

getTemplate

public String getTemplate()
Description copied from interface: Page
Returns the XSLT template of this Page.

Specified by:
getTemplate in interface Page
Returns:
a String containing the relative path of the template.
See Also:
Page

setDefaultType

public void setDefaultType(String type)
See Also:
Page

getDefaultType

public String getDefaultType()
Description copied from interface: Page
Returns the defaultPageType of this page, usually a section.

Specified by:
getDefaultType in interface Page
Returns:
a String containing the defaultPageType
See Also:
Page

isPageTypeSupported

public boolean isPageTypeSupported(String pageType)
Description copied from interface: Page
Indicates whether the specified page type may be contained by this page.

Specified by:
isPageTypeSupported in interface Page
Parameters:
pageType - a String containing the specified page type.
See Also:
Page

getSupportedPageTypes

public List getSupportedPageTypes()
Description copied from interface: Page
Returns a list of supported page types that this page may contain.

Specified by:
getSupportedPageTypes in interface Page
Returns:
a List containing the page types this page may contain.
See Also:
Page

setSupportedPageTypes

public void setSupportedPageTypes(List supportedPageTypes)
Description copied from interface: Page
Sets the supported page types this page may contain.

Specified by:
setSupportedPageTypes in interface Page
Parameters:
supportedPageTypes - a List containing the the page types supported by this page.
See Also:
Page

getCreateDate

public Date getCreateDate()
Description copied from interface: Page
Returns the page's create date.

Specified by:
getCreateDate in interface Page
Returns:
A Date specifying the create date of the page.
See Also:
Page

getProcessBody

public boolean getProcessBody()
Returns a boolean indicating whether or not this page is setup to honor page processing attributes (eg index, secure, reference ) on an individual element basis. The default is false.

Returns:
a boolean indicating whether or not this page processes element page attributes.

setProcessBody

public void setProcessBody(boolean processBody)
Sets the processBody attribute; a boolean value indicating whether or not element-specific page processing attributes ( eg index, secure, reference ) are enabled. The default is false.

Parameters:
processBody - a boolean indicating whether or not this page processes element-specific page attributes.

setPageData

public void setPageData(org.jdom.Document pageData)
Description copied from interface: Page
Sets the application specific XML page data.

Specified by:
setPageData in interface Page
Parameters:
pageData - a JDOM Document containing the application specific XML page data. The Page keeps a live reference to this Document; it is not copied.
See Also:
Page

getPageData

public org.jdom.Document getPageData()
Description copied from interface: Page
Returns the application specific XML page data.

Specified by:
getPageData in interface Page
Returns:
a JDOM Document containing the application-specific XML page data. The Document returned is a live document, and changes made to it will be reflected in the Page's copy.
See Also:
Page

setBaseDir

public void setBaseDir(String baseDir)
Description copied from interface: Page
Sets the base directory used when constructing absolute paths from a Page's name.

Specified by:
setBaseDir in interface Page
Parameters:
baseDir - String representing the base directory
See Also:
Page

unload

public void unload()
Description copied from interface: Page
Causes the page to unload it's page data so that it can be freed during GC.

Specified by:
unload in interface Page
See Also:
Page

getBaseDir

public File getBaseDir()
Description copied from interface: Page
Returns the base directory used when constructing absolute paths from a Page's name.

Specified by:
getBaseDir in interface Page
Returns:
a File object which points at the current Page's base directory.
See Also:
Page

setClassLoader

public void setClassLoader(ClassLoader cl)
Description copied from interface: Page
Sets the class loader of this page.

Specified by:
setClassLoader in interface Page
Parameters:
cl - a ClassLoader instance.
See Also:
Page

isLoaded

public boolean isLoaded()
Description copied from interface: Page
Returns true if the Page has been loaded from disk, or has had it's XML page data set directly by a call to setPageData().

Specified by:
isLoaded in interface Page
Returns:
a boolean indicating whether or not the Page's XML page data has been loaded.
See Also:
Page

isDeletable

public boolean isDeletable()
Description copied from interface: Page
Returns true if the Page is marked as deletable. This indicates that the Page can be deleted.

Specified by:
isDeletable in interface Page
Returns:
a boolean indicating whether or not the Page is deletable.
See Also:
Page

setDeletable

public void setDeletable(boolean isDeletable)
Description copied from interface: Page
Sets or clears the deletable attribute.

Specified by:
setDeletable in interface Page
Parameters:
isDeletable - a boolean indicating whether or not the page is deletable.
See Also:
Page

getBackup

public boolean getBackup()
Description copied from interface: Page
Returns true if the Page is marked to for backup.

Specified by:
getBackup in interface Page
Returns:
a boolean indicating whether or not the Page should be backed up.
See Also:
Page

setBackup

public void setBackup(boolean backup)
Description copied from interface: Page
Sets or clears the backup attribute.

Specified by:
setBackup in interface Page
Parameters:
backup - a boolean indicating whether or not the page should be automatically backed up to a .bak file.
See Also:
Page

isAutoSaveEnabled

public boolean isAutoSaveEnabled()
Description copied from interface: Page
Returns true if the Page has autoSave enabled. Default value is true

Specified by:
isAutoSaveEnabled in interface Page
Returns:
a boolean value
See Also:
Page

setAutoSaveEnabled

public void setAutoSaveEnabled(boolean autoSaveEnabled)
Description copied from interface: Page
Sets the state of the autoStateEnabled flag

Specified by:
setAutoSaveEnabled in interface Page
Parameters:
autoSaveEnabled - a boolean value
See Also:
Page

getForceAutoSave

public boolean getForceAutoSave()
Description copied from interface: Page
Get the state of the forceAutoSave flag. If true, this will force the auto save and program framework to save the page the next time such an event is triggered, regardless if other criteria (such as modified components) is met or not.

Specified by:
getForceAutoSave in interface Page
Returns:
a boolean value
See Also:
Page

setForceAutoSave

public void setForceAutoSave(boolean state)
Description copied from interface: Page
If true, this will force the auto save and program framework to save the page the next time such an event is triggered, regardless if other criteria (such as modified components) is met or not.

Specified by:
setForceAutoSave in interface Page
Parameters:
state - a boolean value
See Also:
Page

isReadOnly

public boolean isReadOnly()
Description copied from interface: Page
Returns true if the Page is marked as read-only. This indicates that the Page should not be modified. If save() is called on a page marked as read-only, the page will only be saved if it does not yet exist on disk; all subsequent save() calls are no-ops.

Specified by:
isReadOnly in interface Page
Returns:
a boolean indicating whether or not the Page is read-only.
See Also:
Page

setReadOnly

public void setReadOnly(boolean isReadOnly)
Description copied from interface: Page
Sets or clears the read-only attribute. If set to true, then this Page will only be saved to disk once, if it does not yet exist. Subsquent calls to save() will do nothing.

Specified by:
setReadOnly in interface Page
Parameters:
isReadOnly - a boolean indicating whether or not the page is read-only.
See Also:
Page

isHidden

public boolean isHidden()
Description copied from interface: Page
Returns true if the Page is marked as hidden. This indicates that the Page should never be shown

Specified by:
isHidden in interface Page
Returns:
a boolean indicating whether or not the Page is hidden.
See Also:
Page

setHidden

public void setHidden(boolean isHidden)
Description copied from interface: Page
Sets or clears the hidden attribute.

Specified by:
setHidden in interface Page
Parameters:
isHidden - a boolean indicating whether or not the page is hidden.
See Also:
Page

isSecure

public boolean isSecure()
Description copied from interface: Page
Returns true if the Page is marked as secure. This indicates that the Page <body> will be encrypted when saved to disk.

Specified by:
isSecure in interface Page
Returns:
a boolean indicating whether or not the Page is secure.
See Also:
Page

setSecure

public void setSecure(boolean isSecure)
Description copied from interface: Page
Sets or clears the secure attribute. If set to true, then the <body> of this page will be encrypted before it is written to disk.

Specified by:
setSecure in interface Page
Parameters:
isSecure - a boolean indicating whether or not the page is secure.
See Also:
Page

exists

public boolean exists()
Description copied from interface: Page
Returns true if the Page exists either in the original jar file or on disk

Specified by:
exists in interface Page
See Also:
Page

getRootAttrValue

public String getRootAttrValue(String attrName)
Description copied from interface: Page
Returns the value of the specified attribute on the root element (ie page, section) in the document

Specified by:
getRootAttrValue in interface Page
See Also:
Returns the value of the specified attribute on the root element (ie page, section) in the document

load

public org.jdom.Document load()
                       throws Exception
Description copied from interface: Page
Loads the Page from disk.

Specified by:
load in interface Page
Returns:
a reference to the Page's page data JDOM Document, or null if the page has not yet been loaded.
Throws:
Exception - if the page data is corrupted, or if the file cannot be read from disk.
See Also:
Page

save

public void save()
          throws Exception
Description copied from interface: Page
Causes the Page to be serialized to disk. Any elements with encrypt=true attributes are encrypted, and any elements with index=true attributes are indexed. The result is written to name.xml.

Specified by:
save in interface Page
Throws:
Exception - if the Page cannot be saved to disk.
See Also:
Page

toString

public String toString()
Debug method to dump contents of Page.

Overrides:
toString in class Object
Returns:
a String representing the page.

getNoCache

public int getNoCache()
Description copied from interface: Page
Get the value which controls how the page will be redisplayed when it has been previously loaded into a tab.

Specified by:
getNoCache in interface Page
Returns:
0 = always use cached version of page if page not modified (default), 1 = never use cached version of page, force reload on display 2 = force re-init of JavaScript bridge on page display
See Also:
Page

setNoCache

public void setNoCache(int options)
Description copied from interface: Page
Set the value which controls how the page will be redisplayed when it has been previously loaded into a tab.

Specified by:
setNoCache in interface Page
Parameters:
options - an int value 0 = always use cached version of page if page not modified (default), 1 = never use cached version of page, force reload on display 2 = force re-init of JavaScript bridge on page display
See Also:
Page


Copyright © 2006-2007 Pepper Computer, Inc. All Rights Reserved.