Package com.composum.ai.aem.core.impl
Class SelectorUtils
- java.lang.Object
-
- com.composum.ai.aem.core.impl.SelectorUtils
-
public class SelectorUtils extends Object
Some utility methods for this.
-
-
Field Summary
Fields Modifier and Type Field Description protected static Set<String>
LOCALE_NAMES
protected static Pattern
LOCALE_PATTERN
static String
PARAMETER_PATH
Parameter defining the path to the resource we work on.static String
PLACEHOLDER_TARGETLANGUAGE
Special placeholder in prompts that is replaced by the language of the page.
-
Constructor Summary
Constructors Constructor Description SelectorUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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.static String
getLanguageName(String languageCode, Locale targetLocale)
static List<org.apache.sling.api.resource.Resource>
getLanguageSiblings(org.apache.sling.api.resource.Resource resource, String language)
We look in the resource path for a path element thatisLocaleName(String)
and try to replace it by language as it is or language with a country suffix ([-_][a-zA-Z]{2}) removed.static boolean
isLocaleName(String name)
-
-
-
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
-
-
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.
-
getLanguageName
public static String getLanguageName(@Nonnull String languageCode, @Nullable Locale targetLocale)
-
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 thatisLocaleName(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.
-
-