Class AbstractLocaleDAOImpl

  • All Implemented Interfaces:
    LocaleDAO
    Direct Known Subclasses:
    LocaleDAOImpl

    public abstract class AbstractLocaleDAOImpl
    extends java.lang.Object
    implements LocaleDAO
    Abstract implementation for Locale DAO.

    This provides basic services such as caching, but defers to the underlying implementation for CRUD operations. Since locales are system-wide and immutable, we can cache lookups in both directions.

    Since:
    3.4
    Author:
    janv
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractLocaleDAOImpl()
      Default constructor.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract LocaleEntity createLocaleEntity​(java.lang.String locale)  
      org.alfresco.util.Pair<java.lang.Long,​java.util.Locale> getDefaultLocalePair()
      protected abstract LocaleEntity getLocaleEntity​(java.lang.Long id)  
      protected abstract LocaleEntity getLocaleEntity​(java.lang.String locale)  
      org.alfresco.util.Pair<java.lang.Long,​java.util.Locale> getLocalePair​(java.lang.Long id)
      org.alfresco.util.Pair<java.lang.Long,​java.util.Locale> getLocalePair​(java.util.Locale locale)
      org.alfresco.util.Pair<java.lang.Long,​java.util.Locale> getOrCreateDefaultLocalePair()
      Find or create the details representing the default locale.
      org.alfresco.util.Pair<java.lang.Long,​java.util.Locale> getOrCreateLocalePair​(java.util.Locale locale)
      Gets the locale ID for an existing instance or creates a new entity if one doesn't exist.
      void setLocaleEntityCache​(org.alfresco.repo.cache.SimpleCache<java.lang.Long,​java.lang.String> localeEntityCache)
      Set the cache that maintains the ID-Locale mappings and vice-versa (bi-directional)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractLocaleDAOImpl

        protected AbstractLocaleDAOImpl()
        Default constructor.

        This sets up the DAO accessors to bypass any caching to handle the case where the caches are not supplied in the setters.

    • Method Detail

      • setLocaleEntityCache

        public void setLocaleEntityCache​(org.alfresco.repo.cache.SimpleCache<java.lang.Long,​java.lang.String> localeEntityCache)
        Set the cache that maintains the ID-Locale mappings and vice-versa (bi-directional)
        Parameters:
        localeEntityCache - the cache
      • getLocalePair

        public org.alfresco.util.Pair<java.lang.Long,​java.util.Locale> getLocalePair​(java.util.Locale locale)
        Specified by:
        getLocalePair in interface LocaleDAO
        Parameters:
        locale - the locale to fetch or null to get the default locale
        Returns:
        the locale or null if no such locale exists
      • getDefaultLocalePair

        public org.alfresco.util.Pair<java.lang.Long,​java.util.Locale> getDefaultLocalePair()
        Specified by:
        getDefaultLocalePair in interface LocaleDAO
        Returns:
        the locale pair for the default locale. Although the Locale object will be populated, the ID will point to an instance that generically refers to the system's default locale i.e. the value returned can vary depending on the executing thread's default locale.
      • getLocalePair

        public org.alfresco.util.Pair<java.lang.Long,​java.util.Locale> getLocalePair​(java.lang.Long id)
        Specified by:
        getLocalePair in interface LocaleDAO
        Parameters:
        id - the unique ID of the entity
        Returns:
        the locale pair (never null)
      • getOrCreateLocalePair

        public org.alfresco.util.Pair<java.lang.Long,​java.util.Locale> getOrCreateLocalePair​(java.util.Locale locale)
        Gets the locale ID for an existing instance or creates a new entity if one doesn't exist.
        Specified by:
        getOrCreateLocalePair in interface LocaleDAO
        Parameters:
        locale - the locale to fetch or null to get or create the default locale.
        Returns:
        the locale - never null
      • getOrCreateDefaultLocalePair

        public org.alfresco.util.Pair<java.lang.Long,​java.util.Locale> getOrCreateDefaultLocalePair()
        Find or create the details representing the default locale.
        Specified by:
        getOrCreateDefaultLocalePair in interface LocaleDAO
        Returns:
        the locale pair for the default locale. Although the Locale object will be populated, the ID will point to an instance that generically refers to the system's default locale i.e. the value returned can vary depending on the executing thread's default locale.
      • getLocaleEntity

        protected abstract LocaleEntity getLocaleEntity​(java.lang.Long id)
      • getLocaleEntity

        protected abstract LocaleEntity getLocaleEntity​(java.lang.String locale)
      • createLocaleEntity

        protected abstract LocaleEntity createLocaleEntity​(java.lang.String locale)