public class Match extends Object
| Modifier and Type | Class and Description |
|---|---|
(package private) class |
Match.MatchState
Used to persist the match results to the cache.
|
private class |
Match.PossibleSignature
Used to represent a signature index and the number of times it occurs in
the matched nodes.
|
private class |
Match.PossibleSignatures
A custom linked list used to identify the most frequently occurring
signature indexes.
|
static interface |
Match.RankedSignatureIterator
Used to iterate over the closest signatures.
|
| Modifier and Type | Field and Description |
|---|---|
(package private) int |
closestSignaturesCount |
private Dataset |
dataSet
The data set used for the detection.
|
private Integer |
lowestScore
The current lowest score for the target user agent.
|
MatchMethods |
method |
int |
nextCharacterPositionIndex
The next character position to be checked.
|
private static Comparator<Node> |
nodeComparator
Comparator used to order the nodes by length with the shortest first.
|
private List<Node> |
nodes
List of nodes found for the match.
|
(package private) int |
nodesEvaluated |
(package private) Profile[] |
profiles |
private Map<String,String[]> |
results |
(package private) int |
rootNodesEvaluated |
private Signature |
signature |
private List<Signature> |
signatures |
(package private) int |
signaturesCompared |
(package private) int |
signaturesRead |
(package private) int |
stringsRead |
private String |
targetUserAgent |
private byte[] |
targetUserAgentArray |
| Constructor and Description |
|---|
Match(Dataset dataSet)
Constructs a new detection match ready to be used.
|
Match(Dataset dataSet,
String targetUserAgent)
Constructs a new detection match ready to be used to identify the
profiles associated with the target user agent.
|
| Modifier and Type | Method and Description |
|---|---|
private Match.PossibleSignatures |
buildInitialList(int[] list) |
void |
cleanTargetUserAgentArray()
Replaces any characters in the target user agent which are outside the
range the dataset used when it was built with question marks.
|
(package private) Match.RankedSignatureIterator |
getClosestSignatures()
Returns a distinct list of signatures which most closely match the target
user agent string.
|
int |
getClosestSignaturesCount()
The number of closest signatures returned for evaluation.
|
private int |
getClosestSignaturesForNode(int[] signatureIndexList,
Match.PossibleSignatures linkedList,
int maxCount,
int iteration) |
(package private) Dataset |
getDataSet() |
String |
getDeviceId()
The unique id of the Device.
|
int |
getDifference() |
(package private) int |
getExactSignatureIndex() |
(package private) int |
getIndexOf(Node node)
Returns the start character position of the node within the target user
agent, or -1 if the node does not exist.
|
Integer |
getLowestScore() |
MatchMethods |
getMethod()
The method used to obtain the match.
|
List<Node> |
getNodes() |
int |
getNodesEvaluated()
The number of nodes checked.
|
Profile[] |
getProfiles()
Array of profiles associated with the device that was found.
|
Map<String,String[]> |
getResults() |
int |
getRootNodesEvaluated()
The number of root nodes checked against the target user agent.
|
Signature |
getSignature()
The signature with the closest match to the user agent provided.
|
int |
getSignaturesCompared()
The number of signatures that were compared against the target user agent
if the Closest match method was used.
|
int |
getSignaturesRead()
The number of signatures read during the detection.
|
int |
getStringsRead()
The number of strings that were read from the data structure for the
match.
|
String |
getTargetUserAgent()
The target user agent string used for the detection.
|
byte[] |
getTargetUserAgentArray()
The user agent string as an ASCII byte array.
|
String |
getUserAgent()
The user agent of the matching device with irrelevant characters removed.
|
Values |
getValues(Property property)
Gets the values associated with the property name using the profiles
found by the match.
|
Values |
getValues(String propertyName)
Gets the values associated with the property name using the profiles
found by the match.
|
void |
incrNodesEvaluated() |
void |
incrStringsRead() |
private void |
init(String targetUserAgent)
Initialises the match object ready for detection.
|
int |
insertNode(Node node)
Inserts the node into the list checking to find it's correct position in
the list first.
|
(package private) void |
reset(String targetUserAgent)
Resets the match for the user agent returning all the fields to the
values they would have when the match was first constructed.
|
(package private) void |
resetNextCharacterPositionIndex()
Reset the next character position index based on the length of the target
user agent and the root nodes.
|
void |
setLowestScore(Integer lowestScore) |
(package private) void |
setSignature(Signature signature) |
(package private) void |
setState(Match.MatchState state)
Sets the match properties based on the state information provided.
|
String |
toString()
A string representation of the nodes found from the target user agent.
|
void |
updateProfile(int profileId)
Override the profiles found by the match with the profileId provided.
|
private static final Comparator<Node> nodeComparator
private final Dataset dataSet
public int nextCharacterPositionIndex
private byte[] targetUserAgentArray
private String targetUserAgent
private Signature signature
public MatchMethods method
int signaturesRead
int signaturesCompared
int rootNodesEvaluated
int nodesEvaluated
int stringsRead
int closestSignaturesCount
Profile[] profiles
private Integer lowestScore
public Match(Dataset dataSet)
dataSet - data set to be used for this matchpublic Match(Dataset dataSet, String targetUserAgent) throws UnsupportedEncodingException
dataSet - data set to be used for this matchtargetUserAgent - user agent to identifyUnsupportedEncodingException - indicates an Unsupported Encoding
exception occurredpublic byte[] getTargetUserAgentArray()
public String getTargetUserAgent()
public Signature getSignature()
void setSignature(Signature signature)
void reset(String targetUserAgent) throws UnsupportedEncodingException
targetUserAgent - UnsupportedEncodingExceptionvoid setState(Match.MatchState state)
state - of a previous match from the cache.private void init(String targetUserAgent) throws UnsupportedEncodingException
targetUserAgent - UnsupportedEncodingExceptionpublic int getDifference()
public MatchMethods getMethod()
public int getSignaturesRead()
public int getSignaturesCompared()
public int getRootNodesEvaluated()
public int getNodesEvaluated()
public int getStringsRead()
public int getClosestSignaturesCount()
public String getDeviceId() throws IOException
IOException - signals an I/O exception occurredpublic Profile[] getProfiles() throws IOException
IOException - indicates an I/O exception occurredpublic String getUserAgent()
void resetNextCharacterPositionIndex()
int getExactSignatureIndex()
throws IOException
IOExceptionMatch.RankedSignatureIterator getClosestSignatures() throws IOException
IOExceptionprivate int getClosestSignaturesForNode(int[] signatureIndexList,
Match.PossibleSignatures linkedList,
int maxCount,
int iteration)
private Match.PossibleSignatures buildInitialList(int[] list)
public Integer getLowestScore()
public void setLowestScore(Integer lowestScore)
public void incrStringsRead()
public void incrNodesEvaluated()
Dataset getDataSet()
public Values getValues(Property property) throws IOException
property - The property whose values are requiredIOException - indicates an I/O exception occurredpublic Values getValues(String propertyName) throws IOException
propertyName - The property name whose values are requiredIOException - indicates an I/O exception occurredpublic Map<String,String[]> getResults() throws IOException
IOExceptionpublic void cleanTargetUserAgentArray()
int getIndexOf(Node node) throws IOException
node - IOExceptionpublic void updateProfile(int profileId)
throws IOException
profileId - The ID of the profile to replace the existing componentIOException - indicates an I/O exception occurredpublic String toString()
public int insertNode(Node node)
node - The node to be added to the match list