java/converter/src/main/java/be/bosa/dt/best/converter/writer/BestRegionWriter.java
/**
	 * Read the various BeST XML files into memory,
	 * and write the data for a specific region to another format.
	 * 
	 * @param writer writer
	 * @param region region
	 * @param inPath input directory
	 * @param outPath output directory
	 */
Read the various BeST XML files into memory,
and write the data for a specific region to another format.

@param writer writer
@param region region
@param inPath input directory
@param outPath output directory
Read the various BeST XML files into memory and write the data for a specific region to another format . @param writer writer @param region region @param inPath input directory @param outPath output directory
public void writeRegion(BestWriter writer, BestRegion region, Path inPath, Path outPath) {
		try( Stream<Municipality> cities = new MunicipalityReader().read(region, inPath);
			Stream<Postal> postals = new PostalReader().read(region, inPath);
			Stream<Street> streets = new StreetnameReader().read(region, inPath);
			Stream<Address> addresses = new AddressReader().read(region, inPath)) {
			Map<String, String[]> cacheCities = writer.writeMunicipalities(region, outPath, cities);
			Map<String, String[]> cacheCityParts = Collections.EMPTY_MAP;
			if (region.equals(BestRegion.WALLONIA)) { 
				try ( Stream<Municipality> cityParts = new MunicipalityPartReader().read(region, inPath)) {
					cacheCityParts = writer.writeMunicipalityParts(region, outPath, cityParts);
				}
			}
			Map<String, String[]> cachePostals = writer.writePostals(region, outPath, postals);
			Map<String, String[]> cacheStreets = writer.writeStreets(region, outPath, streets, cacheCities);
			Map<String, Map<String, String[]>> cachePostalStreets = 
				writer.writeAddresses(region, outPath, addresses, cacheStreets, cacheCities, cacheCityParts, cachePostals);
			writer.writePostalStreets(region, outPath, cachePostalStreets);
		}
	}
public void writeRegion ( BestWriter writer , BestRegion region , Path inPath , Path outPath ) { try ( Stream < Municipality > cities = new MunicipalityReader ( ) . read ( region , inPath ) ; Stream < Postal > postals = new PostalReader ( ) . read ( region , inPath ) ; Stream < Street > streets = new StreetnameReader ( ) . read ( region , inPath ) ; Stream < Address > addresses = new AddressReader ( ) . read ( region , inPath ) ) { Map < String , String [ ] > cacheCities = writer . writeMunicipalities ( region , outPath , cities ) ; Map < String , String [ ] > cacheCityParts = Collections . EMPTY_MAP ; if ( region . equals ( BestRegion . WALLONIA ) ) { try ( Stream < Municipality > cityParts = new MunicipalityPartReader ( ) . read ( region , inPath ) ) { cacheCityParts = writer . writeMunicipalityParts ( region , outPath , cityParts ) ; } } Map < String , String [ ] > cachePostals = writer . writePostals ( region , outPath , postals ) ; Map < String , String [ ] > cacheStreets = writer . writeStreets ( region , outPath , streets , cacheCities ) ; Map < String , Map < String , String [ ] > > cachePostalStreets = writer . writeAddresses ( region , outPath , addresses , cacheStreets , cacheCities , cacheCityParts , cachePostals ) ; writer . writePostalStreets ( region , outPath , cachePostalStreets ) ; } }
Read the various BeST XML files into memory,
 and write the data for a specific region to another format.
Read the various BeST XML files into memory and write the data for a specific region to another format .
// instead of using an RDBMS, store the required info in various maps // key: ID, value: fields as strings // only Walloon Region provides "municipality parts"