Package net.solarnetwork.domain.tariff
Class CsvTemporalRangeTariffParser
java.lang.Object
net.solarnetwork.domain.tariff.CsvTemporalRangeTariffParser
Parse
TemporalRangesTariff rows from CSV data.
The CSV resource must provide a header row, and the names of the tariffs will be taken from there. The first 4 columns of the CSV must be:
- month range, as month names, abbreviations, or numbers 1 - 12
- day of month range, as numbers 1 - 31
- day of week range, as weekday names, abbreviations, or numbers 1-7 (1 = Monday)
- time of date range, as hours 0-24 or ISO local times HH:MM-HH-MM
The remaining columns are rate values, and must be numbers that can be parsed
as a BigDecimal.
- Since:
- 1.71
- Version:
- 1.0
- Author:
- matt
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidformatCsv(List<TemporalRangesTariff> tariffs, Writer writer) Encode a list of tariffs as CSV data.parseTariffs(Reader reader) Parse tariff rows from a reader.
-
Constructor Details
-
CsvTemporalRangeTariffParser
public CsvTemporalRangeTariffParser()Constructor.The system locale will be used.
-
CsvTemporalRangeTariffParser
Constructor.- Parameters:
locale- the locale to use, or null to use the system default
-
-
Method Details
-
parseTariffs
Parse tariff rows from a reader.- Parameters:
reader- the reader- Returns:
- the parsed rows, never null
- Throws:
IOException- if any IO error occursIllegalArgumentException- if any parsing error occurs, like invalid number or range syntax
-
formatCsv
Encode a list of tariffs as CSV data.The range columns are formatted using abbreviations if possible. The time range column will be formatted using integer hours if possible, otherwise HH:MM syntax.
- Parameters:
tariffs- the tariffs to encodewriter- the writer to write the CSV data to- Throws:
IOException- if any IO error occursIllegalArgumentException- if any formatting error occurs
-