Class SelectorUtils


  • public class SelectorUtils
    extends Object
    Some utility methods for this.
    • Field Detail

      • PARAMETER_PATH

        public static final String PARAMETER_PATH
        Parameter defining the path to the resource we work on.
        See Also:
        Constant Field Values
      • PLACEHOLDER_TARGETLANGUAGE

        public static final String PLACEHOLDER_TARGETLANGUAGE
        Special placeholder in prompts that is replaced by the language of the page.
        See Also:
        Constant Field Values
      • LOCALE_PATTERN

        protected static final Pattern LOCALE_PATTERN
      • LOCALE_NAMES

        protected static Set<String> LOCALE_NAMES
    • Constructor Detail

      • SelectorUtils

        public SelectorUtils()
    • Method Detail

      • findLanguage

        public static String findLanguage​(org.apache.sling.api.resource.Resource pageResource)
        Determines the language this resource is in by searching for an ancestor resource with jcr:language set, or for an ancestor that looks like a language code.
      • isLocaleName

        public static boolean isLocaleName​(String name)
      • getLanguageSiblings

        public static List<org.apache.sling.api.resource.Resource> getLanguageSiblings​(@Nullable
                                                                                       org.apache.sling.api.resource.Resource resource,
                                                                                       @Nullable
                                                                                       String language)
        We look in the resource path for a path element that isLocaleName(String) and try to replace it by language as it is or language with a country suffix ([-_][a-zA-Z]{2}) removed. Resources that can be found like that are returned.