|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jalios.jstore.BasicStorable.CdateComparator<T> com.jalios.jcms.comparator.BasicComparator<T>
T
- specialization of Storablepublic class BasicComparator<T extends Storable>
Basic comparator class providing advanced contextual informations and default comparison of Storable using their cdate.
The following fields are available to your implementation :
Channel channel
: the ChannelJcmsContext jcmsContext
: the current JcmsContext if availableString language
: current user language or default channel language.Locale locale
: current user Locale or default channel Locale.Map contextMap
: a Map containing contextual information received
through ComparatorManager.getComparator(Class, String, boolean, Map)
.// Sorts Article by alphabetical order of their "intro" field, using current language. // Declare this comparator using the following property : // comparator.Article.articleintro: com.example.jcms.comparator.MyArticleIntroComparator public class MyArticleIntroComparator extends BasicComparator<Article> { public int compare(Article p1, Article p2) { // object nullity check if (p1 == null) { return (p2 == null) ? 0 : -1; } if (p2 == null) { return 1; } // Retrieve Article introduction String t1 = p1.getIntro(language); String t2 = p2.getIntro(language); if (t1 == null) { return (t2 == null) ? 0 : -1; } if (t2 == null) { return 1; } t1 = Util.unaccentuate(t1); t2 = Util.unaccentuate(t2); int res = t1.compareToIgnoreCase(t2); if (res != 0) { return res; } return super.compare(p1, p2); } }
Field Summary | |
---|---|
protected Channel |
channel
The Channel. |
protected Map<String,Object> |
contextMap
Contextual information map, retrieved through ComparatorManager.getComparator(Class, String, boolean, Map) . |
protected JcmsContext |
jcmsContext
The current JcmsContext, if available. |
protected String |
language
Current user language or default channel language. |
protected Locale |
locale
Current user Locale or default channel Locale. |
Constructor Summary | |
---|---|
BasicComparator()
|
Method Summary |
---|
Methods inherited from class com.jalios.jstore.BasicStorable.CdateComparator |
---|
compare, compareDate |
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 |
---|
protected final Channel channel
Never null.
protected final JcmsContext jcmsContext
Might be null.
protected final String language
Never null.
protected final Locale locale
Never null.
protected final Map<String,Object> contextMap
ComparatorManager.getComparator(Class, String, boolean, Map)
. Never null.
Constructor Detail |
---|
public BasicComparator()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |