Class UnityPropertiesHelper

  • All Implemented Interfaces:
    eu.unicore.util.configuration.PropertiesHelperAPI, eu.unicore.util.configuration.UpdateableConfiguration, java.lang.Cloneable

    public class UnityPropertiesHelper
    extends eu.unicore.util.configuration.PropertiesHelper
    Extends PropertiesHelper with Unity specific methods: returning localized strings and caching of getSortedStringKeys(String, boolean) method results.
    Author:
    K. Benedyczak
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<java.lang.String,​java.util.Set<java.lang.String>> listKeysCache  
      • Fields inherited from class eu.unicore.util.configuration.PropertiesHelper

        genericListeners, log, metadata, prefix, properties, propertyFocusedListeners, structuredPrefixes
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        UnityPropertiesHelper​(java.lang.String prefix, java.util.Properties properties, java.util.Map<java.lang.String,​eu.unicore.util.configuration.PropertyMD> propertiesMD, org.apache.log4j.Logger log)  
      protected UnityPropertiesHelper​(UnityPropertiesHelper cloned)
      For cloning
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addCachedPrefixes​(java.lang.String... prefixRegexp)
      All properties which start with the given regexp will be cached in a way that all properties starting with this prefix can be quickly retrieved using getSortedStringKeys(String, boolean).
      protected void cacheIfNeeded​(java.lang.String key)  
      java.lang.String getAsString()  
      pl.edu.icm.unity.types.I18nString getLocalizedString​(pl.edu.icm.unity.MessageSource msg, java.lang.String baseKey)  
      pl.edu.icm.unity.types.I18nString getLocalizedStringWithoutFallbackToDefault​(pl.edu.icm.unity.MessageSource msg, java.lang.String baseKey)  
      java.lang.String getLocalizedValueWithOutFallbackToDefault​(java.lang.String key, java.util.Locale locale)  
      protected java.util.Set<java.lang.String> getSortedStringKeys​(java.lang.String base, boolean allowListSubKeys)  
      protected boolean isCached​(java.lang.String key)  
      protected void refillCache()  
      void setProperties​(java.util.Properties properties)  
      void setProperty​(java.lang.String key, java.lang.String value)  
      • Methods inherited from class eu.unicore.util.configuration.PropertiesHelper

        addPropertyChangeListener, canHaveSubkeys, checkBounds, checkConstraints, checkConstraints, checkDeprecated, checkPropertyConstraints, checkStructuredListConstraints, clone, cloneTo, filterChanged, findUnknown, getBooleanValue, getClassValue, getDoubleValue, getDoubleValueNoCheck, getEnumValue, getFileValue, getFileValueAsString, getIntValue, getIntValueNoCheck, getKeyDescription, getListOfValues, getLocalizedValue, getLongValue, getLongValueNoCheck, getMetadata, getMetadataKey, getRawProperty, getSortedNumKeys, getStructuredListKeys, getSubkeyBooleanValue, getSubkeyEnumValue, getSubkeyIntValue, getSubkeyLongValue, getSubkeyValue, getValue, isSet, logValue, notifyAllWithKey, notifyFocusedListeners, notifyGenericListeners, removePropertyChangeListener
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • listKeysCache

        protected java.util.Map<java.lang.String,​java.util.Set<java.lang.String>> listKeysCache
    • Constructor Detail

      • UnityPropertiesHelper

        public UnityPropertiesHelper​(java.lang.String prefix,
                                     java.util.Properties properties,
                                     java.util.Map<java.lang.String,​eu.unicore.util.configuration.PropertyMD> propertiesMD,
                                     org.apache.log4j.Logger log)
      • UnityPropertiesHelper

        protected UnityPropertiesHelper​(UnityPropertiesHelper cloned)
        For cloning
        Parameters:
        cloned -
    • Method Detail

      • addCachedPrefixes

        public void addCachedPrefixes​(java.lang.String... prefixRegexp)
        All properties which start with the given regexp will be cached in a way that all properties starting with this prefix can be quickly retrieved using getSortedStringKeys(String, boolean). This also optimizes uses of PropertiesHelper.getListOfValues(String) which relies on the above methods. Note that the regexp must include the main prefix of this properties object.
        Parameters:
        prefixRegexp -
      • setProperties

        public void setProperties​(java.util.Properties properties)
        Specified by:
        setProperties in interface eu.unicore.util.configuration.PropertiesHelperAPI
        Specified by:
        setProperties in interface eu.unicore.util.configuration.UpdateableConfiguration
        Overrides:
        setProperties in class eu.unicore.util.configuration.PropertiesHelper
      • setProperty

        public void setProperty​(java.lang.String key,
                                java.lang.String value)
        Specified by:
        setProperty in interface eu.unicore.util.configuration.PropertiesHelperAPI
        Overrides:
        setProperty in class eu.unicore.util.configuration.PropertiesHelper
      • refillCache

        protected void refillCache()
      • cacheIfNeeded

        protected void cacheIfNeeded​(java.lang.String key)
      • isCached

        protected boolean isCached​(java.lang.String key)
      • getSortedStringKeys

        protected java.util.Set<java.lang.String> getSortedStringKeys​(java.lang.String base,
                                                                      boolean allowListSubKeys)
        Overrides:
        getSortedStringKeys in class eu.unicore.util.configuration.PropertiesHelper
      • getLocalizedString

        public pl.edu.icm.unity.types.I18nString getLocalizedString​(pl.edu.icm.unity.MessageSource msg,
                                                                    java.lang.String baseKey)
        Parameters:
        msg -
        baseKey - Property name (without the prefix).
        Returns:
        localized string of the given property. Default value is set to the regular value of the property. All sub values of the base key are used as localized values, assuming their subkey is equal to one of supported locales.
      • getLocalizedStringWithoutFallbackToDefault

        public pl.edu.icm.unity.types.I18nString getLocalizedStringWithoutFallbackToDefault​(pl.edu.icm.unity.MessageSource msg,
                                                                                            java.lang.String baseKey)
      • getLocalizedValueWithOutFallbackToDefault

        public java.lang.String getLocalizedValueWithOutFallbackToDefault​(java.lang.String key,
                                                                          java.util.Locale locale)
      • getAsString

        public java.lang.String getAsString()