fiftyone.mobile.detection.entities
Class NodeIndex

java.lang.Object
  extended by fiftyone.mobile.detection.entities.BaseEntity
      extended by fiftyone.mobile.detection.entities.NodeIndex
All Implemented Interfaces:
Comparable<NodeIndex>

public class NodeIndex
extends BaseEntity
implements Comparable<NodeIndex>

A node index contains the characters and related child nodes of the current node should any of the characters match at the position.


Field Summary
private  byte[] characters
           
(package private)  boolean isString
          True if the value is an index to a sub string.
private  Node node
           
(package private)  int relatedNodeOffset
          The node index for the sequence of characters.
private  byte[] value
          The value of the node index.
 
Constructor Summary
NodeIndex(Dataset dataSet, int index, boolean isString, byte[] value, int relatedNodeOffset)
          Constructs a new instance of NodeIndex
 
Method Summary
(package private)  int compareTo(byte[] other, int startIndex)
          Compares a byte array of characters at the position provided to the array of characters for this node.
 int compareTo(NodeIndex other)
          Compares this node index to another.
(package private)  byte[] getCharacters()
          Returns the characters related to this node index.
private static byte[] getCharacters(Dataset dataSet, boolean isString, byte[] value)
          Returns the characters the node index relates to.
(package private)  Node getNode()
          The node this index relates to.
(package private)  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 byte[] nonZeros(byte[] value)
          Returns the non zero values in the array.
 String toString()
          Converts the node index into a string.
 
Methods inherited from class fiftyone.mobile.detection.entities.BaseEntity
binarySearch, getDataSet, getIndex, readIntegerArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

relatedNodeOffset

final int relatedNodeOffset
The node index for the sequence of characters.


isString

final boolean isString
True if the value is an index to a sub string. False if the value is 1 to 4 consecutive characters.


value

private final byte[] value
The value of the node index. Interpretation depends on IsSubString. If IsSubString is true the 4 bytes represent an offset in the strings data structure to 5 or more characters. If IsSubString is false the 4 bytes are character values themselves where 0 values are ignored.


characters

private byte[] characters

node

private Node node
Constructor Detail

NodeIndex

public NodeIndex(Dataset dataSet,
                 int index,
                 boolean isString,
                 byte[] value,
                 int relatedNodeOffset)
Constructs a new instance of NodeIndex

Parameters:
dataSet - The data set the node is contained within
index - The index of this object in the Node
isString - True if the value is an integer offset to a string, or false if the value is an array of characters to be used by the node.
value - Array of bytes representing an integer offset to a string, or the array of characters to be used by the node.
relatedNodeOffset - The offset in the list of nodes to the node the index relates to
Method Detail

getCharacters

byte[] getCharacters()
               throws IOException
Returns the characters related to this node index.

Throws:
IOException

getNode

Node getNode()
       throws IOException
The node this index relates to.

Throws:
IOException

init

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

getCharacters

private static byte[] getCharacters(Dataset dataSet,
                                    boolean isString,
                                    byte[] value)
                             throws IOException
Returns the characters the node index relates to.

Parameters:
dataSet -
isString -
value -
Returns:
Throws:
IOException

nonZeros

private static byte[] nonZeros(byte[] value)
Returns the non zero values in the array.

Parameters:
value - An array of values.
Returns:
The non zero values as an array.

compareTo

int compareTo(byte[] other,
              int startIndex)
        throws IOException
Compares a byte array of characters at the position provided to the array of characters for this node.

Parameters:
other - Array of characters to compare
startIndex - The index in the other array to the required characters
Returns:
The relative position of the node in relation to the other array
Throws:
IOException

compareTo

public int compareTo(NodeIndex other)
Compares this node index to another.

Specified by:
compareTo in interface Comparable<NodeIndex>
Parameters:
other - The node index to compare
Returns:
Indication of relative value based on ComponentId field

toString

public String toString()
Converts the node index into a string.

Overrides:
toString in class Object
Returns:
a string representation of the node characters