Class PositiveIntegerColumn

java.lang.Object
io.github.kelsoncm.fwf.columns.AbstractColumn
io.github.kelsoncm.fwf.columns.PositiveIntegerColumn
Direct Known Subclasses:
PositiveDecimalColumn

public class PositiveIntegerColumn extends AbstractColumn
Positive integer column represented as a zero-padded string of digits.
  • Constructor Details

    • PositiveIntegerColumn

      public PositiveIntegerColumn(String name, int size, String description)
      Constructs a new PositiveIntegerColumn with a name, size, and description.
      Parameters:
      name - the column name
      size - the column size in characters
      description - human-readable description
    • PositiveIntegerColumn

      public PositiveIntegerColumn(String name, int size)
      Constructs a new PositiveIntegerColumn with a name and size.
      Parameters:
      name - the column name
      size - the column size in characters
  • Method Details

    • toValue

      public Object toValue(String slice)
      Converts a raw fixed-width zero-padded integer slice into an Integer value.
      Overrides:
      toValue in class AbstractColumn
      Parameters:
      slice - raw fixed-width substring
      Returns:
      parsed integer value
      Throws:
      IllegalArgumentException - if slice is not a valid non-negative integer
    • toStr

      public String toStr(Object value)
      Formats a non-negative Number or null into a zero-padded string of exact column size.
      Specified by:
      toStr in class AbstractColumn
      Parameters:
      value - Number or null to format
      Returns:
      zero-padded string of size AbstractColumn.getSize()
      Throws:
      IllegalArgumentException - if value is negative or not a valid number