Class FixedWidthIntListLabel

All Implemented Interfaces:
FlyweightPrototype<Label>, Label

public class FixedWidthIntListLabel
extends AbstractIntListLabel
A list of integers represented in fixed width. The provided width must be smaller than 32. Each list is prefixed by its length written in γ coding.
  • Constructor Details

    • FixedWidthIntListLabel

      public FixedWidthIntListLabel​(String key, int width, int[] value)
      Creates a new fixed-width int label.
      Parameters:
      key - the (only) key of this label.
      width - the label width (in bits).
      value - the value of this label.
    • FixedWidthIntListLabel

      public FixedWidthIntListLabel​(String key, int width)
      Creates a new fixed-width label with an empty list.
      Parameters:
      key - the (only) key of this label.
      width - the label width (in bits).
    • FixedWidthIntListLabel

      public FixedWidthIntListLabel​(String... arg)
      Creates a new fixed-width integer label using the given key and width with an empty list.
      Parameters:
      arg - two strings containing the key and the width of this label.
  • Method Details

    • copy

      public Label copy()
      Description copied from interface: Label
      Returns a copy of this label.
      Returns:
      a new label that copies this one.
    • fromBitStream

      public int fromBitStream​(InputBitStream inputBitStream, int sourceUnused) throws IOException
      Description copied from interface: Label
      Fills this label with data from the given input bit stream, knowing the source node of the arc. If Label.fixedWidth() is not negative, the value returned must coincide with Label.fixedWidth(). This method is optional.
      Parameters:
      inputBitStream - an input bit stream offering a label.
      sourceUnused - the source node.
      Returns:
      the number of bits read to fill this label.
      Throws:
      IOException
    • toBitStream

      public int toBitStream​(OutputBitStream outputBitStream, int sourceUnused) throws IOException
      Description copied from interface: Label
      Writes out this label to the given input bit stream, in self-delimiting form, knowing the source node of the arc. If Label.fixedWidth() is not negative, the value returned must coincide with Label.fixedWidth(). This method is optional.
      Parameters:
      outputBitStream - an output bit stream where the label will be written.
      sourceUnused - the source node.
      Returns:
      the number of bits written.
      Throws:
      IOException
    • fixedWidth

      public int fixedWidth()
      Returns -1 (the fixed width refers to a single integer, not to the entire list).
      Returns:
      -1;
    • toString

      public String toString()
      Overrides:
      toString in class AbstractIntListLabel
    • toSpec

      public String toSpec()
      Description copied from interface: Label
      Returns a string representing the specification of this label.

      Each label class can be instantiated in several ways (e.g., FixedWidthIntLabel requires a name for the well-known attribute and a number of bits). This method must return a representation that can be used by ObjectParser to instantiate the class, and consequently there must exist a matching constructor whose arguments are strings.

      There is an equation that must be always satisfied:

       ObjectParser.fromSpec(x.toSpec()).toSpec().equals(x.toSpec())
       
      Returns:
      a string representing the specification of this label.
      See Also:
      ObjectParser.fromSpec(String, Class)