org.opencms.jsp
Class CmsJspNavElement

java.lang.Object
  extended by org.opencms.jsp.CmsJspNavElement
All Implemented Interfaces:
Comparable<CmsJspNavElement>

public class CmsJspNavElement
extends Object
implements Comparable<CmsJspNavElement>

Bean to collect navigation information from a resource in the OpenCms VFS.

Each navigation element contains a number of information about a VFS resource, obtained either from the resources properties or attributes. You can use this information to generate a HTML navigation for files in the VFS in your template.

Note: this class has a natural ordering that is inconsistent with equals.

Since:
6.0.0
See Also:
CmsJspNavBuilder

Constructor Summary
CmsJspNavElement()
          Empty constructor required for every JavaBean, does nothing.
CmsJspNavElement(String sitePath, CmsResource resource, Map<String,String> properties)
          Create a new instance of the bean and calls the init method with the provided parameters.
CmsJspNavElement(String sitePath, CmsResource resource, Map<String,String> properties, int navTreeLevel)
          Create a new instance of the bean and calls the init method with the provided parameters.
CmsJspNavElement(String sitePath, Map<String,String> properties)
          Deprecated. use CmsJspNavElement(String, CmsResource, Map)
CmsJspNavElement(String sitePath, Map<String,String> properties, int navTreeLevel)
          Deprecated. use CmsJspNavElement(String, CmsResource, Map, int)
 
Method Summary
 int compareTo(CmsJspNavElement obj)
          Note: this class has a natural ordering that is inconsistent with equals.
 boolean equals(Object obj)
          Note: this class has a natural ordering that is inconsistent with equals.
 String getDescription()
          Returns the value of the property PROPERTY_DESCRIPTION of this navigation element, or null if this property is not set.
 String getFileName()
          Returns the filename of the navigation element, i.e.
 String getInfo()
          Returns the value of the property CmsPropertyDefinition.PROPERTY_NAVINFO of this navigation element, or null if this property is not set.
 String getLocale()
          Returns the value of the property CmsPropertyDefinition.PROPERTY_LOCALE of this navigation element, or null if this property is not set.
 String getNavImage()
          Returns the value of the property CmsPropertyDefinition.PROPERTY_NAVIMAGE of this navigation element, or null if this property is not set.
 float getNavPosition()
          Returns the value of the property C_PROPERTY_NAVPOS converted to a float, or a value of Float.MAX_VALUE if the navigation position property is not set (or not a valid number) for this resource.
 String getNavText()
          Returns the value of the property PROPERTY_NAVTEXT of this navigation element, or a warning message if this property is not set (this method will never return null).
 int getNavTreeLevel()
          Returns the navigation tree level of this resource.
 String getParentFolderName()
          Returns the name of the parent folder of the resource of this navigation element.
 Map<String,String> getProperties()
          Returns the original map of all file properties of the resource that the navigation element belongs to.
 String getProperty(String key)
          Returns the value of the selected property from this navigation element.
 CmsResource getResource()
          Returns the resource.
 String getResourceName()
          Returns the resource name this navigation element was initialized with.
 String getTitle()
          Returns the value of the property PROPERTY_TITLE of this navigation element, or null if this property is not set.
 boolean hasChangedNavPosition()
           
 int hashCode()
          Note: this class has a natural ordering that is inconsistent with equals.
 void init(String resource, Map<String,String> properties)
          Same as calling init(String, Hashtable, -1).
 void init(String resource, Map<String,String> properties, int navTreeLevel)
          Initialized the member variables of this bean with the values provided.
 boolean isFolderLink()
          Returns true if this navigation element describes a folder, false otherwise.
 boolean isInNavigation()
          Returns true if this navigation element is in the navigation, false otherwise.
 void setNavPosition(float value)
          Sets the value that will be returned by the getNavPosition() method of this class.
protected  void setResource(CmsResource resource)
          Sets the resource.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CmsJspNavElement

public CmsJspNavElement()
Empty constructor required for every JavaBean, does nothing.

Call one of the init methods after you have created an instance of the bean. Instead of using the constructor you should use the static factory methods provided by this class to create navigation beans that are properly initialized with current OpenCms context.

See Also:
CmsJspNavBuilder.getNavigationForResource(), CmsJspNavBuilder.getNavigationForFolder(), CmsJspNavBuilder.getNavigationTreeForFolder(int, int)

CmsJspNavElement

public CmsJspNavElement(String sitePath,
                        CmsResource resource,
                        Map<String,String> properties)
Create a new instance of the bean and calls the init method with the provided parameters.

Parameters:
sitePath - will be passed to init
resource - the resource
properties - will be passed to init

CmsJspNavElement

public CmsJspNavElement(String sitePath,
                        CmsResource resource,
                        Map<String,String> properties,
                        int navTreeLevel)
Create a new instance of the bean and calls the init method with the provided parameters.

Parameters:
sitePath - will be passed to init
resource - the resource
properties - will be passed to init
navTreeLevel - will be passed to init
See Also:
init(String, Map, int)

CmsJspNavElement

@Deprecated
public CmsJspNavElement(String sitePath,
                                   Map<String,String> properties)
Deprecated. use CmsJspNavElement(String, CmsResource, Map)

Create a new instance of the bean and calls the init method with the provided parameters.

Parameters:
sitePath - will be passed to init
properties - will be passed to init
See Also:
init(String, Map)

CmsJspNavElement

@Deprecated
public CmsJspNavElement(String sitePath,
                                   Map<String,String> properties,
                                   int navTreeLevel)
Deprecated. use CmsJspNavElement(String, CmsResource, Map, int)

Create a new instance of the bean and calls the init method with the provided parameters.

Parameters:
sitePath - will be passed to init
properties - will be passed to init
navTreeLevel - will be passed to init
See Also:
init(String, Map, int)
Method Detail

compareTo

public int compareTo(CmsJspNavElement obj)
Note: this class has a natural ordering that is inconsistent with equals.

Specified by:
compareTo in interface Comparable<CmsJspNavElement>
See Also:
Comparable.compareTo(Object)

equals

public boolean equals(Object obj)
Note: this class has a natural ordering that is inconsistent with equals.

Overrides:
equals in class Object
See Also:
Object.equals(Object)

getDescription

public String getDescription()
Returns the value of the property PROPERTY_DESCRIPTION of this navigation element, or null if this property is not set.

Returns:
the value of the property PROPERTY_DESCRIPTION of this navigation element or null if this property is not set

getFileName

public String getFileName()
Returns the filename of the navigation element, i.e. the name of the navigation resource without any path information.

Returns:
the filename of the navigation element, i.e. the name of the navigation resource without any path information

getInfo

public String getInfo()
Returns the value of the property CmsPropertyDefinition.PROPERTY_NAVINFO of this navigation element, or null if this property is not set.

Returns:
the value of the property or null if this property is not set

getLocale

public String getLocale()
Returns the value of the property CmsPropertyDefinition.PROPERTY_LOCALE of this navigation element, or null if this property is not set.

Returns:
the value of the property or null if this property is not set

getNavImage

public String getNavImage()
Returns the value of the property CmsPropertyDefinition.PROPERTY_NAVIMAGE of this navigation element, or null if this property is not set.

Returns:
the value of the property or null if this property is not set

getNavPosition

public float getNavPosition()
Returns the value of the property C_PROPERTY_NAVPOS converted to a float, or a value of Float.MAX_VALUE if the navigation position property is not set (or not a valid number) for this resource.

Returns:
float the value of the property C_PROPERTY_NAVPOS converted to a float, or a value of Float.MAX_VALUE if the navigation position property is not set (or not a valid number) for this resource

getNavText

public String getNavText()
Returns the value of the property PROPERTY_NAVTEXT of this navigation element, or a warning message if this property is not set (this method will never return null).

Returns:
the value of the property PROPERTY_NAVTEXT of this navigation element, or a warning message if this property is not set (this method will never return null)

getNavTreeLevel

public int getNavTreeLevel()
Returns the navigation tree level of this resource.

Returns:
the navigation tree level of this resource

getParentFolderName

public String getParentFolderName()
Returns the name of the parent folder of the resource of this navigation element.

Returns:
the name of the parent folder of the resource of this navigation element

getProperties

public Map<String,String> getProperties()
Returns the original map of all file properties of the resource that the navigation element belongs to.

Please note that the original reference is returned, so be careful when making changes to the map.

Returns:
the original map of all file properties of the resource that the navigation element belongs to

getProperty

public String getProperty(String key)
Returns the value of the selected property from this navigation element.

The navigation element contains a hash of all file properties of the resource that the navigation element belongs to.

Parameters:
key - the property name to look up
Returns:
the value of the selected property

getResource

public CmsResource getResource()
Returns the resource.

Returns:
the resource

getResourceName

public String getResourceName()
Returns the resource name this navigation element was initialized with.

Returns:
the resource name this navigation element was initialized with

getTitle

public String getTitle()
Returns the value of the property PROPERTY_TITLE of this navigation element, or null if this property is not set.

Returns:
the value of the property PROPERTY_TITLE of this navigation element or null if this property is not set

hasChangedNavPosition

public boolean hasChangedNavPosition()

hashCode

public int hashCode()
Note: this class has a natural ordering that is inconsistent with equals.

Overrides:
hashCode in class Object
See Also:
Object.hashCode()

init

public void init(String resource,
                 Map<String,String> properties)
Same as calling init(String, Hashtable, -1).

Parameters:
resource - the name of the resource to extract the navigation information from
properties - the properties of the resource read from the vfs

init

public void init(String resource,
                 Map<String,String> properties,
                 int navTreeLevel)
Initialized the member variables of this bean with the values provided.

A resource will be in the navigation if at least one of the two properties I_CmsConstants.PROPERTY_NAVTEXT or I_CmsConstants.PROPERTY_NAVPOS is set. Otherwise it will be ignored.

This bean does provides static methods to create a new instance from the context of a current CmsObject. Call these static methods in order to get a properly initialized bean.

Parameters:
resource - the name of the resource to extract the navigation information from
properties - the properties of the resource read from the vfs
navTreeLevel - tree level of this resource, for building navigation trees
See Also:
CmsJspNavBuilder.getNavigationForResource()

isFolderLink

public boolean isFolderLink()
Returns true if this navigation element describes a folder, false otherwise.

Returns:
true if this navigation element describes a folder, false otherwise.


isInNavigation

public boolean isInNavigation()
Returns true if this navigation element is in the navigation, false otherwise.

A resource is considered to be in the navigation, if

  1. it has the property PROPERTY_NAVTEXT set
  2. or it has the property PROPERTY_NAVPOS set
  3. and it is not a temporary file as defined by CmsResource.isTemporaryFileName(String).

Returns:
true if this navigation element is in the navigation, false otherwise

setNavPosition

public void setNavPosition(float value)
Sets the value that will be returned by the getNavPosition() method of this class.

Parameters:
value - the value to set

setResource

protected void setResource(CmsResource resource)
Sets the resource.

Parameters:
resource - the resource to set