Class LZWCodec.LZWNode

java.lang.Object
com.helger.base.codec.impl.LZWCodec.LZWNode
Enclosing class:
LZWCodec

protected static class LZWCodec.LZWNode extends Object
A single LZW node
Author:
Philip Helger
  • Constructor Details

    • LZWNode

      public LZWNode()
      Default constructor for the root node (table index is -1).
    • LZWNode

      public LZWNode(@Nonnegative int nTableIndex)
      Constructor with a specific table index.
      Parameters:
      nTableIndex - The table index for this node. Must be between 0 and LZWCodec.AbstractLZWDictionary.MAX_CODE (inclusive).
  • Method Details

    • getTableIndex

      @Nonnegative public int getTableIndex()
      Returns:
      The table index of this node. Must be ≥ 0.
      Throws:
      IllegalStateException - if this is the root node (no table index assigned).
    • setChildNode

      public void setChildNode(@Nonnegative byte nIndex, @NonNull LZWCodec.LZWNode aNode)
      Set a child node at the specified byte index.
      Parameters:
      nIndex - The byte index (0-255) at which the child node is set.
      aNode - The child node to set. May not be null.
    • getChildNode

      public @Nullable LZWCodec.LZWNode getChildNode(byte nIndex)
      Get the child node at the specified byte index.
      Parameters:
      nIndex - The byte index (0-255) of the child node to retrieve.
      Returns:
      The child node at the given index, or null if no child exists at that index.
    • getChildNode

      public @Nullable LZWCodec.LZWNode getChildNode(byte @NonNull [] aBuffer)
      This will traverse the tree until it gets to the sub node. This will return null if the node does not exist.
      Parameters:
      aBuffer - The path to the node.
      Returns:
      The node that resides at the data path.
    • toString

      public String toString()
      Overrides:
      toString in class Object