|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jalios.jcms.comparator.ComparatorManager
public class ComparatorManager
Manager of all Comparators used in JCMS to sort Storable instances and their subclass.
You can declare a comparator in properties by following this syntax :
comparator.{Type short name}.{comparator name}: {comparator class Fully Qualified Name}Example :
comparator.Article.intro: com.example.jcmsplugin.ArticleIntroComparator
When working with classes outside the generated package (such as Abstract class), the fully
qualified name associated with {Type short name}
is required and must be declared
using this syntax :
comparator.{Type short name}: {type class Fully Qualified Name}Example :
comparator.AbstractCalendarEvent: com.jalios.jcms.calendar.AbstractCalendarEvent comparator.AbstractCalendarEvent.duration: com.example.jcmsplugin.CalendarEventDurationComparator
public class CalendarEventDurationComparatorimplements Comparator { public int compare(T cal1, T cal2) { long cal1Duration = cal1 == null ? 0 : (cal1.getEndDate().getTime() - cal1.getStartDate().getTime()); long cal2Duration = cal2 == null ? 0 : (cal2.getEndDate().getTime() - cal2.getStartDate().getTime()); long diff = cal2Duration - cal1Duration; return diff != 0 ? (int) diff : IdComparator.compareStorableId(cal1, cal2); } }
Portlet Query Foreach comparators :
Custom Comparators can be added to Portlet Query Foreach edit form.
To add your comparator, declare I18N labels in your plugin language properties by following this syntax :
comparator.pqf.{comparator name}: My ComparatorWarning : You MUST ensure that your comparator name does not conflicts with any existing comparator declared for
Publication
type.
The order of comparators displayed in the sort menu of the Portlet Query Foreach edit form can be controlled by modifying the following property
# Comparator order for Portlet Query Foreach comparator-pqf.prefered-order: \ cdate mdate pdate edate sdate adate udate \ title author opauthor rating workspace reader \ reviewCount type pstatus contentType dimensions size duration
Field Summary |
---|
Fields inherited from interface com.jalios.util.JPropertiesListener |
---|
REVISION |
Method Summary | ||
---|---|---|
static
|
getComparator(Class<T> clazz,
String comparatorName)
Retrieve a new Comparator from its short identifier to sort instances of the specified class. |
|
static
|
getComparator(Class<T> typeClazz,
String comparatorName,
boolean reverse)
Retrieve a new Comparator from its short identifier to sort instances of the specified class. |
|
static
|
getComparator(Class<T> typeClazz,
String comparatorName,
boolean reverse,
Map<String,Object> contextMap)
Retrieve a new Comparator from its short identifier to sort instances of the specified class. |
|
static ComparatorManager |
getInstance()
|
|
void |
loadComparators()
Reload comparator from properties. |
|
void |
overridePortletQueryForeachOrders()
|
|
void |
propertiesChange(JProperties properties)
Invoked after properties have been modified in JCMS and save on disk. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static ComparatorManager getInstance()
public void propertiesChange(JProperties properties)
JPropertiesListener
You cannot alter the value received in parameters.
propertiesChange
in interface JPropertiesListener
properties
- the properties which have been modified (may not contain all JCMS properties)public void loadComparators()
public void overridePortletQueryForeachOrders()
public static <T extends Storable> Comparator<? super T> getComparator(Class<T> clazz, String comparatorName)
T
- specialization of Storableclazz
- the Class of Storable to sortcomparatorName
- the comparator name as declared in properties
public static <T extends Storable> Comparator<? super T> getComparator(Class<T> typeClazz, String comparatorName, boolean reverse)
T
- specialization of StorabletypeClazz
- the Class of Storable to sortcomparatorName
- the comparator name as declared in propertiesreverse
- a boolean indicating whether the comparator should have
its behavior reversed (true) or unchanged (false)
public static <T extends Storable> Comparator<? super T> getComparator(Class<T> typeClazz, String comparatorName, boolean reverse, Map<String,Object> contextMap)
T
- specialization of StorabletypeClazz
- the Class of Storable to sortcomparatorName
- the comparator name as declared in propertiesreverse
- a boolean indicating whether the comparator should have
its behavior reversed (true) or unchanged (false)contextMap
- a Map containing any contextual information which might be needed by the
Comparator implementation (see BasicComparator
for usage)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |