public abstract class TrieProvider extends Object implements Closeable
| Modifier and Type | Class and Description |
|---|---|
static class |
TrieProvider.OffsetType
The type of integers used to represent the offset to the children.
|
| Modifier and Type | Field and Description |
|---|---|
protected ByteBuffer |
_properties
Byte array of the available properties.
|
protected Map<String,Integer> |
_propertyIndex
Dictionary of property names to indexes.
|
protected List<String> |
_propertyNames
List of the available property names.
|
String |
copyright
The copy right notice associated with the data file.
|
protected List<String[]> |
propertyHttpHeaders
List of HTTP headers for each property index.
|
| Constructor and Description |
|---|
TrieProvider(String copyright,
byte[] strings,
byte[] properties,
byte[] devices,
short[] lookupList,
long nodesLength,
long nodesOffset,
TriePool pool)
Constructs a new instance of a tree provider.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Disposes of the pool assigned to the provider.
|
String |
getDefaultPropertyValue(String propertyName)
Returns the default property value for a null User-Agent.
|
String |
getDeviceId(int deviceIndex)
Returns the device id matching the device index.
|
int |
getDeviceIndex(String userAgent)
Returns the index of the device associated with the given user agent.
|
Map<String,Integer> |
getDeviceIndexes(Map<String,String> headers)
Returns a collection of device indexes for each of the relevant HTTP
headers provided.
|
List<String> |
getHttpHeaders()
Returns a list of Http headers that the provider can use for
device detection.
|
String |
getPropertyValue(int deviceIndex,
int propertyIndex)
Returns the value of the property index provided for the device index
provided.
|
String |
getPropertyValue(int deviceIndex,
String property)
Returns the property value based on the useragent provided.
|
String |
getPropertyValue(Map<String,Integer> deviceIndexes,
int propertyIndex)
Returns the value of the property index provided from the device indexes
provided.
|
String |
getPropertyValue(Map<String,Integer> deviceIndexes,
String property)
Returns the property value based on the device indexes provided.
|
String |
getPropertyValue(String userAgent,
String propertyname)
Returns the value of the property for the user agent provided.
|
String |
getPropertyValueWithMultiHeaders(Map<String,String> headers,
String propertyName)
Returns the value of the property for the user agent provided.
|
protected String |
getStringValue(int offset)
Returns the String at the offset provided.
|
String |
getUserAgent(String userAgent)
Returns the user agent matched against the one provided.
|
List<String> |
propertyNames()
List of all property names for the provider.
|
static int |
sizeOfOffsets(TrieProvider.OffsetType offsetType)
The number of bytes each offset takes.
|
public String copyright
protected ByteBuffer _properties
protected final Map<String,Integer> _propertyIndex
public TrieProvider(String copyright, byte[] strings, byte[] properties, byte[] devices, short[] lookupList, long nodesLength, long nodesOffset, TriePool pool) throws FileNotFoundException
copyright - The copyright notice for the data file.strings - Array containing all Strings in the output.properties - Array of properties.devices - Array of devices.lookupList - Lookups data array.nodesLength - The length of the node data.nodesOffset - The position of the start of the nodes in the file
provided.pool - Pool connected to the data source.FileNotFoundException - indicates device data file was not found.public List<String> propertyNames()
public List<String> getHttpHeaders()
public String getUserAgent(String userAgent) throws Exception
userAgent - user agent to matchException - indicates an exception occurredpublic int getDeviceIndex(String userAgent) throws Exception
userAgent - user agent to get device index of.Exception - indicates an exception occurredpublic String getDeviceId(int deviceIndex)
deviceIndex - index of the device whose Id should be returnedpublic Map<String,Integer> getDeviceIndexes(Map<String,String> headers) throws IOException, Exception
headers - Collection of HTTP headers and values.IOException - if there was a problem accessing data file.Exceptionpublic String getPropertyValue(int deviceIndex, String property)
deviceIndex - The index of the device whose property should be
returned.property - the name of the property required.public String getPropertyValue(Map<String,Integer> deviceIndexes, String property)
deviceIndexes - Http headers and their device index.property - The name of the property required.public String getDefaultPropertyValue(String propertyName)
propertyName - String representing name of the property required.public String getPropertyValue(Map<String,Integer> deviceIndexes, int propertyIndex)
deviceIndexes - Indexes for the device.propertyIndex - Index of the property required.public String getPropertyValue(int deviceIndex, int propertyIndex)
deviceIndex - Index for the device.propertyIndex - Index of the property required.public String getPropertyValueWithMultiHeaders(Map<String,String> headers, String propertyName) throws Exception
headers - Collection of HTTP headers and values.propertyName - Name of the property required.Exception - if there was a problem accessing data file.public String getPropertyValue(String userAgent, String propertyname) throws Exception
userAgent - User agent of the request.propertyname - Name of the property required.Exception - if there was a problem accessing data file.public void close()
close in interface Closeableclose in interface AutoCloseableprotected String getStringValue(int offset)
offset - integer offset.public static int sizeOfOffsets(TrieProvider.OffsetType offsetType)
offsetType - offset typeCopyright © 2017 51Degrees. All rights reserved.