net.sf.tacos.services.impl
Class SiteMapImpl

java.lang.Object
  extended by net.sf.tacos.services.impl.SiteMapImpl
All Implemented Interfaces:
SiteMap

public class SiteMapImpl
extends Object
implements SiteMap

This class reads the sitemap configuration, and provides access to basic relationship information, such as page categories, bread crumbs, and other information, that the application may need to ease navigation.

Author:
Gabriel Handford

Constructor Summary
SiteMapImpl()
          Empty constructor.
 
Method Summary
 boolean contains(String parentName, String pageName)
          Check if page name is contained in the page element tree.
protected  org.dom4j.Element findPageNode(String page)
          Finds the specified page node in the sitemap, first trying to find it by name and then path.
 List getBreadCrumbs(String pageName)
          Get bread crumbs.
 List getCategories()
          Get category listing.
 CategoryInfo getCategoryFromPage(String pageName)
          Get the category info for the page name.
 CategoryInfo getCategoryInfo(String name)
          Get category info for named category.
 List getCategoryPages(String pageName)
          Get pages for a specific page names category.
 PageInfo getDefaultPage(String category)
          Get the default page.
 String getDefaultPageDesc(String category)
          Get the default page description.
 PageInfo getPageInfo(String name)
          Get page information.
 boolean inCategory(String pageName, String category)
          Check if page name is in the specified category.
 void initialize()
          Initialize site map from a url (xml document).
protected  void parseNodeTree(PageInfo page, org.dom4j.Node pageNode)
          Iterates through the category tree represented by this page node and parses all children and parents.
protected  PageInfo parsePageNode(org.dom4j.Element node)
          Parses a particular page node, doesn't parse children or parent of PageInfo.
protected  PageInfo parsePageNodes(org.dom4j.Node parent, PageInfo source)
          Parses all children of specified node and adds them to the page cache.
 void setResource(Resource resource)
          Set the sitemap resource (xml).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SiteMapImpl

public SiteMapImpl()
Empty constructor.

Method Detail

setResource

public void setResource(Resource resource)
Set the sitemap resource (xml).

Parameters:
resource - The resource (xml) file

initialize

public void initialize()
                throws org.dom4j.DocumentException
Initialize site map from a url (xml document).

Parameters:
document -
Throws:
org.dom4j.DocumentException - on error
IllegalStateException - If no resource has been set.

contains

public boolean contains(String parentName,
                        String pageName)
Check if page name is contained in the page element tree.

Specified by:
contains in interface SiteMap
Parameters:
parentName - The page to look for.
pageName - The page to start at (moves bottom-up).
Returns:
True if the parent contains the page in its tree.

getPageInfo

public PageInfo getPageInfo(String name)
Get page information.

Specified by:
getPageInfo in interface SiteMap
Parameters:
name - The page name
Returns:
The page info

findPageNode

protected org.dom4j.Element findPageNode(String page)
Finds the specified page node in the sitemap, first trying to find it by name and then path.

Parameters:
page -
Returns:
The page, or null if not found.

parsePageNode

protected PageInfo parsePageNode(org.dom4j.Element node)
Parses a particular page node, doesn't parse children or parent of PageInfo.

Parameters:
node - Node to parse.
Returns:

parseNodeTree

protected void parseNodeTree(PageInfo page,
                             org.dom4j.Node pageNode)
Iterates through the category tree represented by this page node and parses all children and parents.

Parameters:
page - The page that caused the tree parse
pageNode -

parsePageNodes

protected PageInfo parsePageNodes(org.dom4j.Node parent,
                                  PageInfo source)
Parses all children of specified node and adds them to the page cache.

Parameters:
parent -
source - Page that caused the original parse.
Returns:
The parent node that was parsed.

getCategories

public List getCategories()
Get category listing.

Specified by:
getCategories in interface SiteMap
Returns:
The category list

getCategoryInfo

public CategoryInfo getCategoryInfo(String name)
Get category info for named category.

Specified by:
getCategoryInfo in interface SiteMap
Parameters:
name - Category name
Returns:
The category info
See Also:
SiteMap.getCategoryInfo(java.lang.String)

getCategoryFromPage

public CategoryInfo getCategoryFromPage(String pageName)
Get the category info for the page name.

Specified by:
getCategoryFromPage in interface SiteMap
Parameters:
pageName - The page name.
Returns:
The first category associated with this page.

inCategory

public boolean inCategory(String pageName,
                          String category)
Check if page name is in the specified category.

Specified by:
inCategory in interface SiteMap
Parameters:
pageName - Page name
category - Category
Returns:
True if in the specified category

getDefaultPage

public PageInfo getDefaultPage(String category)
Get the default page.

Specified by:
getDefaultPage in interface SiteMap
Parameters:
category - Category
Returns:
Default page

getCategoryPages

public List getCategoryPages(String pageName)
Get pages for a specific page names category.

Specified by:
getCategoryPages in interface SiteMap
Parameters:
pageName - Page name
Returns:
Pages

getDefaultPageDesc

public String getDefaultPageDesc(String category)
Get the default page description.

Specified by:
getDefaultPageDesc in interface SiteMap
Parameters:
category - Category
Returns:
Category default page description

getBreadCrumbs

public List getBreadCrumbs(String pageName)
Get bread crumbs.

Specified by:
getBreadCrumbs in interface SiteMap
Parameters:
pageName - The page name.
Returns:
The bread crumbs (page name list).