|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opencms.file.collectors.CmsDateResourceComparator
public class CmsDateResourceComparator
Comparator for sorting resource objects based on dates.
The comparator can be configured to use any date based on resource attributes or properties.
The user must in the constructor CmsDateResourceComparator(CmsObject, List, boolean)
provide a list of one or more date identifiers that should be checked, in the order they
should be checked. This list of dates identifiers must be Strings which tell the comparator which dates to use.
The first valid date identifier that is found for a resource is used as date for
comparing this resource to other resources.
The following date identifiers can be used
to access the corresponding value of a CmsResource
:
"dateCreated"
, which means CmsResource.getDateCreated()
.
"dateLastModified"
, which means CmsResource.getDateLastModified()
.
"dateContent"
, which means CmsResource.getDateContent()
.
"dateReleased"
, which means CmsResource.getDateReleased()
.
"dateExpired"
, which means CmsResource.getDateExpired()
.
CmsResource.getDateCreated()
is used as default.
Comparator
for resources and as comparator key for the resource
at the same time. Uses lazy initializing of comparator keys for a resource.
Field Summary | |
---|---|
static java.util.List |
DATE_ATTRIBUTES_LIST
Possible keywords to read dates from the resource attributes in a List. |
Constructor Summary | |
---|---|
CmsDateResourceComparator(CmsObject cms,
java.util.List dateIdentifiers,
boolean asc)
Creates a new instance of this comparator key. |
Method Summary | |
---|---|
static long |
calculateDate(CmsObject cms,
CmsResource resource,
java.util.List dateIdentifiers,
long defaultValue)
Calculates the date to use for comparison of this resource based on the given date identifiers. |
int |
compare(java.lang.Object arg0,
java.lang.Object arg1)
|
long |
getDate()
Returns the date of this resource comparator key. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Comparator |
---|
equals |
Field Detail |
---|
public static final java.util.List DATE_ATTRIBUTES_LIST
Constructor Detail |
---|
public CmsDateResourceComparator(CmsObject cms, java.util.List dateIdentifiers, boolean asc)
cms
- the current OpenCms user contextdateIdentifiers
- the names of the dates to checkasc
- if true, the date sort order is ascending, otherwise descendingMethod Detail |
---|
public static long calculateDate(CmsObject cms, CmsResource resource, java.util.List dateIdentifiers, long defaultValue)
cms
- the current OpenCms user contextresource
- the resource to create the key fordateIdentifiers
- the date identifiers to use for selecting the datedefaultValue
- the default value to use in case no value can be calculated
for a description about how the date identifieres are used
public int compare(java.lang.Object arg0, java.lang.Object arg1)
compare
in interface java.util.Comparator
Comparator.compare(java.lang.Object, java.lang.Object)
public long getDate()
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |