Package com.adobe.acs.commons.data
Class Spreadsheet
- java.lang.Object
-
- com.adobe.acs.commons.data.Spreadsheet
-
@ProviderType public class Spreadsheet extends Object
Simple abstraction of reading a single spreadsheet of values. Expects a header row of named columns (case-sensitive) If provided, will also filter data rows missing required columns to prevent processing errors.
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_DELIMITERstatic StringROW_NUMBER
-
Constructor Summary
Constructors Constructor Description Spreadsheet(boolean convertHeaderNames, InputStream file, String... required)Spreadsheet(boolean convertHeaderNames, String... headerArray)Simple constructor used for unit testing purposesSpreadsheet(boolean convertHeaderNames, List<String> caseInsensitiveHeaders, String... headerArray)Simple constructor used for unit testing purposesSpreadsheet(boolean convertHeaderNames, org.apache.sling.api.request.RequestParameter file, String... required)Spreadsheet(InputStream file, String... required)Spreadsheet(org.apache.sling.api.request.RequestParameter file, String... required)Spreadsheet(org.apache.sling.api.request.RequestParameter file, List<String> caseInsensitiveHeaders, String... required)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SpreadsheetbuildSpreadsheet()Parse out the input file synchronously for easier unit test validation.SpreadsheetbuildSpreadsheet(Locale locale)Parse out the input file synchronously for easier unit test validationStringconvertHeaderName(String str)List<Map<String,CompositeVariant>>getDataRowsAsCompositeVariants()StringgetFileName()List<String>getHeaderRow()List<String>getRequiredColumns()intgetRowCount()LonggetRowNum(Map<String,CompositeVariant> row)
-
-
-
Field Detail
-
DEFAULT_DELIMITER
public static final String DEFAULT_DELIMITER
- See Also:
- Constant Field Values
-
ROW_NUMBER
public static final String ROW_NUMBER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Spreadsheet
public Spreadsheet(boolean convertHeaderNames, String... headerArray)Simple constructor used for unit testing purposes- Parameters:
convertHeaderNames- If true, header names are convertedheaderArray- List of strings for header columns
-
Spreadsheet
public Spreadsheet(boolean convertHeaderNames, List<String> caseInsensitiveHeaders, String... headerArray)Simple constructor used for unit testing purposes- Parameters:
convertHeaderNames- If true, header names are convertedcaseInsensitiveHeaders- Header names that will be ignored during conversionheaderArray- List of strings for header columns
-
Spreadsheet
public Spreadsheet(boolean convertHeaderNames, InputStream file, String... required)
-
Spreadsheet
public Spreadsheet(boolean convertHeaderNames, org.apache.sling.api.request.RequestParameter file, String... required) throws IOException- Throws:
IOException
-
Spreadsheet
public Spreadsheet(InputStream file, String... required)
-
Spreadsheet
public Spreadsheet(org.apache.sling.api.request.RequestParameter file, String... required) throws IOException- Throws:
IOException
-
Spreadsheet
public Spreadsheet(org.apache.sling.api.request.RequestParameter file, List<String> caseInsensitiveHeaders, String... required) throws IOException- Throws:
IOException
-
-
Method Detail
-
buildSpreadsheet
public Spreadsheet buildSpreadsheet() throws IOException
Parse out the input file synchronously for easier unit test validation. This overload will implicitly use the default JVM locale for numeric and date/time conversions.- Returns:
- List of files that will be imported, including any renditions
- Throws:
IOException- if the file couldn't be read
-
buildSpreadsheet
public Spreadsheet buildSpreadsheet(Locale locale) throws IOException
Parse out the input file synchronously for easier unit test validation- Parameters:
locale- The locale to be used for numeric and date/time conversions.- Returns:
- List of files that will be imported, including any renditions
- Throws:
IOException- if the file couldn't be read
-
getFileName
public String getFileName()
- Returns:
- the fileName
-
getRowCount
public int getRowCount()
- Returns:
- the rowCount
-
getDataRowsAsCompositeVariants
public List<Map<String,CompositeVariant>> getDataRowsAsCompositeVariants()
- Returns:
- the dataRows
-
getRowNum
public Long getRowNum(Map<String,CompositeVariant> row)
-
-