public class Node extends BaseEntity implements Comparable<Node>
| Modifier and Type | Class and Description |
|---|---|
(package private) class |
Node.NodeNumericIndexIterator |
| Modifier and Type | Field and Description |
|---|---|
private byte[] |
characters |
private int |
characterStringOffset
The offset in the strings data structure to the string that contains all
the characters of the node.
|
private NodeIndex[] |
children
A list of all the child node indexes.
|
static int |
MIN_LENGTH
The minimum length of a node assuming no node indexes or signatures.
|
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.
|
private NodeNumericIndex[] |
numericChildren
An array of all the numeric children.
|
private Node |
parent |
(package private) int |
parentIndex
The parent index for this node.
|
short |
position
The position of the first character the node represents in the signature
or target user agent.
|
private static Range[] |
ranges |
private Node |
root |
private int[] |
signatureIndexes
A list of all the signature indexes that relate to this node.
|
| 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(Match match)
Returns a complete node for the match object provided.
|
Node |
getCompleteNumericNode(Match match) |
private Integer |
getCurrentPositionAsNumeric(Match match)
Returns the node position as a number.
|
boolean |
getIsOverlap(Match match)
Returns true if any of the nodes in the match have overlapping characters
with this one.
|
private boolean |
getIsOverlap(Node node)
Returns true if the node overlaps with this one.
|
int |
getLength()
Returns the number of characters in the node tree.
|
(package private) Node |
getNextNode(Match match)
Returns the next node for the characters provided from the start index
for the number of characters specified.
|
private Integer |
getNumber(byte[] array,
int start,
int length)
Returns an integer representation of the characters between start and
end.
|
int |
getNumericChildrenLength() |
private Node.NodeNumericIndexIterator |
getNumericNodeIterator(int target)
Provides an iterator which provides the closest numeric children to the
target is ascending order of difference
|
(package private) Node |
getParent()
Returns the parent node for this node.
|
private Range |
getRange(int target)
Determines the range the target value falls between
|
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.
|
(package private) boolean |
isComplete()
Returns true if this node represents a completed sub string and the next
character position is set.
|
private static NodeIndex[] |
readNodeIndexes(Dataset dataSet,
BinaryReader reader,
int offset,
short count)
Used by the constructor to read the variable length list of child node
indexes associated with the node.
|
private static NodeNumericIndex[] |
readNodeNumericIndexes(Dataset dataSet,
BinaryReader reader,
short count)
Used by the constructor to read the variable length list of child node
numeric indexes associated with the node.
|
String |
toString()
Returns a string of spaces with the characters relating to this node
populated.
|
binarySearch, getDataSet, getIndex, readIntegerArraypublic static final int NODE_INDEX_LENGTH
public static final int NODE_NUMERIC_INDEX_LENGTH
public static final int MIN_LENGTH
private static final Range[] ranges
private final int[] signatureIndexes
private final NodeIndex[] children
private final NodeNumericIndex[] numericChildren
final int parentIndex
private final int characterStringOffset
public final short nextCharacterPosition
public final short position
private Node root
private Node parent
private byte[] characters
public Node(Dataset dataSet, int offset, BinaryReader reader)
dataSet - The data set the node is contained withinoffset - The offset in the data structure to the nodepublic Node getRoot() throws IOException
IOExceptionNode getParent() throws IOException
IOExceptionboolean isComplete()
public int getLength()
throws IOException
IOExceptionpublic byte[] getCharacters()
throws IOException
IOExceptionpublic int[] getRankedSignatureIndexes()
public int getChildrenLength()
public int getNumericChildrenLength()
private static NodeNumericIndex[] readNodeNumericIndexes(Dataset dataSet, BinaryReader reader, short count)
dataSet - The data set the node is contained withinreader - Reader connected to the source data structure and
positioned to start readingcount - The number of elements to read into the arrayprivate static NodeIndex[] readNodeIndexes(Dataset dataSet, BinaryReader reader, int offset, short count)
dataSet - The data set the node is contained withinreader - Reader connected to the source data structure and
positioned to start readingoffset - The offset in the data structure to the nodecount - The number of elements to read into the arraypublic void init()
throws IOException
IOExceptionpublic Node getCompleteNumericNode(Match match) throws IOException
IOExceptionprivate Node.NodeNumericIndexIterator getNumericNodeIterator(int target)
target - value of the sub string in the user agentprivate Range getRange(int target)
target - value whose range is requiredprivate Integer getCurrentPositionAsNumeric(Match match)
match - results including the target user agentprivate Integer getNumber(byte[] array, int start, int length)
array - Array of characters with numeric characters present between
start and endstart - The first character to use to convert to a numberlength - The number of characters to use in the conversionpublic Node getCompleteNode(Match match) throws IOException
match - results including the target user agentIOExceptionNode getNextNode(Match match) throws IOException
match - Match results including the target user agentIOExceptionprivate boolean getIsOverlap(Node node) throws IOException
node - IOExceptionpublic boolean getIsOverlap(Match match) throws IOException
match - IOExceptionpublic void addCharacters(byte[] values)
throws IOException
values - IOExceptionpublic String toString()
public int compareTo(Node other)
compareTo in interface Comparable<Node>other - node to be compared