Package org.spdx.spreadsheetstore
Class AbstractSheet
java.lang.Object
org.spdx.spreadsheetstore.AbstractSheet
- Direct Known Subclasses:
AnnotationsSheet
,DocumentInfoSheet
,ExternalRefsSheet
,ExtractedLicenseInfoSheet
,PackageInfoSheet
,PerFileSheet
,RelationshipsSheet
,SnippetSheet
Abstract class representing a workbook sheet used in storing structured data
- Author:
- Gary O'Neall
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.apache.poi.ss.usermodel.CellStyle
static Pattern
Pattern for parsing checksumsprotected 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
ConstructorsConstructorDescriptionAbstractSheet
(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 TypeMethodDescriptionprotected org.apache.poi.ss.usermodel.Row
addRow()
Add a new row to the end of the sheetchecksumsToString
(Collection<org.spdx.library.model.v2.Checksum> checksumCollection) Converts a collection ofChecksum
objects into a string representationchecksumToString
(org.spdx.library.model.v2.Checksum checksum) Convert aChecksum
object into its string representationvoid
clear()
Clears all data from the worksheetstatic org.apache.poi.ss.usermodel.CellStyle
createCenterStyle
(org.apache.poi.ss.usermodel.Workbook wb) Creates a cell style with center alignment, without text wrappingstatic org.apache.poi.ss.usermodel.CellStyle
createHeaderStyle
(org.apache.poi.ss.usermodel.Workbook wb) Creates a header cell style for the workbookstatic org.apache.poi.ss.usermodel.CellStyle
createLeftWrapStyle
(org.apache.poi.ss.usermodel.Workbook wb) Creates a cell style with left alignment and text wrappingcsvToStrings
(String csv) Converts a comma-separated value (CSV) string into a list of stringsint
Return the first row number of the data rowsint
Return the number of data rows in the sheetorg.apache.poi.ss.usermodel.Sheet
getSheet()
Return the sheet managed by this classstatic String
licensesToString
(Collection<org.spdx.library.model.v2.license.AnyLicenseInfo> licenseCollection) Convert a collection ofAnyLicenseInfo
objects into a CSV string representationorg.spdx.library.model.v2.Checksum
parseChecksum
(String value) Creates aChecksum
from the parameters specified in the tag valuevoid
Resize the rows for a best fit.static String
stringsToCsv
(Collection<String> strings) Convert a collection of strings to a comma-separated value stringCollection
<org.spdx.library.model.v2.Checksum> strToChecksums
(String checksumsString) Convert a string representation of checksums into a collection ofChecksum
objectsabstract String
verify()
Verifies the integrity of the sheet's data
-
Field Details
-
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
-
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 livessheetName
- Name of the sheetmodelStore
- Model store for creating typed valuesdocumentUri
- URI for the document if knowncopyManager
- 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
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 ofChecksum
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 aChecksum
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 ofChecksum
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
Creates aChecksum
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
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
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 ofAnyLicenseInfo
objects into a CSV string representation- Parameters:
licenseCollection
- A collection ofAnyLicenseInfo
objects to be converted.- Returns:
- A comma-separated string representation of the licenses, or an empty string if the collection is null or empty.
-