public abstract class Node extends BaseEntity implements Comparable<Node>
Every character position in the string contains a tree of nodes which are evaluated until either a complete node is found, or no nodes are found that match at the character position.
The list of Signature entities is in ascending order of the complete nodes which form the sub strings of the signature. Complete nodes are found at detection time for the target User-Agent and then used to search for a corresponding signature. If one does not exist then Signatures associated with the nodes that were found are evaluated to find one that is closest to the target User-Agent.
Root nodes are the first node at a character position. It's children are based on sequences of characters that if present lead to the next node. A complete node will represent a sub string within the User-Agent.
For more information see https://51degrees.com/Support/Documentation/Java
| Modifier and Type | Field and Description |
|---|---|
protected NodeIndex[] |
children
A list of all the child node indexes.
|
protected short |
childrenCount
Number of children associated with the node.
|
short |
nextCharacterPosition
The next character position to the left of this node or a negative number
if this is not a complete node.
|
static int |
NODE_INDEX_LENGTH
The length of a node index.
|
static int |
NODE_NUMERIC_INDEX_LENGTH
The length of a numeric node index.
|
protected long |
nodeStartStreamPosition
The position in the stream of the first byte of the node.
|
protected short |
numericChildrenCount
Number of numeric children associated with the node.
|
short |
position
The position of the first character the node represents in the signature
or target User-Agent.
|
protected int |
rankedSignatureCount
Number of ranked signature indexes associated with the node.
|
dataSet, index| Constructor and Description |
|---|
Node(Dataset dataSet,
int offset,
BinaryReader reader)
Constructs a new instance of Node
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCharacters(byte[] values)
Adds the characters for this node to the values array.
|
int |
compareTo(Node other)
Compares one node to another for the purposes of determining the
signature the node relates to.
|
byte[] |
getCharacters()
Gets an array containing all the characters of the node.
|
int |
getChildrenLength() |
Node |
getCompleteNode(MatchState state)
Returns a complete node for the match object provided.
|
Node |
getCompleteNumericNode(MatchState state)
Gets a complete node, or if one isn't available exactly the closest
numeric one to the target User-Agent at the current position.
|
boolean |
getIsOverlap(MatchState state)
Returns true if any of the nodes in the match have overlapping characters
with this one.
|
int |
getLength()
Returns the number of characters in the node tree.
|
abstract NodeNumericIndex[] |
getNumericChildren() |
int |
getNumericChildrenLength() |
abstract int[] |
getRankedSignatureIndexes() |
Node |
getRoot()
Returns the root node for this node.
|
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.
|
NodeNumericIndex[] |
readNodeNumericIndexes(Dataset dataSet,
BinaryReader reader,
short count)
Used by the constructor to read the variable length list of child
indexes that contain numeric values.
|
String |
toString()
Returns a string of spaces with the characters relating to this node
populated.
|
compareTo, compareTo, getDataSet, getIndex, getIsNumeric, getNumber, readIntegerArraypublic static final int NODE_INDEX_LENGTH
public static final int NODE_NUMERIC_INDEX_LENGTH
protected final long nodeStartStreamPosition
protected final short numericChildrenCount
protected final short childrenCount
protected NodeIndex[] children
public final short nextCharacterPosition
public final short position
protected int rankedSignatureCount
public Node(Dataset dataSet, int offset, BinaryReader reader)
dataSet - The data set the node is contained within.offset - The offset in the data structure to the node.reader - BinaryReader object to be used.public Node getRoot() throws IOException
IOException - if there was a problem accessing data file.public int compareTo(Node other)
compareTo in interface Comparable<Node>other - node to be compared.public int getLength()
throws IOException
IOException - if there was a problem accessing data file.public byte[] getCharacters()
throws IOException
IOException - if there was a problem accessing data file.public NodeNumericIndex[] readNodeNumericIndexes(Dataset dataSet, BinaryReader reader, short count)
dataSet - The data set the node is contained within.reader - Reader connected to the source data structure and
positioned to start reading.count - The number of node indexes that need to be read.public abstract int[] getRankedSignatureIndexes()
throws IOException
IOException - if there was a problem accessing data file.public int getChildrenLength()
public int getNumericChildrenLength()
public abstract NodeNumericIndex[] getNumericChildren() throws IOException
IOException - if there was a problem accessing data file.public void init()
throws IOException
This method should not be called as it is part of the internal logic.
IOException - if there was a problem accessing data file.public Node getCompleteNumericNode(MatchState state) throws IOException
state - current working state of the matching processIOException - if there was a problem accessing data file.public Node getCompleteNode(MatchState state) throws IOException
state - current working state of the matching process.IOException - if there was a problem accessing data file.public boolean getIsOverlap(MatchState state) throws IOException
state - current working state of the matching processIOException - if there was a problem accessing data file.public void addCharacters(byte[] values)
throws IOException
values - array to add characters to.IOException - if there was a problem accessing data file.Copyright © 2015 51Degrees. All rights reserved.