fiftyone.mobile.detection
Class Dataset

java.lang.Object
  extended by fiftyone.mobile.detection.Dataset
All Implemented Interfaces:
Disposable

public class Dataset
extends Object
implements Disposable

Data set used for device detection created by the reader classes.

The Memory.Reader and Stream.Reader factories should be used to create detector data sets. They can not be constructed directly from external code.

All information about the detector data set is exposed in this class including meta data and data used for device detection in the form of lists.

Detector data sets created using the factory using a file must be disposed of to ensure any readers associated with the file are closed elegantly.

For more information see http://51degrees.mobi/Support/Documentation/Java


Field Summary
 int age
          Age of the data in months when exported.
private  Component browsers
           
 ReadonlyList<Component> components
           
protected  String copyright
           
protected  int copyrightOffset
           
private  Component crawlers
           
 int csvBufferLength
          The number of bytes to allocate to a buffer returning CSV format data for a match.
 int deviceCombinations
          The number of unique device combinations available in the data set.
private  boolean disposed
           
protected  String format
           
protected  int formatOffset
           
 Guid guid
           
private  Component hardware
           
 byte highestCharacter
          The highest character the character trees can contain.
 int jsonBufferLength
          The number of bytes to allocate to a buffer returning JSON format data for a match.
 byte lowestCharacter
          The lowest character the character trees can contain.
 ReadonlyList<Map> maps
           
 int maxSignatures
          The maximum number of signatures that can be checked.
 int maxSignaturesClosest
          The maximum number of signatures that could possibly be returned during a closest match.
 short maxUserAgentLength
          The maximum length of a user agent string.
 short maxValues
          The maximum number of values that can be returned by a profile and a property supporting a list of values.
 int minUserAgentCount
          The minimum number of times a user agent should have been seen before it was included in the dataset.
private  short minUserAgentLength
          The minimum length of a user agent string.
private  String name
           
protected  int nameOffset
           
 Date nextUpdate
          The date the data set is next expected to be updated by 51Degrees.
 ReadonlyList<Node> nodes
          List of nodes the data set contains.
 ReadonlyList<ProfileOffset> profileOffsets
          List of profile offsets the data set contains.
 ReadonlyList<Profile> profiles
          A list of all the possible profiles the data set contains.
 ReadonlyList<Property> properties
           
 Date published
          The date the data set was published.
 ReadonlyList<RankedSignatureIndex> rankedSignatureIndexes
          A list of signature indexes ordered in ascending order of rank.
 ReadonlyList<Node> rootNodes
          Nodes for each of the possible character positions in the user agent.
private  int signatureNodesCount
           
private  int signatureProfilesCount
           
 ReadonlyList<Signature> signatures
          A list of all the signatures the data set contains.
private  Component software
           
 ReadonlyList<AsciiString> strings
          A list of ASCII byte arrays for strings used by the dataset.
 ReadonlyList<Value> values
           
 Version version
          The version of the data set.
 int xmlBufferLength
          The number of bytes to allocate to a buffer returning XML format data for a match.
 
Constructor Summary
Dataset(BinaryReader reader)
          Constructs a new data set ready to have lists of data assigned to it.
 
Method Summary
 void dispose()
           
 Profile findProfile(int profileId)
          Searches the list of profile Ids and returns the profile if the profile id is valid.
 Property get(String propertyName)
           
 Component getBrowsers()
          The browser component.
 Component getComponent(String componentName)
          Returns the Component associated with the name provided.
 ReadonlyList<Component> getComponents()
          A list of all the components the data set contains.
 String getCopyright()
          The copyright notice associated with the data set.
 Component getCrawlers()
          The crawler component.
 boolean getDisposed()
          Indicates if the data set has been disposed.
 String getFormat()
          The name of the property map used to create the dataset.
 Component getHardware()
          The hardware component.
 ReadonlyList<Map> getMaps()
          A list of all property maps the data set contains.
 short getMinUserAgentLength()
           
 String getName()
          The common name of the data set.
 ReadonlyList<Node> getNodes()
          List of nodes the data set contains.
 int getNodesCount()
           
 double getPercentageNodeCacheMisses()
          The percentage of requests for nodes which were not already contained in the cache.
 double getPercentageProfilesCacheMisses()
          The percentage of requests for profiles which were not already contained in the cache.
 double getPercentageSignatureCacheMisses()
          The percentage of requests for signatures which were not already contained in the cache.
 double getPercentageStringsCacheMisses()
          The percentage of requests for strings which were not already contained in the cache.
 double getPercentageValuesCacheMisses()
          The percentage of requests for values which were not already contained in the cache.
 ReadonlyList<Profile> getProfiles()
          A list of all the possible profiles the data set contains.
 int getProfilesCount()
           
 ReadonlyList<Property> getProperties()
          A list of all properties the data set contains.
 ReadonlyList<Signature> getSignatures()
          List of signatures the data set contains.
 Component getSoftware()
          The software component.
 ReadonlyList<Value> getValues()
          A list of all property values the data set contains.
 void init()
          Called after the entire data set has been loaded to ensure any further initialisation steps that require other items in the data set can be completed.
private static Date readDate(BinaryReader reader)
          Reads a date in year, month and day order from the reader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

disposed

private boolean disposed

published

public final Date published
The date the data set was published.


nextUpdate

public final Date nextUpdate
The date the data set is next expected to be updated by 51Degrees.


minUserAgentCount

public final int minUserAgentCount
The minimum number of times a user agent should have been seen before it was included in the dataset.


version

public final Version version
The version of the data set.


maxUserAgentLength

public final short maxUserAgentLength
The maximum length of a user agent string.


minUserAgentLength

private final short minUserAgentLength
The minimum length of a user agent string.


lowestCharacter

public final byte lowestCharacter
The lowest character the character trees can contain.


highestCharacter

public final byte highestCharacter
The highest character the character trees can contain.


deviceCombinations

public final int deviceCombinations
The number of unique device combinations available in the data set.


maxSignatures

public final int maxSignatures
The maximum number of signatures that can be checked. Needed to avoid bogus user agents which deliberately require so many signatures to be checked that performance is degraded.


maxValues

public final short maxValues
The maximum number of values that can be returned by a profile and a property supporting a list of values.


csvBufferLength

public final int csvBufferLength
The number of bytes to allocate to a buffer returning CSV format data for a match.


jsonBufferLength

public final int jsonBufferLength
The number of bytes to allocate to a buffer returning JSON format data for a match.


xmlBufferLength

public final int xmlBufferLength
The number of bytes to allocate to a buffer returning XML format data for a match.


maxSignaturesClosest

public final int maxSignaturesClosest
The maximum number of signatures that could possibly be returned during a closest match.


guid

public final Guid guid

age

public final int age
Age of the data in months when exported.


hardware

private Component hardware

software

private Component software

browsers

private Component browsers

crawlers

private Component crawlers

copyright

protected String copyright

copyrightOffset

protected final int copyrightOffset

nameOffset

protected final int nameOffset

name

private String name

formatOffset

protected final int formatOffset

format

protected String format

components

public ReadonlyList<Component> components

maps

public ReadonlyList<Map> maps

properties

public ReadonlyList<Property> properties

values

public ReadonlyList<Value> values

signatures

public ReadonlyList<Signature> signatures
A list of all the signatures the data set contains.


rankedSignatureIndexes

public ReadonlyList<RankedSignatureIndex> rankedSignatureIndexes
A list of signature indexes ordered in ascending order of rank. Used by the node ranked signature indexes lists to identify the corresponding signature.


profiles

public ReadonlyList<Profile> profiles
A list of all the possible profiles the data set contains.


nodes

public ReadonlyList<Node> nodes
List of nodes the data set contains.


rootNodes

public ReadonlyList<Node> rootNodes
Nodes for each of the possible character positions in the user agent.


profileOffsets

public ReadonlyList<ProfileOffset> profileOffsets
List of profile offsets the data set contains.


strings

public ReadonlyList<AsciiString> strings
A list of ASCII byte arrays for strings used by the dataset.


signatureProfilesCount

private int signatureProfilesCount

signatureNodesCount

private int signatureNodesCount
Constructor Detail

Dataset

public Dataset(BinaryReader reader)
        throws IOException
Constructs a new data set ready to have lists of data assigned to it.

Parameters:
reader - Reader connected to the source data structure and positioned to start reading
Throws:
IOException
Method Detail

getPercentageSignatureCacheMisses

public double getPercentageSignatureCacheMisses()
The percentage of requests for signatures which were not already contained in the cache.

A value is only returned when operating in Stream mode.


getPercentageNodeCacheMisses

public double getPercentageNodeCacheMisses()
The percentage of requests for nodes which were not already contained in the cache.

A value is only returned when operating in Stream mode.


getPercentageStringsCacheMisses

public double getPercentageStringsCacheMisses()
The percentage of requests for strings which were not already contained in the cache.

A value is only returned when operating in Stream mode.


getPercentageProfilesCacheMisses

public double getPercentageProfilesCacheMisses()
The percentage of requests for profiles which were not already contained in the cache.

A value is only returned when operating in Stream mode.


getPercentageValuesCacheMisses

public double getPercentageValuesCacheMisses()
The percentage of requests for values which were not already contained in the cache.

A value is only returned when operating in Stream mode.


getDisposed

public boolean getDisposed()
Indicates if the data set has been disposed.


getHardware

public Component getHardware()
                      throws IOException
The hardware component.

Throws:
IOException

getSoftware

public Component getSoftware()
                      throws IOException
The software component.

Throws:
IOException

getBrowsers

public Component getBrowsers()
                      throws IOException
The browser component.

Throws:
IOException

getCrawlers

public Component getCrawlers()
                      throws IOException
The crawler component.

Throws:
IOException

getCopyright

public String getCopyright()
                    throws IOException
The copyright notice associated with the data set.

Throws:
IOException

getName

public String getName()
               throws IOException
The common name of the data set.

Throws:
IOException

getFormat

public String getFormat()
                 throws IOException
The name of the property map used to create the dataset.

Throws:
IOException

getComponents

public ReadonlyList<Component> getComponents()
A list of all the components the data set contains.


getMaps

public ReadonlyList<Map> getMaps()
A list of all property maps the data set contains.


getProperties

public ReadonlyList<Property> getProperties()
A list of all properties the data set contains.


getValues

public ReadonlyList<Value> getValues()
A list of all property values the data set contains.


getSignatures

public ReadonlyList<Signature> getSignatures()
List of signatures the data set contains.


readDate

private static Date readDate(BinaryReader reader)
Reads a date in year, month and day order from the reader.

Parameters:
reader - Reader positioned at the start of the date
Returns:
A date time with the year, month and day set from the reader

getNodes

public ReadonlyList<Node> getNodes()
List of nodes the data set contains.


getProfiles

public ReadonlyList<Profile> getProfiles()
A list of all the possible profiles the data set contains.


getMinUserAgentLength

public short getMinUserAgentLength()

init

public void init()
          throws IOException
Called after the entire data set has been loaded to ensure any further initialisation steps that require other items in the data set can be completed.

Throws:
IOException

getComponent

public Component getComponent(String componentName)
                       throws IOException
Returns the Component associated with the name provided.

Parameters:
componentName -
Returns:
The component matching the name, or null if no component is found
Throws:
IOException

get

public Property get(String propertyName)
             throws IOException
Throws:
IOException

getProfilesCount

public int getProfilesCount()

getNodesCount

public int getNodesCount()

findProfile

public Profile findProfile(int profileId)
                    throws IOException
Searches the list of profile Ids and returns the profile if the profile id is valid.

Parameters:
profileId - Id of the profile to be found
Returns:
Profile related to the id, or null if none found
Throws:
IOException

dispose

public void dispose()
Specified by:
dispose in interface Disposable