Class GenericBrowserSettings

  • All Implemented Interfaces:
    BrowserSettings, EnumBrowserType
    Direct Known Subclasses:
    AbstractBrowserSettings, HttpBrowserSettings

    public abstract class GenericBrowserSettings
    extends java.lang.Object
    implements BrowserSettings
    This abstract class represents a generic implementation of the BrowserSettings interface.

    It provides with implementation of methods that can be used on other BrowserSettings child classes. Some of these methods are the ones that provide a cache system for the values (addCacheValue(), getCacheValue(), etc); others for values related to the Query String and Form Data (buildBrowserSettingURLParameter(), getValueFromQueryString(), etc); and generic methods for finding out information about the client browser that made a request (isDHTMLSupported(), getBrowserType(), etc)

    As mentioned above, this implementation provides a cache system that can be used transparently by the classes that extend this implementation. It is assumed that the values saved under the main keys are with URL-like format, for example:
    key1=subkey1=value1&subkey2=value2
    This formatting is completely hidden if using the cache methods. If the cache does not exist then the updateCacheValue() method can be directly used and this one will create the cache and will provide the URL-like string required to be saved as the value of a cookie, a preference, or any other.

    Since:
    MicroStrategy Web 7.3.1 or earlier
    • Field Detail

      • GENERIC_KEY

        protected static final java.lang.String GENERIC_KEY
        Primary key to use for representing global persistent browser setting values
        See Also:
        Constant Field Values
      • GENERIC_HTTP_SESSION_KEY

        protected static final java.lang.String GENERIC_HTTP_SESSION_KEY
        Primary key to use for representing global temporal browser setting values
        See Also:
        Constant Field Values
      • GENERIC_PROJECT_KEY_PREFIX

        protected static final java.lang.String GENERIC_PROJECT_KEY_PREFIX
        key name prefix for project settings *
        Since:
        MicroStrategy Web 8.0.2
        See Also:
        Constant Field Values
    • Constructor Detail

      • GenericBrowserSettings

        public GenericBrowserSettings()
        Class Constructor. Initializes an empty instance of the class.
    • Method Detail

      • setPreferences

        public void setPreferences​(Preferences preferences)
        Set the Preferences instance to use for this BrowserSettings instance
        Specified by:
        setPreferences in interface BrowserSettings
        Parameters:
        preferences - a valid Preferences instance
      • setSession

        public void setSession​(WebIServerSession currentSession)
        Sets the session that will be used as default when accessing session settings.
        Specified by:
        setSession in interface BrowserSettings
        Parameters:
        currentSession - an initialized WebIServerSession instance that represents the current session opened.
      • getBrowserType

        public int getBrowserType()
        Returns the type of the browser that is being used for performing the request being handled.
        Specified by:
        getBrowserType in interface BrowserSettings
        Returns:
        an int value depending on the type of browser used by the client:
      • BROWSER_TYPE_NETSCAPE
      • BROWSER_TYPE_IE
      • BROWSER_TYPE_OTHER
      • getBrowserTypeAndVersion

        public int getBrowserTypeAndVersion()
        Returns the type and the version of the browser
        Specified by:
        getBrowserTypeAndVersion in interface BrowserSettings
        Returns:
        an int value depending on the type of browser defined in BrowserSettings.
        Since:
        MicroStrategy Web 9.0.1
      • getBrowserVersion

        public java.lang.String getBrowserVersion()
        Returns the numeric version of the browser that is being used. ie. 1.5, 6, 7
        Specified by:
        getBrowserVersion in interface BrowserSettings
        Since:
        MicroStrategy Web 9.0.0
      • isCSS2Supported

        public boolean isCSS2Supported()
        Indicates if the browser currently used by the client can handle CSS 2 styles.
        Specified by:
        isCSS2Supported in interface BrowserSettings
        Returns:
        a boolean value indicating if the client browser can display and handle CSS 2 styles.
      • getUserAgent

        public java.lang.String getUserAgent()
        Retrives the USER-AGENT string from the header of the browser.
        Specified by:
        getUserAgent in interface BrowserSettings
        Returns:
        a String value indicating USER-AGENT string from the header of the browser
        Since:
        MicroStrategy Web 8.0.0
      • isDHTMLSupported

        public boolean isDHTMLSupported()
        Indicates if the browser currently used by the client can handle DHTML content or not.
        Specified by:
        isDHTMLSupported in interface BrowserSettings
        Returns:
        a boolean value indicating if the client browser can display and handle DHTML code.
      • getLocale

        public java.lang.String getLocale()
        Get the locale value saved as browser setting
        Specified by:
        getLocale in interface BrowserSettings
        Returns:
        the localeId available for this BrowserSettings instance.
      • setDefinitionList

        public void setDefinitionList​(BrowserSettingDefinitionList bsDefinitionList)
        Sets the default definition of the browser setting. This definition object will be use to determine the value of the browser settings in case the setting requested is not found for the user.
        Specified by:
        setDefinitionList in interface BrowserSettings
        Parameters:
        bsDefinitionList - the default definition of the browser settings
      • getDefinitionList

        public BrowserSettingDefinitionList getDefinitionList()
        Description copied from interface: BrowserSettings
        Return the default definition of the browser setting which will be use to determine the value of the browser settings in case the setting requested is not found for the user.
        Specified by:
        getDefinitionList in interface BrowserSettings
        Returns:
        the default definition of the browser setting. This definition object will be use to determine the value of the browser settings in case the setting requested is not found for the user.
      • getDefaultValue

        public java.lang.String getDefaultValue​(java.lang.String key)
        Return the default value of a specific setting. Returns an null if the definition of the setting was not found on the definition list.
        Specified by:
        getDefaultValue in interface BrowserSettings
        Parameters:
        key - the name of the browser setting.
        Returns:
        the default value of a specific setting
      • hasValueSet

        public boolean hasValueSet​(java.lang.String keyName)
        Description copied from interface: BrowserSettings
        Checks whether a value has been set for the given key name or not
        Specified by:
        hasValueSet in interface BrowserSettings
        Parameters:
        keyName - the name associated with the setting
        Returns:
        true if there is a value been set already (other than the default)
        Since:
        MicroStrategy Web 9.0.0
      • getCacheValue

        protected java.lang.String getCacheValue​(java.lang.String key,
                                                 java.lang.String subkey)
        Deprecated.
        it is only used by deprecated classes.
        Obtains the value of the given key-subkey pair if stored on the cache.
        Parameters:
        key - Key to search for in the cache
        subkey - Subkey to search for in the cache contents
        Returns:
        The value associated with the key-subkey sent. If no value found, returns null.
      • getCacheValue

        protected java.lang.String getCacheValue​(java.lang.String key)
        Deprecated.
        it is only used by deprecated classes.
        Obtains the value of the given key if stored on the cache
        Parameters:
        key - Key to search for in the cache
        Returns:
        The value associated with the key sent. If no value found, returns null.
      • isCacheValuePersistable

        protected boolean isCacheValuePersistable​(java.lang.String key)
        Deprecated.
        it is only used by deprecated classes.
        Determines if the cache value related with the key given is a persistable browser setting or not
        Parameters:
        key - Key to search for in the cache
        Returns:
        True if the cache value is related to a persistent browser setting. Otherwise (or if not found) returns False
      • setCacheValuePersistable

        protected void setCacheValuePersistable​(java.lang.String key,
                                                boolean persistable)
        Deprecated.
        it is only used by deprecated classes.
        Sets if the cache value related with the key given is a persistable browser setting or not. If the value is not found, nothing is done.
        Parameters:
        key - Key to search for in the cache
        persistable - True if the cache value will be related to a persistent browser setting. Otherwise, False
      • isCacheValueModified

        protected boolean isCacheValueModified​(java.lang.String key)
        Deprecated.
        it is only used by deprecated classes.
        Determines if the cache value has been modified since it was initially loaded.
        Parameters:
        key - Key to search for in the cache
        Returns:
        True if the value has been modified from its original value. Otherwise (or if value is not found) returns False
      • isValueCached

        protected boolean isValueCached​(java.lang.String key)
        Deprecated.
        it is only used by deprecated classes.
        Determines if the key sent as parameter is already contained in the cache or not
        Parameters:
        key - key to search for in the cache
        Returns:
        True if the value is contained in the cache, otherwise returns False
      • getCacheNames

        protected java.util.Enumeration getCacheNames()
        Deprecated.
        it is only used by deprecated classes.
        Return an enumeration of all the keys used in the cache.
        Returns:
        an Enumeration with all the key names saved in the cache
      • addCacheValue

        protected void addCacheValue​(java.lang.String key,
                                     java.lang.String value)
        Deprecated.
        it is only used by deprecated classes.
        Adds the indicated value under the given key on the cache. By default it will be considered that the browser setting related is temporal.
        Parameters:
        key - Key to use for the value to store
        value - Value to save in the cache.
      • addCacheValue

        protected void addCacheValue​(java.lang.String key,
                                     java.lang.String value,
                                     boolean persistable)
        Deprecated.
        it is only used by deprecated classes.
        Adds the indicated value under the given key on the cache.
        Parameters:
        key - Key to use for the value to store
        value - Value to save in the cache.
        persistable - indicates if the browser setting is temporal or permanent
      • isValueSafeForXSS

        protected boolean isValueSafeForXSS​(java.lang.String key,
                                            java.lang.String value)
        Check if the value is safe for XSS, which means check the value contains valid HTML tag or not
        Parameters:
        key - Key to use for the value
        value - Value to be checked
        Returns:
        If the value safe for XSS or not
      • updateCacheValue

        protected java.lang.String updateCacheValue​(java.lang.String key,
                                                    java.lang.String subkey,
                                                    java.lang.String newValue)
        Deprecated.
        it is only used by deprecated classes.
        Update the value under the given key-subkey combination on the cache
        Parameters:
        key - key to search for in the cache
        subkey - subkey to search for in the cache value
        newValue - new value that the key-subkey combination will have
        Returns:
        the full String of the cache value saved under the key (includes all subkeys information)
      • getValueFromQueryString

        protected java.lang.String getValueFromQueryString​(java.lang.String keyName,
                                                           java.lang.String subKeyName)
        Deprecated.
        it is only used by deprecated classes.
        Based on the key and subkey given, search this value on the URL and on the Form Data
        Parameters:
        keyName - key to look for
        subKeyName - subkey to look for
        Returns:
        the value corresponding to the key-subkey pair sent. If no value is found, null is returned.
      • setIframeVisibility

        public void setIframeVisibility​(java.lang.String value)
        Define a browser setting for allowing the IFrame to be shown on DHTML environments. A request for hidding the IFrame has precedence over one for showing it.
        Specified by:
        setIframeVisibility in interface BrowserSettings
        Parameters:
        value - String value of a boolean indicating if the IFrame should be shown.
        Since:
        MicroStrategy Web 8.0.0
      • getBrowserName

        public java.lang.String getBrowserName()
        Description copied from interface: BrowserSettings
        Returns the name of the browser that is being used for performing the request
        Specified by:
        getBrowserName in interface BrowserSettings
        Returns:
        a value depending on the type and version of browser used by the client. supported browser names: ie7, ie8, ie9, ie10, firefox, chrome, safari; otherwise: unsupported-browser.
      • getBrowserCompatName

        public java.lang.String getBrowserCompatName()
        Description copied from interface: BrowserSettings
        Returns the name of the IE browser including its status to indicate whether it is requesitng in Compatibility Mode.
        Specified by:
        getBrowserCompatName in interface BrowserSettings
        Returns:
        a value depending on the type and version of browser used by the client. supported browser compat names: ie8c, ie9c, ie10c otherwise: ""
      • isEdgeModeEnabled

        public boolean isEdgeModeEnabled()
        Get flag whether System Preference enables a tag to force IE browsers to render in highest Document Mode.
        Specified by:
        isEdgeModeEnabled in interface BrowserSettings
        Returns:
        boolean