com.opencms.flex.jsp
Class CmsJspNavElement

java.lang.Object
  |
  +--com.opencms.flex.jsp.CmsJspNavElement
All Implemented Interfaces:
java.lang.Comparable

public class CmsJspNavElement
extends java.lang.Object
implements java.lang.Comparable

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

Version:
$Revision: 1.12 $
Author:
Alexander Kandzior (a.kandzior@alkacon.com)

Field Summary
static java.lang.String C_PROPERTY_LOCALE
          Property constant for "locale"
static java.lang.String C_PROPERTY_NAVIMAGE
          Property constant for "NavImage"
static java.lang.String C_PROPERTY_NAVINFO
          Property constant for "NavInfo"
 
Constructor Summary
CmsJspNavElement()
          Empty constructor required for every JavaBean, does nothing.
CmsJspNavElement(java.lang.String resource, java.util.Map properties)
          Create a new instance of the bean and calls the init method with the provided parametes.
CmsJspNavElement(java.lang.String resource, java.util.Map properties, int navTreeLevel)
          Create a new instance of the bean and calls the init method with the provided parametes.
 
Method Summary
 int compareTo(java.lang.Object o)
           
 boolean equals(java.lang.Object o)
           
 java.lang.String getDescription()
          Returns the value of the property C_PROPERTY_DESCRIPTION of this nav element, or null if this property is not set.
 java.lang.String getFileName()
          Returns the filename of the nav element, i.e.
 java.lang.String getInfo()
          Returns the value of the property C_PROPERTY_NAVINFO of this nav element, or null if this property is not set.
 java.lang.String getLocale()
          Returns the value of the property C_PROPERTY_LOCALE of this nav element, or null if this property is not set.
 java.lang.String getNavImage()
          Returns the value of the property C_PROPERTY_NAVIMAGE of this nav 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 nav position property is not set (or not a valid number) for this resource.
 java.lang.String getNavText()
          Returns the value of the property C_PROPERTY_NAVTEXT of this nav element, or a warning message if this property is not set (this method will never return null).
 int getNavTreeLevel()
          Returns the nav tree level of this resource.
 java.lang.String getParentFolderName()
          Returns the name of the parent folder of the resource of this nav element,
 java.util.Map getProperties()
          Returns the original Hashtable of all file properties of the resource that the nav element belongs to.
 java.lang.String getProperty(java.lang.String key)
          Returns the value of the selected property from this nav element.
 java.lang.String getResourceName()
          Returns the resource name this nav element was initalized with.
 java.lang.String getTitle()
          Returns the value of the property C_PROPERTY_TITLE of this nav element, or null if this property is not set.
 void init(java.lang.String resource, java.util.Map properties)
          Same as calling init(String, Hashtable, -1).
 void init(java.lang.String resource, java.util.Map properties, int navTreeLevel)
          Initialized the member variables of this bean with the values provided.
 boolean isFolderLink()
          Returns true if this nav element describes a folder, false otherwise.
 boolean isInNavigation()
          Returns true if this nav 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.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

C_PROPERTY_LOCALE

public static final java.lang.String C_PROPERTY_LOCALE
Property constant for "locale"

See Also:
Constant Field Values

C_PROPERTY_NAVIMAGE

public static final java.lang.String C_PROPERTY_NAVIMAGE
Property constant for "NavImage"

See Also:
Constant Field Values

C_PROPERTY_NAVINFO

public static final java.lang.String C_PROPERTY_NAVINFO
Property constant for "NavInfo"

See Also:
Constant Field Values
Constructor Detail

CmsJspNavElement

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

Call one of the init methods afer 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:
(String), (String), (String, String), (String, int, String), (String, int, int, String)

CmsJspNavElement

public CmsJspNavElement(java.lang.String resource,
                        java.util.Map properties)
Create a new instance of the bean and calls the init method with the provided parametes.

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

CmsJspNavElement

public CmsJspNavElement(java.lang.String resource,
                        java.util.Map properties,
                        int navTreeLevel)
Create a new instance of the bean and calls the init method with the provided parametes.

Parameters:
resource - 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

init

public void init(java.lang.String resource,
                 java.util.Map 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(java.lang.String resource,
                 java.util.Map properties,
                 int navTreeLevel)
Initialized the member variables of this bean with the values provided.

A resource will be in the nav if at least one of the two properties I_CmsConstants.C_PROPERTY_NAVTEXT or I_CmsConstants.C_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:
(String)

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable
See Also:
Comparable.compareTo(Object)

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(Object)

getNavTreeLevel

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

Returns:
int the nav tree level of this resource

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 nav 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 nav position property is not set (or not a valid number) for this resource

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

getResourceName

public java.lang.String getResourceName()
Returns the resource name this nav element was initalized with.

Returns:
the resource name this nav element was initalized with

getFileName

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

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

getParentFolderName

public java.lang.String getParentFolderName()
Returns the name of the parent folder of the resource of this nav element,

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

getNavText

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

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

getTitle

public java.lang.String getTitle()
Returns the value of the property C_PROPERTY_TITLE of this nav element, or null if this property is not set.

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

getInfo

public java.lang.String getInfo()
Returns the value of the property C_PROPERTY_NAVINFO of this nav element, or null if this property is not set.

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

getLocale

public java.lang.String getLocale()
Returns the value of the property C_PROPERTY_LOCALE of this nav element, or null if this property is not set.

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

getNavImage

public java.lang.String getNavImage()
Returns the value of the property C_PROPERTY_NAVIMAGE of this nav element, or null if this property is not set.

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

getDescription

public java.lang.String getDescription()
Returns the value of the property C_PROPERTY_DESCRIPTION of this nav element, or null if this property is not set.

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

isInNavigation

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

A resource is considered to be in the navigation, if

  1. it has the property C_PROPERTY_NAVTEXT set
  2. or it has the property C_PROPERTY_NAVPOS set
  3. and it is not a temporary file that contains a '~' in it's filename.

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

isFolderLink

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

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


getProperty

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

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

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

getProperties

public java.util.Map getProperties()
Returns the original Hashtable of all file properties of the resource that the nav element belongs to.

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

Returns:
the original Hashtable of all file properties of the resource that the nav element belongs to