[miio] Elimate several SAT warnings (#9289)

* [miio] eliminate warnings from mapdraw
* [miio] clean warnings from basic handler
* [miio] avoid apache commons warning in utils
* [miio] eliminate warnings from micloudconnector

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
This commit is contained in:
Marcel 2020-12-12 15:27:54 -08:00 committed by GitHub
parent 6b3490fc57
commit 5bfc8940f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 110 additions and 74 deletions

View File

@ -13,14 +13,19 @@
package org.openhab.binding.miio.internal; package org.openhab.binding.miio.internal;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.NoSuchFileException;
import org.apache.commons.io.IOUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonIOException; import com.google.gson.JsonIOException;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException; import com.google.gson.JsonSyntaxException;
@ -90,13 +95,17 @@ public final class Utils {
} }
} }
public static JsonObject convertFileToJSON(URL fileName) throws JsonIOException, JsonSyntaxException, IOException { public static JsonObject convertFileToJSON(URL fileName) throws JsonIOException, JsonSyntaxException,
JsonParseException, IOException, URISyntaxException, NoSuchFileException {
JsonObject jsonObject = new JsonObject(); JsonObject jsonObject = new JsonObject();
JsonParser parser = new JsonParser(); JsonParser parser = new JsonParser();
JsonElement jsonElement = parser.parse(IOUtils.toString(fileName)); try (InputStream inputStream = fileName.openStream();
InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) {
JsonElement jsonElement = parser.parse(reader);
jsonObject = jsonElement.getAsJsonObject(); jsonObject = jsonElement.getAsJsonObject();
return jsonObject; return jsonObject;
} }
}
public static String minLengthString(String string, int length) { public static String minLengthString(String string, int length) {
return String.format("%-" + length + "s", string); return String.format("%-" + length + "s", string);

View File

@ -18,6 +18,7 @@ import static org.openhab.binding.miio.internal.MiIoBindingConstants.BINDING_DAT
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
@ -43,9 +44,8 @@ import org.slf4j.LoggerFactory;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.google.gson.JsonIOException;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException; import com.google.gson.JsonParseException;
/** /**
* The {@link MiIoDatabaseWatchService} creates a registry of database file per ModelId * The {@link MiIoDatabaseWatchService} creates a registry of database file per ModelId
@ -118,7 +118,7 @@ public class MiIoDatabaseWatchService extends AbstractWatchService {
for (String id : devdb.getDevice().getId()) { for (String id : devdb.getDevice().getId()) {
workingDatabaseList.put(id, db); workingDatabaseList.put(id, db);
} }
} catch (JsonIOException | JsonSyntaxException | IOException e) { } catch (JsonParseException | IOException | URISyntaxException e) {
logger.debug("Error while processing database '{}': {}", db, e.getMessage()); logger.debug("Error while processing database '{}': {}", db, e.getMessage());
} }
databaseList = workingDatabaseList; databaseList = workingDatabaseList;

View File

@ -52,6 +52,7 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException; import com.google.gson.JsonSyntaxException;
@ -154,14 +155,15 @@ public class MiCloudConnector {
String mapResponse = request(url, map); String mapResponse = request(url, map);
logger.trace("response: {}", mapResponse); logger.trace("response: {}", mapResponse);
String errorMsg = ""; String errorMsg = "";
try {
JsonElement response = PARSER.parse(mapResponse); JsonElement response = PARSER.parse(mapResponse);
if (response.isJsonObject()) { if (response.isJsonObject()) {
logger.debug("Received JSON message {}", response.toString()); logger.debug("Received JSON message {}", response);
if (response.getAsJsonObject().has("result") && response.getAsJsonObject().get("result").isJsonObject()) { if (response.getAsJsonObject().has("result")
&& response.getAsJsonObject().get("result").isJsonObject()) {
JsonObject jo = response.getAsJsonObject().get("result").getAsJsonObject(); JsonObject jo = response.getAsJsonObject().get("result").getAsJsonObject();
if (jo.has("url")) { if (jo.has("url")) {
String mapUrl = jo.get("url").getAsString(); return jo.get("url").getAsString();
return mapUrl != null ? mapUrl : "";
} else { } else {
errorMsg = "Could not get url"; errorMsg = "Could not get url";
} }
@ -171,6 +173,9 @@ public class MiCloudConnector {
} else { } else {
errorMsg = "Received message is invalid JSON"; errorMsg = "Received message is invalid JSON";
} }
} catch (ClassCastException | IllegalStateException e) {
errorMsg = "Received message could not be parsed";
}
logger.debug("{}: {}", errorMsg, mapResponse); logger.debug("{}: {}", errorMsg, mapResponse);
return ""; return "";
} }
@ -209,12 +214,14 @@ public class MiCloudConnector {
if (resp.isJsonObject()) { if (resp.isJsonObject()) {
final JsonObject jor = resp.getAsJsonObject(); final JsonObject jor = resp.getAsJsonObject();
if (jor.has("result")) { if (jor.has("result")) {
devicesList = GSON.fromJson(jor.get("result"), CloudDeviceListDTO.class).getCloudDevices(); CloudDeviceListDTO cdl = GSON.fromJson(jor.get("result"), CloudDeviceListDTO.class);
if (cdl != null) {
devicesList.addAll(cdl.getCloudDevices());
for (CloudDeviceDTO device : devicesList) { for (CloudDeviceDTO device : devicesList) {
device.setServer(country); device.setServer(country);
logger.debug("Xiaomi cloud info: {}", device); logger.debug("Xiaomi cloud info: {}", device);
} }
}
} else { } else {
logger.debug("Response missing result: '{}'", response); logger.debug("Response missing result: '{}'", response);
} }
@ -222,6 +229,7 @@ public class MiCloudConnector {
logger.debug("Response is not a json object: '{}'", response); logger.debug("Response is not a json object: '{}'", response);
} }
} catch (JsonSyntaxException | IllegalStateException | ClassCastException e) { } catch (JsonSyntaxException | IllegalStateException | ClassCastException e) {
loginFailedCounter++;
logger.info("Error while parsing devices: {}", e.getMessage()); logger.info("Error while parsing devices: {}", e.getMessage());
} }
return devicesList; return devicesList;
@ -238,6 +246,7 @@ public class MiCloudConnector {
} }
} catch (MiCloudException e) { } catch (MiCloudException e) {
logger.info("{}", e.getMessage()); logger.info("{}", e.getMessage());
loginFailedCounter++;
} }
return ""; return "";
} }
@ -260,6 +269,7 @@ public class MiCloudConnector {
if (this.serviceToken.isEmpty() || this.userId.isEmpty()) { if (this.serviceToken.isEmpty() || this.userId.isEmpty()) {
throw new MiCloudException("Cannot execute request. service token or userId missing"); throw new MiCloudException("Cannot execute request. service token or userId missing");
} }
loginFailedCounterCheck();
startClient(); startClient();
logger.debug("Send request: {} to {}", params.get("data"), url); logger.debug("Send request: {} to {}", params.get("data"), url);
Request request = httpClient.newRequest(url).timeout(REQUEST_TIMEOUT_SECONDS, TimeUnit.SECONDS); Request request = httpClient.newRequest(url).timeout(REQUEST_TIMEOUT_SECONDS, TimeUnit.SECONDS);
@ -305,10 +315,13 @@ public class MiCloudConnector {
} catch (HttpResponseException e) { } catch (HttpResponseException e) {
serviceToken = ""; serviceToken = "";
logger.debug("Error while executing request to {} :{}", url, e.getMessage()); logger.debug("Error while executing request to {} :{}", url, e.getMessage());
loginFailedCounter++;
} catch (InterruptedException | TimeoutException | ExecutionException | IOException e) { } catch (InterruptedException | TimeoutException | ExecutionException | IOException e) {
logger.debug("Error while executing request to {} :{}", url, e.getMessage()); logger.debug("Error while executing request to {} :{}", url, e.getMessage());
loginFailedCounter++;
} catch (MiIoCryptoException e) { } catch (MiIoCryptoException e) {
logger.debug("Error while decrypting response of request to {} :{}", url, e.getMessage(), e); logger.debug("Error while decrypting response of request to {} :{}", url, e.getMessage(), e);
loginFailedCounter++;
} }
return ""; return "";
} }
@ -339,14 +352,20 @@ public class MiCloudConnector {
logger.info("Error logging on to Xiaomi cloud ({}): {}", loginFailedCounter, e.getMessage()); logger.info("Error logging on to Xiaomi cloud ({}): {}", loginFailedCounter, e.getMessage());
loginFailedCounter++; loginFailedCounter++;
serviceToken = ""; serviceToken = "";
loginFailedCounterCheck();
return false;
}
return true;
}
void loginFailedCounterCheck() {
if (loginFailedCounter > 10) { if (loginFailedCounter > 10) {
logger.info("Repeated errors logging on to Xiaomi cloud. Cleaning stored cookies"); logger.info("Repeated errors logging on to Xiaomi cloud. Cleaning stored cookies");
dumpCookies(".xiaomi.com", true); dumpCookies(".xiaomi.com", true);
dumpCookies(".mi.com", true); dumpCookies(".mi.com", true);
serviceToken = "";
loginFailedCounter = 0;
} }
return false;
}
return true;
} }
protected boolean loginRequest() throws MiCloudException { protected boolean loginRequest() throws MiCloudException {
@ -360,7 +379,6 @@ public class MiCloudConnector {
location = sign; // seems we already have login location location = sign; // seems we already have login location
} }
final ContentResponse responseStep3 = loginStep3(location); final ContentResponse responseStep3 = loginStep3(location);
switch (responseStep3.getStatus()) { switch (responseStep3.getStatus()) {
case HttpStatus.FORBIDDEN_403: case HttpStatus.FORBIDDEN_403:
throw new MiCloudException("Access denied. Did you set the correct api-key and/or username?"); throw new MiCloudException("Access denied. Did you set the correct api-key and/or username?");
@ -375,7 +393,7 @@ public class MiCloudConnector {
throw new MiCloudException("Cannot logon to Xiaomi cloud: " + e.getMessage(), e); throw new MiCloudException("Cannot logon to Xiaomi cloud: " + e.getMessage(), e);
} catch (MiIoCryptoException e) { } catch (MiIoCryptoException e) {
throw new MiCloudException("Error decrypting. Cannot logon to Xiaomi cloud: " + e.getMessage(), e); throw new MiCloudException("Error decrypting. Cannot logon to Xiaomi cloud: " + e.getMessage(), e);
} catch (MalformedURLException e) { } catch (MalformedURLException | JsonParseException e) {
throw new MiCloudException("Error getting logon URL. Cannot logon to Xiaomi cloud: " + e.getMessage(), e); throw new MiCloudException("Error getting logon URL. Cannot logon to Xiaomi cloud: " + e.getMessage(), e);
} }
} }
@ -396,22 +414,21 @@ public class MiCloudConnector {
logger.trace("Xiaomi Login step 1 response = {}", responseStep1); logger.trace("Xiaomi Login step 1 response = {}", responseStep1);
try { try {
JsonElement resp = new JsonParser().parse(parseJson(content)); JsonElement resp = new JsonParser().parse(parseJson(content));
if (resp.getAsJsonObject().has("_sign")) { if (resp.isJsonObject() && resp.getAsJsonObject().has("_sign")) {
String sign = resp.getAsJsonObject().get("_sign").getAsString(); String sign = resp.getAsJsonObject().get("_sign").getAsString();
logger.trace("Xiaomi Login step 1 sign = {}", sign); logger.trace("Xiaomi Login step 1 sign = {}", sign);
return sign; return sign;
} else { } else {
logger.trace("Xiaomi Login _sign missing. Maybe still has login cookie."); logger.debug("Xiaomi Login _sign missing. Maybe still has login cookie.");
return ""; return "";
} }
} catch (JsonParseException | IllegalStateException | ClassCastException e) {
} catch (JsonSyntaxException | NullPointerException e) {
throw new MiCloudException("Error getting logon sign. Cannot parse response: " + e.getMessage(), e); throw new MiCloudException("Error getting logon sign. Cannot parse response: " + e.getMessage(), e);
} }
} }
private String loginStep2(String sign) private String loginStep2(String sign) throws MiIoCryptoException, InterruptedException, TimeoutException,
throws MiIoCryptoException, InterruptedException, TimeoutException, ExecutionException, MiCloudException { ExecutionException, MiCloudException, JsonSyntaxException, JsonParseException {
String passToken; String passToken;
String cUserId; String cUserId;
@ -442,7 +459,9 @@ public class MiCloudConnector {
JsonElement resp2 = new JsonParser().parse(parseJson(content2)); JsonElement resp2 = new JsonParser().parse(parseJson(content2));
CloudLoginDTO jsonResp = GSON.fromJson(resp2, CloudLoginDTO.class); CloudLoginDTO jsonResp = GSON.fromJson(resp2, CloudLoginDTO.class);
if (jsonResp == null) {
throw new MiCloudException("Error getting logon details from step 2: " + content2);
}
ssecurity = jsonResp.getSsecurity(); ssecurity = jsonResp.getSsecurity();
userId = jsonResp.getUserId(); userId = jsonResp.getUserId();
cUserId = jsonResp.getcUserId(); cUserId = jsonResp.getcUserId();
@ -492,9 +511,9 @@ public class MiCloudConnector {
if (logger.isTraceEnabled()) { if (logger.isTraceEnabled()) {
try { try {
URI uri = URI.create(url); URI uri = URI.create(url);
if (uri != null) {
logger.trace("Cookie dump for {}", uri); logger.trace("Cookie dump for {}", uri);
CookieStore cs = httpClient.getCookieStore(); CookieStore cs = httpClient.getCookieStore();
if (cs != null) {
List<HttpCookie> cookies = cs.get(uri); List<HttpCookie> cookies = cs.get(uri);
for (HttpCookie cookie : cookies) { for (HttpCookie cookie : cookies) {
logger.trace("Cookie ({}) : {} --> {} (path: {}. Removed: {})", cookie.getDomain(), logger.trace("Cookie ({}) : {} --> {} (path: {}. Removed: {})", cookie.getDomain(),
@ -504,9 +523,9 @@ public class MiCloudConnector {
} }
} }
} else { } else {
logger.trace("Could not create URI from {}", url); logger.trace("Could not create cookiestore from {}", url);
} }
} catch (IllegalArgumentException | NullPointerException e) { } catch (IllegalArgumentException e) {
logger.trace("Error dumping cookies from {}: {}", url, e.getMessage(), e); logger.trace("Error dumping cookies from {}: {}", url, e.getMessage(), e);
} }
} }

View File

@ -22,6 +22,7 @@ import java.util.HashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.measure.Unit; import javax.measure.Unit;
@ -134,7 +135,7 @@ public class MiIoBasicHandler extends MiIoAbstractHandler {
} }
logger.debug("Locating action for {} channel '{}': '{}'", getThing().getUID(), channelUID.getId(), command); logger.debug("Locating action for {} channel '{}': '{}'", getThing().getUID(), channelUID.getId(), command);
if (!actions.isEmpty()) { if (!actions.isEmpty()) {
MiIoBasicChannel miIoBasicChannel = actions.get(channelUID); final MiIoBasicChannel miIoBasicChannel = actions.get(channelUID);
if (miIoBasicChannel != null) { if (miIoBasicChannel != null) {
int valuePos = 0; int valuePos = 0;
for (MiIoDeviceAction action : miIoBasicChannel.getActions()) { for (MiIoDeviceAction action : miIoBasicChannel.getActions()) {
@ -254,8 +255,8 @@ public class MiIoBasicHandler extends MiIoAbstractHandler {
} else { } else {
logger.debug("Channel Id {} not in mapping.", channelUID.getId()); logger.debug("Channel Id {} not in mapping.", channelUID.getId());
if (logger.isTraceEnabled()) { if (logger.isTraceEnabled()) {
for (ChannelUID a : actions.keySet()) { for (Entry<ChannelUID, MiIoBasicChannel> a : actions.entrySet()) {
logger.trace("Available entries: {} : {}", a, actions.get(a).getFriendlyName()); logger.trace("Available entries: {} : {}", a.getKey(), a.getValue().getFriendlyName());
} }
} }
} }
@ -641,14 +642,15 @@ public class MiIoBasicHandler extends MiIoAbstractHandler {
default: default:
if (refreshListCustomCommands.containsKey(response.getMethod())) { if (refreshListCustomCommands.containsKey(response.getMethod())) {
logger.debug("Processing custom refresh command response for !{}", response.getMethod()); logger.debug("Processing custom refresh command response for !{}", response.getMethod());
MiIoBasicChannel ch = refreshListCustomCommands.get(response.getMethod()); final MiIoBasicChannel ch = refreshListCustomCommands.get(response.getMethod());
if (ch != null) {
if (response.getResult().isJsonArray()) { if (response.getResult().isJsonArray()) {
JsonArray cmdResponse = response.getResult().getAsJsonArray(); JsonArray cmdResponse = response.getResult().getAsJsonArray();
final String transformation = ch.getTransfortmation(); final String transformation = ch.getTransfortmation();
if (transformation == null || transformation.isBlank()) { if (transformation == null || transformation.isBlank()) {
updateChannel(ch, ch.getChannel(), JsonElement response0 = cmdResponse.get(0);
cmdResponse.get(0).isJsonPrimitive() ? cmdResponse.get(0) updateChannel(ch, ch.getChannel(), response0.isJsonPrimitive() ? response0
: new JsonPrimitive(cmdResponse.get(0).toString())); : new JsonPrimitive(response0.toString()));
} else { } else {
updateChannel(ch, ch.getChannel(), cmdResponse); updateChannel(ch, ch.getChannel(), cmdResponse);
} }
@ -656,6 +658,7 @@ public class MiIoBasicHandler extends MiIoAbstractHandler {
updateChannel(ch, ch.getChannel(), new JsonPrimitive(response.getResult().toString())); updateChannel(ch, ch.getChannel(), new JsonPrimitive(response.getResult().toString()));
} }
} }
}
break; break;
} }
} catch (Exception e) { } catch (Exception e) {

View File

@ -36,6 +36,7 @@ import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
@ -196,7 +197,8 @@ public class RRMapDraw {
private void drawPath(Graphics2D g2d, float scale) { private void drawPath(Graphics2D g2d, float scale) {
Stroke stroke = new BasicStroke(0.5f * scale); Stroke stroke = new BasicStroke(0.5f * scale);
g2d.setStroke(stroke); g2d.setStroke(stroke);
for (Integer pathType : rmfp.getPaths().keySet()) { for (Entry<Integer, ArrayList<float[]>> path : rmfp.getPaths().entrySet()) {
Integer pathType = path.getKey();
switch (pathType) { switch (pathType) {
case RRMapFileParser.PATH: case RRMapFileParser.PATH:
if (!multicolor) { if (!multicolor) {
@ -216,7 +218,7 @@ public class RRMapDraw {
} }
float prvX = 0; float prvX = 0;
float prvY = 0; float prvY = 0;
for (float[] point : rmfp.getPaths().get(pathType)) { for (float[] point : path.getValue()) {
float x = toXCoord(point[0]) * scale; float x = toXCoord(point[0]) * scale;
float y = toYCoord(point[1]) * scale; float y = toYCoord(point[1]) * scale;
if (prvX > 1) { if (prvX > 1) {
@ -244,8 +246,8 @@ public class RRMapDraw {
} }
private void drawNoGo(Graphics2D g2d, float scale) { private void drawNoGo(Graphics2D g2d, float scale) {
for (Integer area : rmfp.getAreas().keySet()) { for (Map.Entry<Integer, ArrayList<float[]>> area : rmfp.getAreas().entrySet()) {
for (float[] point : rmfp.getAreas().get(area)) { for (float[] point : area.getValue()) {
float x = toXCoord(point[0]) * scale; float x = toXCoord(point[0]) * scale;
float y = toYCoord(point[1]) * scale; float y = toYCoord(point[1]) * scale;
float x1 = toXCoord(point[2]) * scale; float x1 = toXCoord(point[2]) * scale;
@ -262,10 +264,11 @@ public class RRMapDraw {
noGo.lineTo(x, y); noGo.lineTo(x, y);
g2d.setColor(COLOR_NO_GO_ZONES); g2d.setColor(COLOR_NO_GO_ZONES);
g2d.fill(noGo); g2d.fill(noGo);
g2d.setColor(area == 9 ? Color.RED : Color.WHITE); g2d.setColor(area.getKey() == 9 ? Color.RED : Color.WHITE);
g2d.draw(noGo); g2d.draw(noGo);
} }
} }
;
} }
private void drawWalls(Graphics2D g2d, float scale) { private void drawWalls(Graphics2D g2d, float scale) {
@ -419,6 +422,7 @@ public class RRMapDraw {
} }
private @Nullable URL getImageUrl(String image) { private @Nullable URL getImageUrl(String image) {
final Bundle bundle = this.bundle;
if (bundle != null) { if (bundle != null) {
return bundle.getEntry("images/" + image); return bundle.getEntry("images/" + image);
} }

View File

@ -25,6 +25,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
@ -333,25 +334,25 @@ public class RRMapFileParser {
pw.printf("Charger pos:\tX: %.0f\tY: %.0f\r\n", getChargerX(), getChargerY()); pw.printf("Charger pos:\tX: %.0f\tY: %.0f\r\n", getChargerX(), getChargerY());
pw.printf("Robo pos:\tX: %.0f\tY: %.0f\tAngle: %d\r\n", getRoboX(), getRoboY(), getRoboA()); pw.printf("Robo pos:\tX: %.0f\tY: %.0f\tAngle: %d\r\n", getRoboX(), getRoboY(), getRoboA());
pw.printf("Goto:\tX: %.0f\tY: %.0f\r\n", getGotoX(), getGotoY()); pw.printf("Goto:\tX: %.0f\tY: %.0f\r\n", getGotoX(), getGotoY());
for (Integer area : areas.keySet()) { for (Entry<Integer, ArrayList<float[]>> area : areas.entrySet()) {
pw.print(area == NO_GO_AREAS ? "No Go zones:\t" : "MFBZS zones:\t"); pw.print(area.getKey() == NO_GO_AREAS ? "No Go zones:\t" : "MFBZS zones:\t");
pw.printf("%d\r\n", areas.get(area).size()); pw.printf("%d\r\n", area.getValue().size());
printAreaDetails(areas.get(area), pw); printAreaDetails(area.getValue(), pw);
} }
pw.printf("Walls:\t%d\r\n", walls.size()); pw.printf("Walls:\t%d\r\n", walls.size());
printAreaDetails(walls, pw); printAreaDetails(walls, pw);
pw.printf("Zones:\t%d\r\n", zones.size()); pw.printf("Zones:\t%d\r\n", zones.size());
printAreaDetails(zones, pw); printAreaDetails(zones, pw);
for (Integer obstacleType : obstacles.keySet()) { for (Entry<Integer, ArrayList<int[]>> obstacleType : obstacles.entrySet()) {
pw.printf("Obstacles Type (%d):\t%d\r\n", obstacleType, obstacles.get(obstacleType).size()); pw.printf("Obstacles Type (%d):\t%d\r\n", obstacleType.getKey(), obstacleType.getValue().size());
printObstacleDetails(obstacles.get(obstacleType), pw); printObstacleDetails(obstacleType.getValue(), pw);
} }
pw.printf("Blocks:\t%d\r\n", blocks.length); pw.printf("Blocks:\t%d\r\n", blocks.length);
pw.print("Paths:"); pw.print("Paths:");
for (Integer p : pathsDetails.keySet()) { for (Entry<Integer, Map<String, Integer>> pathDetail : pathsDetails.entrySet()) {
pw.printf("\r\nPath type:\t%d", p); pw.printf("\r\nPath type:\t%d", pathDetail.getKey());
for (String detail : pathsDetails.get(p).keySet()) { for (String detail : pathDetail.getValue().keySet()) {
pw.printf(" %s: %d", detail, pathsDetails.get(p).get(detail)); pw.printf(" %s: %d", detail, pathDetail.getValue().get(detail));
} }
} }
pw.println(); pw.println();