Class ColumnNumberManager


  • public class ColumnNumberManager
    extends java.lang.Object
    Helper class maintaining a record of occupied columns and an index to the next non-occupied column.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int columnNumber  
      private java.util.BitSet usedColumnIndices
      We use the term "index" instead of "number" because, unlike column numbers, it's 0-based.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) int getCurrentColumnNumber()
      Returns the number of the column that shall receive the next parsed cell.
      boolean isColumnNumberUsed​(int colNr)
      Checks whether a given column-number is already in use for the current row.
      (package private) void prepareForNextRow​(java.util.List pendingSpans)
      Resets the record of occupied columns, taking into account columns already occupied by previous spanning cells, and computes the number of the first free column.
      (package private) void signalUsedColumnNumbers​(int start, int end)
      Flags columns start to end as occupied, and updates the number of the next available column.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • columnNumber

        private int columnNumber
      • usedColumnIndices

        private java.util.BitSet usedColumnIndices
        We use the term "index" instead of "number" because, unlike column numbers, it's 0-based.
    • Constructor Detail

      • ColumnNumberManager

        public ColumnNumberManager()
    • Method Detail

      • getCurrentColumnNumber

        int getCurrentColumnNumber()
        Returns the number of the column that shall receive the next parsed cell.
        Returns:
        a column number, 1-based
      • signalUsedColumnNumbers

        void signalUsedColumnNumbers​(int start,
                                     int end)
        Flags columns start to end as occupied, and updates the number of the next available column.
        Parameters:
        start - start number, inclusive, 1-based
        end - end number, inclusive
      • prepareForNextRow

        void prepareForNextRow​(java.util.List pendingSpans)
        Resets the record of occupied columns, taking into account columns already occupied by previous spanning cells, and computes the number of the first free column.
        Parameters:
        pendingSpans - List<PendingSpan> of possible spans over the next row
      • isColumnNumberUsed

        public boolean isColumnNumberUsed​(int colNr)
        Checks whether a given column-number is already in use for the current row.
        Parameters:
        colNr - the column-number to check
        Returns:
        true if column-number is already occupied