net.sf.navigator.menu
Class MenuRepository

java.lang.Object
  extended by net.sf.navigator.menu.MenuRepository
All Implemented Interfaces:
Serializable, LoadableResource

public class MenuRepository
extends Object
implements LoadableResource, Serializable

Holder of Menus and their items. Can be populated programmatically.

Author:
ssayles, mraible
See Also:
Serialized Form

Field Summary
protected  String config
           
protected  org.apache.commons.collections.map.LinkedMap displayers
           
static String MENU_REPOSITORY_KEY
           
protected  org.apache.commons.collections.map.LinkedMap menus
           
protected  String name
           
protected  javax.servlet.ServletContext servletContext
           
protected  org.apache.commons.collections.map.LinkedMap templates
           
 
Constructor Summary
MenuRepository()
           
 
Method Summary
 void addMenu(MenuComponent menu)
          Adds a new menu.
 void addMenuDisplayerMapping(MenuDisplayerMapping displayerMapping)
           
 void buildBreadCrumbs()
           
 void buildBreadCrumbs(String delimiter)
           
 org.apache.commons.collections.map.LinkedMap getDisplayers()
          This method is so menu repositories can retrieve displayers from the default repository specified in menu-config.xml
 String getLoadParam()
           
 MenuComponent getMenu(String menuName)
           
 MenuComponent getMenu(String menuName, String delimiter)
          Method getMenu.
 int getMenuDepth()
          Method getMenuDepth.
 int getMenuDepth(String menuName)
          Method getMenuDepth.
 MenuDisplayerMapping getMenuDisplayerMapping(String displayerName)
           
 Set getMenuNames()
           
 String getName()
           
 javax.servlet.ServletContext getServletContext()
           
 List getTopMenus()
          Convenience method for dynamic menus - returns the top-level menus only.
 MenuComponent[] getTopMenusAsArray()
          Method getTopMenusAsArray.
 List getTopMenusNames()
          Get a List of all the top menus' names
protected  org.apache.commons.digester.Digester initDigester()
           
 void load()
           
 void reload()
           
 void removeAllMenus()
          Allows easy removal of all menus, suggested use for users wanting to reload menus without having to perform a complete reload of the MenuRepository
 void removeMenu(String name)
          Allows easy removal of a menu by its name.
 void setBreadCrumbDelimiter(String string)
           
 void setDisplayers(org.apache.commons.collections.map.LinkedMap displayers)
          Allow the displayers to be set as a whole.
 void setLoadParam(String loadParam)
           
 void setName(String name)
           
 void setServletContext(javax.servlet.ServletContext context)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MENU_REPOSITORY_KEY

public static final String MENU_REPOSITORY_KEY
See Also:
Constant Field Values

config

protected String config

name

protected String name

servletContext

protected javax.servlet.ServletContext servletContext

menus

protected org.apache.commons.collections.map.LinkedMap menus

displayers

protected org.apache.commons.collections.map.LinkedMap displayers

templates

protected org.apache.commons.collections.map.LinkedMap templates
Constructor Detail

MenuRepository

public MenuRepository()
Method Detail

getMenuNames

public Set getMenuNames()

getTopMenus

public List getTopMenus()
Convenience method for dynamic menus - returns the top-level menus only.


getMenu

public MenuComponent getMenu(String menuName)

getMenuDisplayerMapping

public MenuDisplayerMapping getMenuDisplayerMapping(String displayerName)

initDigester

protected org.apache.commons.digester.Digester initDigester()

addMenu

public void addMenu(MenuComponent menu)
Adds a new menu. This is called when parsing the menu xml definition.

Parameters:
menu - The menu component to add.

removeMenu

public void removeMenu(String name)
Allows easy removal of a menu by its name.

Parameters:
name -

removeAllMenus

public void removeAllMenus()
Allows easy removal of all menus, suggested use for users wanting to reload menus without having to perform a complete reload of the MenuRepository


addMenuDisplayerMapping

public void addMenuDisplayerMapping(MenuDisplayerMapping displayerMapping)

getDisplayers

public org.apache.commons.collections.map.LinkedMap getDisplayers()
This method is so menu repositories can retrieve displayers from the default repository specified in menu-config.xml

Returns:
the displayers specified in this repository

setDisplayers

public void setDisplayers(org.apache.commons.collections.map.LinkedMap displayers)
Allow the displayers to be set as a whole. This should only be used when copying the displayers from the default repository to a newly created repository.

Parameters:
displayers -

load

public void load()
          throws LoadableResourceException
Specified by:
load in interface LoadableResource
Throws:
LoadableResourceException

reload

public void reload()
            throws LoadableResourceException
Specified by:
reload in interface LoadableResource
Throws:
LoadableResourceException

setLoadParam

public void setLoadParam(String loadParam)
Specified by:
setLoadParam in interface LoadableResource

getLoadParam

public String getLoadParam()
Specified by:
getLoadParam in interface LoadableResource

setName

public void setName(String name)
Specified by:
setName in interface LoadableResource

getName

public String getName()
Specified by:
getName in interface LoadableResource

getServletContext

public javax.servlet.ServletContext getServletContext()
Specified by:
getServletContext in interface LoadableResource

setServletContext

public void setServletContext(javax.servlet.ServletContext context)
Specified by:
setServletContext in interface LoadableResource

getMenu

public MenuComponent getMenu(String menuName,
                             String delimiter)
Method getMenu. Get a subMenu beneath a root or parent menu. Will drill-down as deep as requested

Parameters:
menuName - - e.g grandParent.parent.menu
delimiter - - e.g. '.'
Returns:
MenuComponent

getMenuDepth

public int getMenuDepth(String menuName)
Method getMenuDepth. Get the depth of the deepest sub-menu within the requested top menu

Parameters:
menuName - - name of the top menu to check the menu depth
Returns:
int. If no menuName found return -1

getMenuDepth

public int getMenuDepth()
Method getMenuDepth. Get the depth of the deepest sub-menu throughout all menus held in the repository

Returns:
int. If no menus return -1.

getTopMenusAsArray

public MenuComponent[] getTopMenusAsArray()
Method getTopMenusAsArray. Get menus as array rather than a List

Returns:
MenuComponent[]

getTopMenusNames

public List getTopMenusNames()
Get a List of all the top menus' names

Returns:
List

setBreadCrumbDelimiter

public void setBreadCrumbDelimiter(String string)

buildBreadCrumbs

public void buildBreadCrumbs()

buildBreadCrumbs

public void buildBreadCrumbs(String delimiter)


Copyright © 2003-2007 SourceForge. All Rights Reserved.