Class Config

java.lang.Object
com.deviceatlas.device.Config
All Implemented Interfaces:
Cloneable

public class Config extends Object implements Cloneable
DeviceApi Configurations. To change the default configs of the DeviceAtlas DeviceApi create an instance of this class, set your preferred configs and pass the instance to the constructor of a DeviceApi or DeviceApiWeb. Note that you may change the configs even after the Config instance has been passed to the DeviceApi.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The default cookie name that the client side properties would be set to.
    static final int
    The default config value for result (Properties object) caching.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Get the cookie name that the client side properties would be set to.
    int
    Get the max number of results to be cached.
    void
    setCookieName(String cookieName)
    To change the cookie name that the client side properties would be set to.
    void
    setMaxCacheEntries(int maxCacheEntries)
    Set the max number of results to be cached to improve performance of repeat-heavy inputs.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_MAX_CACHE_ENTRIES

      public static final int DEFAULT_MAX_CACHE_ENTRIES
      The default config value for result (Properties object) caching. Depending on the frequency and distance factor of your user-agents or headers passed to the API for detection the result cache may increase performance by preventing repeated lookups.
      See Also:
  • Constructor Details

    • Config

      public Config()
  • Method Details

    • setCookieName

      public void setCookieName(String cookieName)
      To change the cookie name that the client side properties would be set to. When using getProperties() on a servlet container, the detection would automatically use the contents of this cookie if it exists. If you want the client side properties to be used add the DeviceAtlas Client-side component (JS lib) to your web-site pages.
      When the user-agent or HTTP headers are set manually to getProperties() the client side properties (probably the value set to the cookie) can be manually passed to this method as the second argument, note that this config is only used for getProperties(REQUEST-OBJECT). If you set the cookie-name to null then the client side properties cookie will be ignored.
      Parameters:
      cookieName - The cookie name which the client side properties are set to. Set to null to turn off using client side properties.
    • getCookieName

      public String getCookieName()
      Get the cookie name that the client side properties would be set to. When using getProperties() on a servlet container, the detection would automatically use the contents of this cookie if it exists. If you want the client side properties to be used add the DeviceAtlas Client-side component (JS lib) to your web-site pages.
      When the User-Agent or HTTP headers are set manually to getProperties() the client side properties (probably the value set to the cookie) can be manually passed to this method as the second argument, note that this config is only used for getProperties(REQUEST-OBJECT).
      Returns:
      The cookie name which the client side properties are set to
    • setMaxCacheEntries

      public void setMaxCacheEntries(int maxCacheEntries)
      Set the max number of results to be cached to improve performance of repeat-heavy inputs. If the inputs to the API are mostly unique it is recommended to disable the cache by setting a size of 0.
      Parameters:
      maxCacheEntries -
    • getMaxCacheEntries

      public int getMaxCacheEntries()
      Get the max number of results to be cached.
      Returns:
      maxCacheEntries