Package com.deviceatlas.device
Class Config
java.lang.Object
com.deviceatlas.device.Config
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescriptionstatic final StringThe default cookie name that the client side properties would be set to.static final intThe default config value for result (Properties object) caching. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the cookie name that the client side properties would be set to.intGet the max number of results to be cached.voidsetCookieName(String cookieName) To change the cookie name that the client side properties would be set to.voidsetMaxCacheEntries(int maxCacheEntries) Set the max number of results to be cached to improve performance of repeat-heavy inputs.
-
Field Details
-
DEFAULT_COOKIE_NAME
The default 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.- See Also:
-
DEFAULT_MAX_CACHE_ENTRIES
public static final int DEFAULT_MAX_CACHE_ENTRIESThe 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
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
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
-