public class CmsJspNavElement extends java.lang.Object implements java.lang.Comparable<CmsJspNavElement>
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.
CmsJspNavBuilder
Modifier and Type | Field and Description |
---|---|
protected java.util.Locale |
m_locale
The locale for which the property should be read.
|
Constructor and Description |
---|
CmsJspNavElement()
Empty constructor required for every JavaBean, does nothing.
|
CmsJspNavElement(java.lang.String sitePath,
CmsResource resource,
java.util.Map<java.lang.String,java.lang.String> properties)
Create a new instance of the bean and calls the init method
with the provided parameters.
|
CmsJspNavElement(java.lang.String sitePath,
CmsResource resource,
java.util.Map<java.lang.String,java.lang.String> properties,
int navTreeLevel)
Create a new instance of the bean and calls the init method
with the provided parameters.
|
CmsJspNavElement(java.lang.String sitePath,
CmsResource resource,
java.util.Map<java.lang.String,java.lang.String> properties,
int navTreeLevel,
java.util.Locale locale)
Create a new instance of the bean and calls the init method
with the provided parameters.
|
CmsJspNavElement(java.lang.String sitePath,
java.util.Map<java.lang.String,java.lang.String> properties)
Deprecated.
|
CmsJspNavElement(java.lang.String sitePath,
java.util.Map<java.lang.String,java.lang.String> properties,
int navTreeLevel)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(CmsJspNavElement obj)
Note: this class has a natural ordering that is inconsistent with equals.
|
boolean |
equals(java.lang.Object obj)
Note: this class has a natural ordering that is inconsistent with equals.
|
java.lang.String |
getDescription()
Returns the value of the property PROPERTY_DESCRIPTION of this navigation element,
or
null if this property is not set. |
java.lang.String |
getFileName()
Returns the filename of the navigation element, i.e.
|
java.lang.String |
getInfo()
Returns the value of the property
of this
navigation element, or null if this property is not set. |
java.lang.String |
getLocale()
Returns the value of the property
of this
navigation element, or null if this property is not set. |
java.lang.String |
getNavImage()
Returns the value of the property
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. |
java.lang.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.
|
java.lang.String |
getParentFolderName()
Returns the name of the parent folder of the resource of this navigation element.
|
java.util.Map<java.lang.String,java.lang.String> |
getProperties()
Returns the original map of all file properties of the resource that
the navigation element belongs to.
|
java.lang.String |
getProperty(java.lang.String key)
Returns the value of the selected property from this navigation element.
|
CmsResource |
getResource()
Returns the resource.
|
java.lang.String |
getResourceName()
Returns the resource name this navigation element was initialized with.
|
protected java.lang.String |
getSitePath()
Returns the site path of the target resource.
|
java.lang.String |
getTitle()
Returns the value of the property PROPERTY_TITLE of this navigation element,
or
null if this property is not set. |
boolean |
hasChangedNavPosition()
Returns if the navigation position has been changed since initialization.
|
int |
hashCode()
Note: this class has a natural ordering that is inconsistent with equals.
|
void |
init(java.lang.String resource,
java.util.Map<java.lang.String,java.lang.String> properties)
Same as calling
init(String, Hashtable, -1, null) . |
void |
init(java.lang.String resource,
java.util.Map<java.lang.String,java.lang.String> properties,
int navTreeLevel)
Initialized the member variables of this bean with the values
provided.
|
void |
init(java.lang.String resource,
java.util.Map<java.lang.String,java.lang.String> properties,
int navTreeLevel,
java.util.Locale locale)
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 |
isHiddenNavigationEntry()
Returns if this is a hidden navigation entry.
|
boolean |
isInNavigation()
Returns
true if this navigation element is in the navigation,
false otherwise. |
boolean |
isNavigationLevel()
Returns if the navigation element represents a navigation level, linking to it's first sub-element.
|
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.
|
protected java.util.Locale m_locale
public CmsJspNavElement()
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.
public CmsJspNavElement(java.lang.String sitePath, CmsResource resource, java.util.Map<java.lang.String,java.lang.String> properties)
sitePath
- will be passed to init
resource
- the resourceproperties
- will be passed to init
public CmsJspNavElement(java.lang.String sitePath, CmsResource resource, java.util.Map<java.lang.String,java.lang.String> properties, int navTreeLevel)
sitePath
- will be passed to init
resource
- the resourceproperties
- will be passed to init
navTreeLevel
- will be passed to init
init(String, Map, int, Locale)
public CmsJspNavElement(java.lang.String sitePath, CmsResource resource, java.util.Map<java.lang.String,java.lang.String> properties, int navTreeLevel, java.util.Locale locale)
sitePath
- will be passed to init
resource
- the resourceproperties
- will be passed to init
navTreeLevel
- will be passed to init
locale
- the locale for which properties should be accessed.init(String, Map, int, Locale)
@Deprecated public CmsJspNavElement(java.lang.String sitePath, java.util.Map<java.lang.String,java.lang.String> properties)
CmsJspNavElement(String, CmsResource, Map)
sitePath
- will be passed to init
properties
- will be passed to init
init(String, Map)
@Deprecated public CmsJspNavElement(java.lang.String sitePath, java.util.Map<java.lang.String,java.lang.String> properties, int navTreeLevel)
CmsJspNavElement(String, CmsResource, Map, int)
sitePath
- will be passed to init
properties
- will be passed to init
navTreeLevel
- will be passed to init
init(String, Map, int, Locale)
public int compareTo(CmsJspNavElement obj)
compareTo
in interface java.lang.Comparable<CmsJspNavElement>
Comparable.compareTo(Object)
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
Object.equals(Object)
public java.lang.String getDescription()
null
if this property is not set.null
if this property is not setpublic java.lang.String getFileName()
public java.lang.String getInfo()
CmsPropertyDefinition.PROPERTY_NAVINFO
of this
navigation element, or null
if this property is not set.null
if this property is not setpublic java.lang.String getLocale()
CmsPropertyDefinition.PROPERTY_LOCALE
of this
navigation element, or null
if this property is not set.null
if this property is not setpublic java.lang.String getNavImage()
CmsPropertyDefinition.PROPERTY_NAVIMAGE
of this
navigation element, or null
if this property is not set.null
if this property is not setpublic float getNavPosition()
float
,
or a value of Float.MAX_VALUE
if the navigation position property is not
set (or not a valid number) for this resource.float
,
or a value of Float.MAX_VALUE
if the navigation position property is not
set (or not a valid number) for this resourcepublic java.lang.String getNavText()
null
).null
)public int getNavTreeLevel()
public java.lang.String getParentFolderName()
public java.util.Map<java.lang.String,java.lang.String> getProperties()
Please note that the original reference is returned, so be careful when making changes to the map.
public java.lang.String getProperty(java.lang.String key)
The navigation element contains a hash of all file properties of the resource that the navigation element belongs to.
key
- the property name to look uppublic CmsResource getResource()
public java.lang.String getResourceName()
public java.lang.String getTitle()
null
if this property is not set.null
if this property is not setpublic boolean hasChangedNavPosition()
true
if the navigation position has been changed since initializationpublic int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
public void init(java.lang.String resource, java.util.Map<java.lang.String,java.lang.String> properties)
init(String, Hashtable, -1, null)
.resource
- the name of the resource to extract the navigation
information fromproperties
- the properties of the resource read from the vfspublic void init(java.lang.String resource, java.util.Map<java.lang.String,java.lang.String> properties, int navTreeLevel)
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.
resource
- the name of the resource to extract the navigation
information fromproperties
- the properties of the resource read from the vfsnavTreeLevel
- tree level of this resource, for building
navigation treesCmsJspNavBuilder.getNavigationForResource()
public void init(java.lang.String resource, java.util.Map<java.lang.String,java.lang.String> properties, int navTreeLevel, java.util.Locale locale)
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.
resource
- the name of the resource to extract the navigation
information fromproperties
- the properties of the resource read from the vfsnavTreeLevel
- tree level of this resource, for building
navigation treeslocale
- The locale for which properties should be accessed.CmsJspNavBuilder.getNavigationForResource()
public boolean isFolderLink()
true
if this navigation element describes a folder,
false
otherwise.true
if this navigation element describes a folder,
false
otherwise.public boolean isHiddenNavigationEntry()
true
if this is a hidden navigation entrypublic boolean isInNavigation()
true
if this navigation element is in the navigation,
false
otherwise.A resource is considered to be in the navigation, if
CmsResource.isTemporaryFileName(String)
.true
if this navigation element is in the navigation, false
otherwisepublic boolean isNavigationLevel()
true
if the navigation element represents a navigation levelpublic void setNavPosition(float value)
getNavPosition()
method of this class.value
- the value to setprotected java.lang.String getSitePath()
protected void setResource(CmsResource resource)
resource
- the resource to set