Class BasicComparator<T extends Storable>

    • Field Detail

      • channel

        protected final Channel channel
        The Channel.

        Never null.

      • jcmsContext

        protected final JcmsContext jcmsContext
        Was used to access the current JcmsContext. Warning : This field is always null since jcms-10.0.5 (JCMS-8435) to prevent a memory leak.
        This variable will be removed in a future version.

        See Channel.getCurrentJcmsContext() if you really need it, but use it wisely.
      • language

        protected final java.lang.String language
        Current user language or default channel language.

        Never null.

      • locale

        protected final java.util.Locale locale
        Current user Locale or default channel Locale.

        Never null.

    • Constructor Detail

      • BasicComparator

        public BasicComparator()
    • Method Detail

      • compareString

        public int compareString​(java.lang.String str1,
                                 java.lang.String str2)
        Compare the two specified String using default method configured.

        Example of use :

          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
             int res = compareString(p1.getIntro(language), p2.getIntro(language));
             if (res != 0) {
               return res;
             return, m2);
        Default String comparison method can be configured globally or per class using property, see BasicComparator.StringComparisonMethod.
        str1 - the first string to compare, null is authorized
        str2 - the second string to compare, null is authorized
        Returns an integer value. Value is less than zero if str1 is lexicographically less than str2, value is zero if str1 and str2 are equal and value is greater than str1 if this is lexicographically greater than str2.
        jcms-10.0.4 / JCMS-8000