Class AbstractSheet

java.lang.Object
org.spdx.spreadsheetstore.AbstractSheet
Direct Known Subclasses:
AnnotationsSheet, DocumentInfoSheet, ExternalRefsSheet, ExtractedLicenseInfoSheet, PackageInfoSheet, PerFileSheet, RelationshipsSheet, SnippetSheet

public abstract class AbstractSheet extends Object
Abstract class representing a workbook sheet used in storing structured data
Author:
Gary O'Neall
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.apache.poi.ss.usermodel.CellStyle
     
    static Pattern
    Pattern for parsing checksums
    protected org.spdx.library.ModelCopyManager
     
    protected org.apache.poi.ss.usermodel.CellStyle
     
    protected String
     
    protected int
     
    protected int
     
    protected static final short
     
    protected org.apache.poi.ss.usermodel.CellStyle
     
    protected int
     
    protected org.spdx.storage.IModelStore
     
    protected org.apache.poi.ss.usermodel.CellStyle
     
    protected org.apache.poi.ss.usermodel.Sheet
     
    protected org.apache.poi.ss.usermodel.Workbook
     
    protected org.apache.poi.ss.usermodel.CellStyle
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    AbstractSheet(org.apache.poi.ss.usermodel.Workbook workbook, String sheetName, org.spdx.storage.IModelStore modelStore, String documentUri, org.spdx.library.ModelCopyManager copyManager)
    Construct an AbstractSheet instance
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.apache.poi.ss.usermodel.Row
    Add a new row to the end of the sheet
    checksumsToString(Collection<org.spdx.library.model.v2.Checksum> checksumCollection)
    Converts a collection of Checksum objects into a string representation
    checksumToString(org.spdx.library.model.v2.Checksum checksum)
    Convert a Checksum object into its string representation
    void
    Clears all data from the worksheet
    static org.apache.poi.ss.usermodel.CellStyle
    createCenterStyle(org.apache.poi.ss.usermodel.Workbook wb)
    Creates a cell style with center alignment, without text wrapping
    static org.apache.poi.ss.usermodel.CellStyle
    createHeaderStyle(org.apache.poi.ss.usermodel.Workbook wb)
    Creates a header cell style for the workbook
    static org.apache.poi.ss.usermodel.CellStyle
    createLeftWrapStyle(org.apache.poi.ss.usermodel.Workbook wb)
    Creates a cell style with left alignment and text wrapping
    static List<String>
    Converts a comma-separated value (CSV) string into a list of strings
    int
    Return the first row number of the data rows
    int
    Return the number of data rows in the sheet
    org.apache.poi.ss.usermodel.Sheet
    Return the sheet managed by this class
    static String
    licensesToString(Collection<org.spdx.library.model.v2.license.AnyLicenseInfo> licenseCollection)
    Convert a collection of AnyLicenseInfo objects into a CSV string representation
    org.spdx.library.model.v2.Checksum
    Creates a Checksum from the parameters specified in the tag value
    void
    Resize the rows for a best fit.
    static String
    Convert a collection of strings to a comma-separated value string
    Collection<org.spdx.library.model.v2.Checksum>
    strToChecksums(String checksumsString)
    Convert a string representation of checksums into a collection of Checksum objects
    abstract String
    Verifies the integrity of the sheet's data

    Methods inherited from class java.lang.Object

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

    • CHECKSUM_PATTERN

      public static Pattern CHECKSUM_PATTERN
      Pattern for parsing checksums
    • FONT_SIZE

      protected static final short FONT_SIZE
      See Also:
    • checkboxStyle

      protected org.apache.poi.ss.usermodel.CellStyle checkboxStyle
    • dateStyle

      protected org.apache.poi.ss.usermodel.CellStyle dateStyle
    • greenWrapped

      protected org.apache.poi.ss.usermodel.CellStyle greenWrapped
    • redWrapped

      protected org.apache.poi.ss.usermodel.CellStyle redWrapped
    • yellowWrapped

      protected org.apache.poi.ss.usermodel.CellStyle yellowWrapped
    • workbook

      protected org.apache.poi.ss.usermodel.Workbook workbook
    • sheet

      protected org.apache.poi.ss.usermodel.Sheet sheet
    • lastRowNum

      protected int lastRowNum
    • firstCellNum

      protected int firstCellNum
    • firstRowNum

      protected int firstRowNum
    • modelStore

      protected org.spdx.storage.IModelStore modelStore
    • documentUri

      protected String documentUri
    • copyManager

      protected org.spdx.library.ModelCopyManager copyManager
  • Constructor Details

    • AbstractSheet

      public AbstractSheet(org.apache.poi.ss.usermodel.Workbook workbook, String sheetName, org.spdx.storage.IModelStore modelStore, @Nullable String documentUri, org.spdx.library.ModelCopyManager copyManager)
      Construct an AbstractSheet instance
      Parameters:
      workbook - Workbook where the sheet lives
      sheetName - Name of the sheet
      modelStore - Model store for creating typed values
      documentUri - URI for the document if known
      copyManager - The copy manager used for handling SPDX object copies.
  • Method Details

    • addRow

      protected org.apache.poi.ss.usermodel.Row addRow()
      Add a new row to the end of the sheet
      Returns:
      new row
    • clear

      public void clear()
      Clears all data from the worksheet
    • getFirstDataRow

      public int getFirstDataRow()
      Return the first row number of the data rows
      Returns:
      First data row number
    • getNumDataRows

      public int getNumDataRows()
      Return the number of data rows in the sheet
      Returns:
      Number of data rows.
    • getSheet

      public org.apache.poi.ss.usermodel.Sheet getSheet()
      Return the sheet managed by this class
      Returns:
      The Sheet object.
    • verify

      public abstract String verify()
      Verifies the integrity of the sheet's data
      Returns:
      A string describing any issues, or an empty string if valid.
    • createHeaderStyle

      public static org.apache.poi.ss.usermodel.CellStyle createHeaderStyle(org.apache.poi.ss.usermodel.Workbook wb)
      Creates a header cell style for the workbook
      Parameters:
      wb - Workbook where the style will be created.
      Returns:
      A CellStyle for header cells.
    • createLeftWrapStyle

      public static org.apache.poi.ss.usermodel.CellStyle createLeftWrapStyle(org.apache.poi.ss.usermodel.Workbook wb)
      Creates a cell style with left alignment and text wrapping
      Parameters:
      wb - Workbook where the style will be created.
      Returns:
      A CellStyle with left alignment and wrapping.
    • createCenterStyle

      public static org.apache.poi.ss.usermodel.CellStyle createCenterStyle(org.apache.poi.ss.usermodel.Workbook wb)
      Creates a cell style with center alignment, without text wrapping
      Parameters:
      wb - Workbook where the style will be created.
      Returns:
      A CellStyle with center alignment.
    • resizeRows

      public void resizeRows()
      Resize the rows for a best fit. Will not exceed maximum row height.
    • checksumsToString

      public String checksumsToString(Collection<org.spdx.library.model.v2.Checksum> checksumCollection) throws org.spdx.core.InvalidSPDXAnalysisException
      Converts a collection of Checksum objects into a string representation
      Parameters:
      checksumCollection - Collection of checksums.
      Returns:
      String containing checksums in the format "Algorithm: Value", with each checksum separated by a newline.
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException - If a checksum is invalid.
    • checksumToString

      public String checksumToString(org.spdx.library.model.v2.Checksum checksum) throws org.spdx.core.InvalidSPDXAnalysisException
      Convert a Checksum object into its string representation
      Parameters:
      checksum - Checksum object.
      Returns:
      String representation of the checksum in the format "Algorithm: Value".
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException - If the checksum is invalid.
    • strToChecksums

      public Collection<org.spdx.library.model.v2.Checksum> strToChecksums(String checksumsString) throws SpreadsheetException
      Convert a string representation of checksums into a collection of Checksum objects
      Parameters:
      checksumsString - String containing checksums, separated by newlines.
      Returns:
      Collection of Checksum objects.
      Throws:
      SpreadsheetException - If the string is invalid or cannot be parsed.
    • parseChecksum

      public org.spdx.library.model.v2.Checksum parseChecksum(String value) throws SpreadsheetException
      Creates a Checksum from the parameters specified in the tag value
      Parameters:
      value - A checksum string in the format "Algorithm: Value".
      Returns:
      A Checksum object created from the input string.
      Throws:
      SpreadsheetException - If the string is invalid or parsing fails.
    • stringsToCsv

      public static String stringsToCsv(Collection<String> strings)
      Convert a collection of strings to a comma-separated value string
      Parameters:
      strings - A collection of strings to be converted into a CSV string.
      Returns:
      A CSV-formatted string representing the input collection, or an error message if parsing fails.
    • csvToStrings

      public static List<String> csvToStrings(String csv)
      Converts a comma-separated value (CSV) string into a list of strings
      Parameters:
      csv - A string containing comma-separated values.
      Returns:
      A list of strings representing the parsed values from the CSV string. If an error occurs, the list contains a single error message.
    • licensesToString

      public static String licensesToString(Collection<org.spdx.library.model.v2.license.AnyLicenseInfo> licenseCollection)
      Convert a collection of AnyLicenseInfo objects into a CSV string representation
      Parameters:
      licenseCollection - A collection of AnyLicenseInfo objects to be converted.
      Returns:
      A comma-separated string representation of the licenses, or an empty string if the collection is null or empty.