Class PositiveDecimalColumn


public class PositiveDecimalColumn extends PositiveIntegerColumn
Positive decimal column with a fixed number of decimal places, formatted with leading zeros.
  • Field Details

    • decimals

      protected final int decimals
      Number of implicit decimal places.
  • Constructor Details

    • PositiveDecimalColumn

      public PositiveDecimalColumn(String name, int size, int decimals, String description)
      Constructs a new PositiveDecimalColumn with a name, size, decimals, and description.
      Parameters:
      name - the column name
      size - the total column size in characters
      decimals - number of implicit decimal places, must be > 0 and < size
      description - human-readable description
      Throws:
      IllegalArgumentException - if decimals <= 0 or size <= decimals
    • PositiveDecimalColumn

      public PositiveDecimalColumn(String name, int size, int decimals)
      Constructs a new PositiveDecimalColumn with a name, size, and decimals.
      Parameters:
      name - the column name
      size - the total column size in characters
      decimals - number of implicit decimal places
    • PositiveDecimalColumn

      public PositiveDecimalColumn(String name, int size)
      Constructs a new PositiveDecimalColumn with a name and size, defaulting to 2 decimals.
      Parameters:
      name - the column name
      size - the total column size in characters
  • Method Details

    • getDecimals

      public int getDecimals()
      Gets the number of implicit decimal places.
      Returns:
      number of decimal places
    • toValue

      public Object toValue(String slice)
      Converts a raw fixed-width zero-padded integer slice into a Double value with decimal precision.
      Overrides:
      toValue in class PositiveIntegerColumn
      Parameters:
      slice - raw fixed-width substring
      Returns:
      parsed Double value
      Throws:
      IllegalArgumentException - if slice is not a valid positive decimal string
    • toStr

      public String toStr(Object value)
      Formats a non-negative Double/Float or null into a zero-padded string of exact column size.
      Overrides:
      toStr in class PositiveIntegerColumn
      Parameters:
      value - Double, Float or null to format
      Returns:
      zero-padded decimal string of size AbstractColumn.getSize()
      Throws:
      IllegalArgumentException - if value is negative or not a Double/Float