Package org.goplanit.osm.defaults
Class CountrySpecificDefaultUtils
- java.lang.Object
-
- org.goplanit.osm.defaults.CountrySpecificDefaultUtils
-
public class CountrySpecificDefaultUtils extends Object
Class with some common functionality for defaults that are country specific and stored in CSV files- Author:
- markr
-
-
Constructor Summary
Constructors Constructor Description CountrySpecificDefaultUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
callForEachFileInResourceDir(String resourceDir, BiConsumer<InputStreamReader,String> callBack)
Call consumer for each country specific file in resource dirstatic Iterable<org.apache.commons.csv.CSVRecord>
collectCsvRecordIterable(File file)
collect an iterable given that each country specific file is in CSV formatstatic Iterable<org.apache.commons.csv.CSVRecord>
collectCsvRecordIterable(Reader readerToUse)
Collect an iterable for the given readerstatic String
extractCountryNameFromFile(Path filePath)
Validate if file is a valid resource file and its name is constructed based on a country code.
-
-
-
Method Detail
-
callForEachFileInResourceDir
public static void callForEachFileInResourceDir(String resourceDir, BiConsumer<InputStreamReader,String> callBack)
Call consumer for each country specific file in resource dir- Parameters:
resourceDir
- to usecallBack
- to use
-
extractCountryNameFromFile
public static String extractCountryNameFromFile(Path filePath) throws PlanItException
Validate if file is a valid resource file and its name is constructed based on a country code. Each file should be named according to ISO366 alpha 2 country code. If valid the full country name is returned- Parameters:
filePath
- to validate- Returns:
- full country name, otherwise null
- Throws:
PlanItException
- thrown if error
-
collectCsvRecordIterable
public static Iterable<org.apache.commons.csv.CSVRecord> collectCsvRecordIterable(File file) throws IOException
collect an iterable given that each country specific file is in CSV format- Parameters:
file
- presumed compatible with country specific CSV format- Returns:
- CSVRecord iterable
- Throws:
IOException
- thrown if error
-
collectCsvRecordIterable
public static Iterable<org.apache.commons.csv.CSVRecord> collectCsvRecordIterable(Reader readerToUse) throws IOException
Collect an iterable for the given reader- Parameters:
readerToUse
- the reader to use- Returns:
- CSVRecord iterable
- Throws:
IOException
- thrown if error
-
-