From f2e5aff4c2530c60dce20f579892ae8692ae4ce4 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Mon, 6 Jun 2016 19:28:21 +0200 Subject: [PATCH] UrlManager: Reindent based on our coding style --- .../cz/brmlab/yodaqa/provider/UrlManager.java | 366 +++++++++--------- 1 file changed, 183 insertions(+), 183 deletions(-) diff --git a/src/main/java/cz/brmlab/yodaqa/provider/UrlManager.java b/src/main/java/cz/brmlab/yodaqa/provider/UrlManager.java index 7b9eadd1..2721e3cf 100644 --- a/src/main/java/cz/brmlab/yodaqa/provider/UrlManager.java +++ b/src/main/java/cz/brmlab/yodaqa/provider/UrlManager.java @@ -13,186 +13,186 @@ */ public class UrlManager { - static { - updateUrlTable(); - } - - public enum DataBackends { - DBPEDIA, FREEBASE, LABEL1, LABEL2, SOLR - } - - private static String[][] urlLookUpTable; - - public static String[][] getUrlLookUpTable() { - return urlLookUpTable; - } - public static void setUrlLookUpTable(String[][] newLookUpTable) { - urlLookUpTable = newLookUpTable; - } - - private static int currentBackend = 0; //Default is 0: ailao.eu, 1: loopback, different if custom tables loaded - public static int getCurrentBackend() { - return currentBackend; - } - public static boolean setCurrentBackend(int currentBackend) { - if (currentBackend < urlLookUpTable.length) { - UrlManager.currentBackend = currentBackend; - return true; - } else { - return false; - } - } - - public static String printState() { - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("Currently selected backend: "); - stringBuilder.append(Integer.toString(currentBackend)); - stringBuilder.append("\n\nCurrent Lookup Table:\n"); - for (int i=0; i backends = gson.fromJson(jsonObject.get("offline"), new TypeToken>(){}.getType()); - //JsonParser jsonParser = new JsonParser(); - //JsonElement jsonElement = jsonParser.parse(jsonString); - // JsonArray jsonArray = jsonElement.isJsonArray()?jsonElement.getAsJsonArray():null; - - // ...but we can load it directly - return gson.fromJson(jsonString, String[][].class); - } - - /** - * Reads and parses configuration file - * @return Success state - */ - public static boolean updateUrlTable() { - try{ - String[][] result = parseConfiguration(readConfigurationFile()); - if (result != null) { - urlLookUpTable = result; - return true; - } - return false; - } catch (JsonParseException jpe) { - jpe.printStackTrace(); - return false; - } - } - - /** - * Looks up entire URL set for a backend (DBpedia, Freebase, Label Service 1, Label Service 2 - * and then Solr/enwiki) - * @param id Backend to return all URLs for - * @return All backends in order - */ - public static String[] lookUpUrlSet(int id) { - if(urlLookUpTable != null && id backends = gson.fromJson(jsonObject.get("offline"), new TypeToken>(){}.getType()); + //JsonParser jsonParser = new JsonParser(); + //JsonElement jsonElement = jsonParser.parse(jsonString); + // JsonArray jsonArray = jsonElement.isJsonArray()?jsonElement.getAsJsonArray():null; + + // ...but we can load it directly + return gson.fromJson(jsonString, String[][].class); + } + + /** + * Reads and parses configuration file + * @return Success state + */ + public static boolean updateUrlTable() { + try{ + String[][] result = parseConfiguration(readConfigurationFile()); + if (result != null) { + urlLookUpTable = result; + return true; + } + return false; + } catch (JsonParseException jpe) { + jpe.printStackTrace(); + return false; + } + } + + /** + * Looks up entire URL set for a backend (DBpedia, Freebase, Label Service 1, Label Service 2 + * and then Solr/enwiki) + * @param id Backend to return all URLs for + * @return All backends in order + */ + public static String[] lookUpUrlSet(int id) { + if(urlLookUpTable != null && id