Class LocaleUtils

java.lang.Object
com.sap.cds.impl.localized.LocaleUtils

public class LocaleUtils extends Object
Utility class to handle the locale settings
  • Method Details

    • localizedEntityName

      public static String localizedEntityName(CdsEntity entity)
      Calculates the localized entity name that can be used to access localized fields
      Parameters:
      entity - the entity
      Returns:
      the localized entity name
    • localizedEntityName

      public static String localizedEntityName(String entity)
      Calculates the localized entity name that can be used to access localized fields
      Parameters:
      entity - the entity name
      Returns:
      the localized entity name
    • localeSpecificViewName

      public static String localeSpecificViewName(String entity, Locale locale)
      Calculates the locale-specific view name for a given locale, which can be used to access localized fields
      Parameters:
      entity - the entity name
      locale - the locale
      Returns:
      the locale-specific view name
    • isLocalizedEntityName

      public static boolean isLocalizedEntityName(String entity)
      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

      public static String getLocaleString(Locale locale)
      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

      public static boolean isLocalized(CdsEntity entity)
      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 elements
      elementRefs - the element refs to be checked
      Returns:
      true if the provided elementRefs contain localized elements
    • collateClauseIsNeeded

      public static boolean collateClauseIsNeeded(CdsModel model, CqnStatement statement, Locale locale)
      Checks whether a given CqnStatement needs to be appended with a collate clause
      Parameters:
      model - the underlying CdsModel
      statement - the statement to be checked
      locale - the Locale provided along the statement execution
      Returns:
      true if a collate clause needs to be appended