Package com.sap.cds.impl.localized
Class LocaleUtils
java.lang.Object
com.sap.cds.impl.localized.LocaleUtils
Utility class to handle the locale settings
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
collateClauseIsNeeded
(CqnFilterableStatement statement, Locale locale) Checks whether a givenCqnStatement
needs to be appended with a collate clausestatic String
getLocaleString
(Locale locale) Calculates the locale String value from a specific locale that can be used to access localized attributes fieldsstatic boolean
hasLocalizedElements
(CdsStructuredType targetType, Collection<CqnElementRef> elementRefs) Checks if some element refs of a structured type has any localized elementsstatic boolean
isLocalized
(CdsEntity entity) Checks if an entity is annotated with @cds.localizedstatic boolean
isLocalizedEntityName
(String entity) Checks if a given entity name is a localized entity namestatic String
localeSpecificViewName
(String entity, Locale locale) Calculates the locale-specific view name for a given locale, which can be used to access localized fieldsstatic String
localizedEntityName
(CdsEntity entity) Calculates the localized entity name that can be used to access localized fieldsstatic String
localizedEntityName
(String entity) Calculates the localized entity name that can be used to access localized fields
-
Constructor Details
-
LocaleUtils
-
-
Method Details
-
localizedEntityName
Calculates the localized entity name that can be used to access localized fields- Parameters:
entity
- the entity- Returns:
- the localized entity name
-
localizedEntityName
Calculates the localized entity name that can be used to access localized fields- Parameters:
entity
- the entity name- Returns:
- the localized entity name
-
localeSpecificViewName
Calculates the locale-specific view name for a given locale, which can be used to access localized fields- Parameters:
entity
- the entity namelocale
- the locale- Returns:
- the locale-specific view name
-
isLocalizedEntityName
Checks if a given entity name is a localized entity name- Parameters:
entity
- the entity name- Returns:
- true if the given name if a localized entity name
-
getLocaleString
Calculates the locale String value from a specific locale that can be used to access localized attributes fields- Parameters:
locale
- the locale- Returns:
- the locale String value
-
isLocalized
Checks if an entity is annotated with @cds.localized- Parameters:
entity
- the entity to be checked- Returns:
- true if the entity is annotated with @cds.localized
-
hasLocalizedElements
public static boolean hasLocalizedElements(CdsStructuredType targetType, Collection<CqnElementRef> elementRefs) Checks if some element refs of a structured type has any localized elements- Parameters:
targetType
- the structured type to be checked for localized elementselementRefs
- the element refs to be checked- Returns:
- true if the provided elementRefs contain localized elements
-
collateClauseIsNeeded
Checks whether a givenCqnStatement
needs to be appended with a collate clause- Parameters:
statement
- the statement to be checkedlocale
- theLocale
provided along the statement execution- Returns:
- true if a collate clause needs to be appended
-