[LIB-13] Rename some common classes
authorgotty <gotty@hedgecode.org>
Sat, 18 Jan 2020 21:15:43 +0000 (00:15 +0300)
committergotty <gotty@hedgecode.org>
Sat, 18 Jan 2020 21:15:43 +0000 (00:15 +0300)
22 files changed:
src/main/java/org/hedgecode/chess/scanner/ChessHogScanner.java
src/main/java/org/hedgecode/chess/scanner/ChessHogScannerApp.java
src/main/java/org/hedgecode/chess/scanner/Initiable.java
src/main/java/org/hedgecode/chess/scanner/Scanner.java
src/main/java/org/hedgecode/chess/scanner/ScannerConsole.java [moved from src/main/java/org/hedgecode/chess/scanner/ChessHogScannerConsole.java with 92% similarity]
src/main/java/org/hedgecode/chess/scanner/ScannerConstants.java [moved from src/main/java/org/hedgecode/chess/scanner/ChessHogScannerConstants.java with 95% similarity]
src/main/java/org/hedgecode/chess/scanner/ScannerException.java [moved from src/main/java/org/hedgecode/chess/scanner/ChessHogScannerException.java with 75% similarity]
src/main/java/org/hedgecode/chess/scanner/ScannerProperties.java [moved from src/main/java/org/hedgecode/chess/scanner/ChessHogScannerProperties.java with 94% similarity]
src/main/java/org/hedgecode/chess/scanner/ScannerType.java
src/main/java/org/hedgecode/chess/scanner/SettingsBuilder.java
src/main/java/org/hedgecode/chess/scanner/json/JSONSettingsBuilder.java
src/main/java/org/hedgecode/chess/scanner/portal/AbstractRequestScanner.java
src/main/java/org/hedgecode/chess/scanner/portal/AbstractSettingsScanner.java
src/main/java/org/hedgecode/chess/scanner/portal/Chess24Scanner.java
src/main/java/org/hedgecode/chess/scanner/portal/ChessBombScanner.java
src/main/java/org/hedgecode/chess/scanner/portal/ChessComScanner.java
src/main/java/org/hedgecode/chess/scanner/portal/ChessGamesScanner.java
src/main/java/org/hedgecode/chess/scanner/portal/LiChessScanner.java
src/main/java/org/hedgecode/chess/scanner/proxy/Proxy.java
src/main/java/org/hedgecode/chess/scanner/regex/RegexBuilder.java
src/main/java/org/hedgecode/chess/scanner/regex/type/RegexBlockFinder.java
src/main/java/org/hedgecode/chess/scanner/regex/type/RegexSplitter.java

index 91a05c8..93c8143 100644 (file)
@@ -66,20 +66,20 @@ public final class ChessHogScanner {
      *
      * @param url URL string for scan.
      * @return PGN game.
-     * @throws ChessHogScannerException Incorrect URL or unknown chess portal.
+     * @throws ScannerException Incorrect URL or unknown chess portal.
      */
-    public static PGNGame scan(String url) throws ChessHogScannerException {
+    public static PGNGame scan(String url) throws ScannerException {
         String hostName;
         try {
             hostName = new URL(url).getHost();
         } catch (MalformedURLException cause) {
-            throw new ChessHogScannerException(
+            throw new ScannerException(
                     String.format("Incorrect  URL: %s", url), cause
             );
         }
         ScannerType type = ScannerType.byHost(hostName);
         if (type == null) {
-            throw new ChessHogScannerException(
+            throw new ScannerException(
                     String.format("Host %s is not among the known for the scanner", hostName)
             );
         }
@@ -100,7 +100,7 @@ public final class ChessHogScanner {
                 initiableScanner.init();
             }
             initScanners.add(type);
-        } catch (ChessHogScannerException e) {
+        } catch (ScannerException e) {
             throw new RuntimeException(e);
         }
     }
@@ -114,7 +114,7 @@ public final class ChessHogScanner {
     }
 
     private ChessHogScanner() {
-        if (!ChessHogScannerProperties.is("scanner.lazy.init")) {
+        if (!ScannerProperties.is("scanner.lazy.init")) {
             init();
         }
     }
index 618a802..060773c 100644 (file)
@@ -26,20 +26,17 @@ import org.hedgecode.chess.scanner.proxy.ProxyParams;
  */
 public final class ChessHogScannerApp {
 
-    public static void main(String[] args) throws ChessHogScannerException {
+    public static void main(String[] args) throws ScannerException {
 
-        ChessHogScannerConsole.init();
+        ScannerConsole.init();
 
-        boolean useProxy = Boolean.parseBoolean(
-                ChessHogScannerProperties.get("scanner.use.proxy")
-        );
+        boolean useProxy = ScannerProperties.is("scanner.use.proxy");
 
         if (useProxy) {
             ProxyParams proxyParams = new ProxyParams(
-                    ChessHogScannerProperties.get("scanner.proxy.server"),
-                    ChessHogScannerProperties.get("scanner.proxy.auth")
+                    ScannerProperties.get("scanner.proxy.server"),
+                    ScannerProperties.get("scanner.proxy.auth")
             );
-            ChessHogScannerConsole.console(proxyParams.toString());
             Proxy.setProxy(proxyParams);
         }
 
index 4fd24d6..da729a4 100644 (file)
@@ -23,6 +23,6 @@ package org.hedgecode.chess.scanner;
  */
 public interface Initiable {
 
-    void init() throws ChessHogScannerException;
+    void init() throws ScannerException;
 
 }
index 2c6095a..5188214 100644 (file)
@@ -26,14 +26,14 @@ import org.hedgecode.chess.scanner.entity.PGNTournament;
  */
 public interface Scanner {
 
-    PGNTournament scanTournament(String tournamentId) throws ChessHogScannerException;
+    PGNTournament scanTournament(String tournamentId) throws ScannerException;
 
-    PGNTournament findTournament(String tournamentName) throws ChessHogScannerException;
+    PGNTournament findTournament(String tournamentName) throws ScannerException;
 
-    PGNGame scanGame(String gameId) throws ChessHogScannerException;
+    PGNGame scanGame(String gameId) throws ScannerException;
 
-    PGNGame scanGame(String gameId, String tournamentId) throws ChessHogScannerException;
+    PGNGame scanGame(String gameId, String tournamentId) throws ScannerException;
 
-    PGNGame scanUrl(String gameUrl) throws ChessHogScannerException;
+    PGNGame scanUrl(String gameUrl) throws ScannerException;
 
 }
@@ -24,7 +24,7 @@ import java.util.Calendar;
  *
  * @author Dmitry Samoshin aka gotty
  */
-public class ChessHogScannerConsole {
+public class ScannerConsole {
 
     private static final String[] ASCII_LOGO = {
             "             _______     _                   _                   ",
@@ -42,7 +42,7 @@ public class ChessHogScannerConsole {
 
     private static boolean logMode = false;
 
-    private ChessHogScannerConsole() {
+    private ScannerConsole() {
     }
 
     public static void setLogMode(boolean isLogMode) {
@@ -78,7 +78,7 @@ public class ChessHogScannerConsole {
     }
 
     private static void copyright() {
-        int inceptionYear = ChessHogScannerProperties.getInt("scanner.inception.year");
+        int inceptionYear = ScannerProperties.getInt("scanner.inception.year");
         int currentYear = Calendar.getInstance().get(Calendar.YEAR);
         String copyright = currentYear > inceptionYear
                 ? String.format("%s-%s %s", inceptionYear, currentYear, COPYRIGHT)
@@ -92,7 +92,7 @@ public class ChessHogScannerConsole {
         console(
                 alignCenter(
                         String.format(
-                                "v. %s", ChessHogScannerProperties.get("scanner.version")
+                                "v. %s", ScannerProperties.get("scanner.version")
                         )
                 )
         );
@@ -24,7 +24,7 @@ import java.nio.charset.StandardCharsets;
  *
  * @author Dmitry Samoshin aka gotty
  */
-public final class ChessHogScannerConstants {
+public final class ScannerConstants {
 
     public static final Charset CHARSET = StandardCharsets.UTF_8;
 
@@ -48,7 +48,7 @@ public final class ChessHogScannerConstants {
     public static final String PROXY_HTTP = "http";
     public static final String PROXY_SOCKS = "socks";
 
-    private ChessHogScannerConstants() {
+    private ScannerConstants() {
         throw new AssertionError(
                 String.format("No %s instances!", getClass().getName())
         );
 package org.hedgecode.chess.scanner;
 
 /**
- * ChessHogScannerException
+ * ScannerException
  *
  * @author Dmitry Samoshin aka gotty
  */
-public class ChessHogScannerException extends Exception {
+public class ScannerException extends Exception {
 
-    public ChessHogScannerException(String message) {
+    public ScannerException(String message) {
         super(message);
     }
 
-    public ChessHogScannerException(Throwable cause) {
+    public ScannerException(Throwable cause) {
         super(cause);
     }
 
-    public ChessHogScannerException(String message, Throwable cause) {
+    public ScannerException(String message, Throwable cause) {
         super(message, cause);
     }
 
@@ -25,7 +25,7 @@ import java.util.Properties;
  *
  * @author Dmitry Samoshin aka gotty
  */
-public class ChessHogScannerProperties {
+public class ScannerProperties {
 
     /** Properties file. */
     private static final String PROPERTIES_FILE = "scanner.properties";
@@ -47,7 +47,7 @@ public class ChessHogScannerProperties {
      * @param throwExc Flag indicating whether to throw an exception or not.
      */
     public static void readProperties(String propsFile, Properties props, boolean throwExc) {
-        try (InputStream is = ChessHogScannerProperties.class.getClassLoader().getResourceAsStream(propsFile))
+        try (InputStream is = ScannerProperties.class.getClassLoader().getResourceAsStream(propsFile))
         {
             if (is == null) {
                 if (throwExc) {
@@ -114,7 +114,7 @@ public class ChessHogScannerProperties {
     /**
      * Private constructor.
      */
-    private ChessHogScannerProperties() {
+    private ScannerProperties() {
     }
 
 }
index 306c316..49217ea 100644 (file)
@@ -16,7 +16,7 @@
 
 package org.hedgecode.chess.scanner;
 
-import static org.hedgecode.chess.scanner.ChessHogScannerConstants.*;
+import static org.hedgecode.chess.scanner.ScannerConstants.*;
 
 /**
  * ScannerType
index f71899f..5e3f155 100644 (file)
@@ -23,6 +23,6 @@ package org.hedgecode.chess.scanner;
  */
 public interface SettingsBuilder {
 
-    Settings build(String name) throws ChessHogScannerException;
+    Settings build(String name) throws ScannerException;
 
 }
index 0fb7eda..e0ddbcc 100644 (file)
@@ -23,7 +23,7 @@ import java.io.InputStreamReader;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 
-import org.hedgecode.chess.scanner.ChessHogScannerException;
+import org.hedgecode.chess.scanner.ScannerException;
 import org.hedgecode.chess.scanner.Settings;
 import org.hedgecode.chess.scanner.SettingsBuilder;
 
@@ -39,7 +39,7 @@ public class JSONSettingsBuilder implements SettingsBuilder {
     private static final Gson GSON = new GsonBuilder().create();
 
     @Override
-    public Settings build(String jsonFileName) throws ChessHogScannerException {
+    public Settings build(String jsonFileName) throws ScannerException {
         Settings settings;
         try (BufferedReader jsonReader = new BufferedReader(
                 new InputStreamReader(
@@ -53,7 +53,7 @@ public class JSONSettingsBuilder implements SettingsBuilder {
                     JSONSettings.class
             );
         } catch (IOException cause) {
-            throw new ChessHogScannerException(
+            throw new ScannerException(
                     String.format("Failed to get settings from resource file: %s", jsonFileName), cause
             );
         }
index 0390848..e179d2c 100644 (file)
@@ -27,14 +27,14 @@ import org.apache.http.client.methods.HttpGet;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
 
-import org.hedgecode.chess.scanner.ChessHogScannerException;
 import org.hedgecode.chess.scanner.Scanner;
+import org.hedgecode.chess.scanner.ScannerException;
 import org.hedgecode.chess.scanner.regex.RegexMatcher;
 import org.hedgecode.chess.scanner.regex.RegexResult;
 import org.hedgecode.chess.scanner.regex.RegexType;
 import org.hedgecode.chess.scanner.regex.RegexTypeMatcher;
 
-import static org.hedgecode.chess.scanner.ChessHogScannerConstants.*;
+import static org.hedgecode.chess.scanner.ScannerConstants.*;
 
 /**
  * AbstractRequestScanner
@@ -43,11 +43,11 @@ import static org.hedgecode.chess.scanner.ChessHogScannerConstants.*;
  */
 public abstract class AbstractRequestScanner implements Scanner {
 
-    protected String request(String url) throws ChessHogScannerException {
+    protected String request(String url) throws ScannerException {
         return request(url, true);
     }
 
-    protected String request(String url, boolean withCrlf) throws ChessHogScannerException {
+    protected String request(String url, boolean withCrlf) throws ScannerException {
         HttpGet request = new HttpGet(url);
         CloseableHttpResponse response = null;
         StringBuilder sb = new StringBuilder();
@@ -67,7 +67,7 @@ public abstract class AbstractRequestScanner implements Scanner {
                 }
             }
         } catch (IOException cause) {
-            throw new ChessHogScannerException(
+            throw new ScannerException(
                     String.format("Error occurred for requesting URL: %s", url), cause
             );
         } finally {
@@ -80,30 +80,30 @@ public abstract class AbstractRequestScanner implements Scanner {
         return sb.toString();
     }
 
-    protected List<String> split(String url, String splitMatch) throws ChessHogScannerException {
+    protected List<String> split(String url, String splitMatch) throws ScannerException {
         RegexResult result = splitRequest(url, splitMatch);
         return result.resultList();
     }
 
-    protected Map<String, String> splitMap(String url, String splitMatch) throws ChessHogScannerException {
+    protected Map<String, String> splitMap(String url, String splitMatch) throws ScannerException {
         RegexResult result = splitRequest(url, splitMatch);
         return result.resultMap();
     }
 
-    protected RegexResult splitRequest(String url, String splitMatch) throws ChessHogScannerException {
+    protected RegexResult splitRequest(String url, String splitMatch) throws ScannerException {
         RegexMatcher matcher = new RegexTypeMatcher(
                 RegexType.SPLIT, splitMatch
         );
         return matchRequest(url, matcher, false);
     }
 
-    protected String match(String url, String match) throws ChessHogScannerException {
+    protected String match(String url, String match) throws ScannerException {
         List<String> result = match(url, match, true);
         return result.isEmpty() ? null : result.get(0);
     }
 
     protected List<String> match(String url, String match, boolean isFirst)
-            throws ChessHogScannerException
+            throws ScannerException
     {
         RegexMatcher matcher = new RegexTypeMatcher(
                 RegexType.FIND, match
@@ -117,7 +117,7 @@ public abstract class AbstractRequestScanner implements Scanner {
     }
 
     protected Map<String, String> matchMap(String url, String match, boolean isFirst)
-            throws ChessHogScannerException
+            throws ScannerException
     {
         RegexMatcher matcher = new RegexTypeMatcher(
                 RegexType.FIND, match
@@ -131,14 +131,14 @@ public abstract class AbstractRequestScanner implements Scanner {
     }
 
     protected String match(String url, String startMatch, String endMatch)
-            throws ChessHogScannerException
+            throws ScannerException
     {
         List<String> result = match(url, startMatch, endMatch, true);
         return result.isEmpty() ? null : result.get(0);
     }
 
     protected List<String> match(String url, String startMatch, String endMatch, boolean isFirst)
-            throws ChessHogScannerException
+            throws ScannerException
     {
         RegexMatcher matcher = new RegexTypeMatcher(
                 startMatch, endMatch
@@ -152,7 +152,7 @@ public abstract class AbstractRequestScanner implements Scanner {
     }
 
     protected Map<String, String> matchMap(String url, String startMatch, String endMatch, boolean isFirst)
-            throws ChessHogScannerException
+            throws ScannerException
     {
         RegexMatcher matcher = new RegexTypeMatcher(
                 startMatch, endMatch
@@ -166,7 +166,7 @@ public abstract class AbstractRequestScanner implements Scanner {
     }
 
     protected RegexResult matchRequest(String url, RegexMatcher matcher, boolean isFirst)
-            throws ChessHogScannerException
+            throws ScannerException
     {
         HttpGet request = new HttpGet(url);
         CloseableHttpResponse response = null;
@@ -187,7 +187,7 @@ public abstract class AbstractRequestScanner implements Scanner {
                 }
             }
         } catch (IOException cause) {
-            throw new ChessHogScannerException(
+            throw new ScannerException(
                     String.format("Error occurred for requesting URL: %s", url), cause
             );
         } finally {
index 445b603..8d0ccf4 100644 (file)
@@ -19,15 +19,15 @@ package org.hedgecode.chess.scanner.portal;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.hedgecode.chess.scanner.ChessHogScannerException;
 import org.hedgecode.chess.scanner.Initiable;
+import org.hedgecode.chess.scanner.ScannerException;
 import org.hedgecode.chess.scanner.Settings;
 import org.hedgecode.chess.scanner.SettingsBuilder;
 import org.hedgecode.chess.scanner.regex.RegexBuilder;
 import org.hedgecode.chess.scanner.regex.RegexParams;
 import org.hedgecode.chess.scanner.spi.ServiceRegistry;
 
-import static org.hedgecode.chess.scanner.ChessHogScannerConstants.*;
+import static org.hedgecode.chess.scanner.ScannerConstants.*;
 import static org.hedgecode.chess.scanner.regex.RegexBuilder.Type;
 
 /**
@@ -42,7 +42,7 @@ public abstract class AbstractSettingsScanner extends AbstractRequestScanner imp
     protected abstract String getResourceName();
 
     @Override
-    public void init() throws ChessHogScannerException {
+    public void init() throws ScannerException {
         SettingsBuilder settingsBuilder = ServiceRegistry.singleProvider(
                 SettingsBuilder.class
         );
index 6d4b18c..476bc7e 100644 (file)
@@ -16,8 +16,8 @@
 
 package org.hedgecode.chess.scanner.portal;
 
-import org.hedgecode.chess.scanner.ChessHogScannerException;
 import org.hedgecode.chess.scanner.Scanner;
+import org.hedgecode.chess.scanner.ScannerException;
 import org.hedgecode.chess.scanner.entity.PGNGame;
 import org.hedgecode.chess.scanner.entity.PGNTournament;
 
@@ -36,34 +36,34 @@ public class Chess24Scanner extends AbstractSettingsScanner implements Scanner {
     }
 
     @Override
-    public PGNTournament scanTournament(String tournamentId) throws ChessHogScannerException {
-        throw new ChessHogScannerException(
+    public PGNTournament scanTournament(String tournamentId) throws ScannerException {
+        throw new ScannerException(
                 "The scanner functional of portal chess24.com is under development!"
         );
     }
 
     @Override
-    public PGNTournament findTournament(String tournamentName) throws ChessHogScannerException {
-        throw new ChessHogScannerException(
+    public PGNTournament findTournament(String tournamentName) throws ScannerException {
+        throw new ScannerException(
                 "The scanner functional of portal chess24.com is under development!"
         );
     }
 
     @Override
-    public PGNGame scanGame(String gameId) throws ChessHogScannerException {
+    public PGNGame scanGame(String gameId) throws ScannerException {
         return scanGame(gameId, null);
     }
 
     @Override
-    public PGNGame scanGame(String gameId, String tournamentId) throws ChessHogScannerException {
-        throw new ChessHogScannerException(
+    public PGNGame scanGame(String gameId, String tournamentId) throws ScannerException {
+        throw new ScannerException(
                 "The scanner functional of portal chess24.com is under development!"
         );
     }
 
     @Override
-    public PGNGame scanUrl(String gameUrl) throws ChessHogScannerException {
-        throw new ChessHogScannerException(
+    public PGNGame scanUrl(String gameUrl) throws ScannerException {
+        throw new ScannerException(
                 "The scanner functional of portal chess24.com is under development!"
         );
     }
index 6139ed4..096a36e 100644 (file)
@@ -18,8 +18,8 @@ package org.hedgecode.chess.scanner.portal;
 
 import java.util.Base64;
 
-import org.hedgecode.chess.scanner.ChessHogScannerException;
 import org.hedgecode.chess.scanner.Scanner;
+import org.hedgecode.chess.scanner.ScannerException;
 import org.hedgecode.chess.scanner.entity.PGNGame;
 import org.hedgecode.chess.scanner.entity.PGNTournament;
 import org.hedgecode.chess.scanner.format.chessbomb.ArenaFormat;
@@ -42,7 +42,7 @@ public class ChessBombScanner extends AbstractSettingsScanner implements Scanner
     }
 
     @Override
-    public PGNTournament scanTournament(String tournamentId) throws ChessHogScannerException {
+    public PGNTournament scanTournament(String tournamentId) throws ScannerException {
         String decodeTournament = decodeUrlByRegex(
                 assignUrl(tournamentId, null),
                 getSettings().getTournamentJsonUrlRegex()
@@ -64,7 +64,7 @@ public class ChessBombScanner extends AbstractSettingsScanner implements Scanner
     }
 
     @Override
-    public PGNTournament findTournament(String tournamentName) throws ChessHogScannerException {
+    public PGNTournament findTournament(String tournamentName) throws ScannerException {
         String decodeArena = decodeUrlByRegex(
                 assignUrl(tournamentName, false),
                 getSettings().getTournamentQueryUrlRegex()
@@ -80,14 +80,14 @@ public class ChessBombScanner extends AbstractSettingsScanner implements Scanner
     }
 
     @Override
-    public PGNGame scanGame(String gameId) throws ChessHogScannerException {
-        throw new ChessHogScannerException(
+    public PGNGame scanGame(String gameId) throws ScannerException {
+        throw new ScannerException(
                 "ChessBomb does not support searching game without a tournament name!"
         );
     }
 
     @Override
-    public PGNGame scanGame(String gameId, String tournamentId) throws ChessHogScannerException {
+    public PGNGame scanGame(String gameId, String tournamentId) throws ScannerException {
         return scanGameByRegex(
                 assignUrl(gameId, tournamentId, true),
                 getSettings().getGameJsonUrlRegex()
@@ -95,14 +95,14 @@ public class ChessBombScanner extends AbstractSettingsScanner implements Scanner
     }
 
     @Override
-    public PGNGame scanUrl(String gameUrl) throws ChessHogScannerException {
+    public PGNGame scanUrl(String gameUrl) throws ScannerException {
         return scanGameByRegex(
                 gameUrl,
                 getSettings().getGameJsonUrlRegex()
         );
     }
 
-    private PGNGame scanGameByRegex(String gameUrl, String regex) throws ChessHogScannerException {
+    private PGNGame scanGameByRegex(String gameUrl, String regex) throws ScannerException {
         String decodeGame = decodeUrlByRegex(
                 gameUrl,
                 regex
@@ -117,13 +117,13 @@ public class ChessBombScanner extends AbstractSettingsScanner implements Scanner
     }
 
 
-    private String decodeUrlByRegex(String url, String regex) throws ChessHogScannerException {
+    private String decodeUrlByRegex(String url, String regex) throws ScannerException {
         String encodeString = match(
                 url,
                 regex
         );
         if (encodeString == null) {
-            throw new ChessHogScannerException(
+            throw new ScannerException(
                     String.format("Failed to decode source data for requesting URL: %s", url)
             );
         }
index a7f94cd..313d8e0 100644 (file)
@@ -16,8 +16,8 @@
 
 package org.hedgecode.chess.scanner.portal;
 
-import org.hedgecode.chess.scanner.ChessHogScannerException;
 import org.hedgecode.chess.scanner.Scanner;
+import org.hedgecode.chess.scanner.ScannerException;
 import org.hedgecode.chess.scanner.entity.PGNGame;
 import org.hedgecode.chess.scanner.entity.PGNTournament;
 
@@ -36,34 +36,34 @@ public class ChessComScanner extends AbstractSettingsScanner implements Scanner
     }
 
     @Override
-    public PGNTournament scanTournament(String tournamentId) throws ChessHogScannerException {
-        throw new ChessHogScannerException(
+    public PGNTournament scanTournament(String tournamentId) throws ScannerException {
+        throw new ScannerException(
                 "The scanner functional of portal chess.com is under development!"
         );
     }
 
     @Override
-    public PGNTournament findTournament(String tournamentName) throws ChessHogScannerException {
-        throw new ChessHogScannerException(
+    public PGNTournament findTournament(String tournamentName) throws ScannerException {
+        throw new ScannerException(
                 "The scanner functional of portal chess.com is under development!"
         );
     }
 
     @Override
-    public PGNGame scanGame(String gameId) throws ChessHogScannerException {
+    public PGNGame scanGame(String gameId) throws ScannerException {
         return scanGame(gameId, null);
     }
 
     @Override
-    public PGNGame scanGame(String gameId, String tournamentId) throws ChessHogScannerException {
-        throw new ChessHogScannerException(
+    public PGNGame scanGame(String gameId, String tournamentId) throws ScannerException {
+        throw new ScannerException(
                 "The scanner functional of portal chess.com is under development!"
         );
     }
 
     @Override
-    public PGNGame scanUrl(String gameUrl) throws ChessHogScannerException {
-        throw new ChessHogScannerException(
+    public PGNGame scanUrl(String gameUrl) throws ScannerException {
+        throw new ScannerException(
                 "The scanner functional of portal chess.com is under development!"
         );
     }
index dfca440..247660a 100644 (file)
@@ -20,8 +20,8 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
-import org.hedgecode.chess.scanner.ChessHogScannerException;
 import org.hedgecode.chess.scanner.Scanner;
+import org.hedgecode.chess.scanner.ScannerException;
 import org.hedgecode.chess.scanner.entity.PGNGame;
 import org.hedgecode.chess.scanner.entity.PGNTournament;
 
@@ -40,14 +40,14 @@ public class ChessGamesScanner extends AbstractSettingsScanner implements Scanne
     }
 
     @Override
-    public PGNTournament scanTournament(String tournamentId) throws ChessHogScannerException {
+    public PGNTournament scanTournament(String tournamentId) throws ScannerException {
         PGNTournament tournament = new PGNTournament(tournamentId);
         assignTournamentGames(tournament);
         return tournament;
     }
 
     @Override
-    public PGNTournament findTournament(String tournamentName) throws ChessHogScannerException {
+    public PGNTournament findTournament(String tournamentName) throws ScannerException {
         PGNTournament tournament = null;
         Map<String, String> result = matchMap(
                 assignUrl(
@@ -71,12 +71,12 @@ public class ChessGamesScanner extends AbstractSettingsScanner implements Scanne
     }
 
     @Override
-    public PGNGame scanGame(String gameId) throws ChessHogScannerException {
+    public PGNGame scanGame(String gameId) throws ScannerException {
         String pgn = request(
                 assignUrl(gameId)
         );
         if (!isPgnFormat(pgn)) {
-            throw new ChessHogScannerException(
+            throw new ScannerException(
                     String.format("Failed to get PGN for requesting game ID: %s", gameId)
             );
         }
@@ -86,12 +86,12 @@ public class ChessGamesScanner extends AbstractSettingsScanner implements Scanne
     }
 
     @Override
-    public PGNGame scanGame(String gameId, String tournamentId) throws ChessHogScannerException {
+    public PGNGame scanGame(String gameId, String tournamentId) throws ScannerException {
         return scanGame(gameId);
     }
 
     @Override
-    public PGNGame scanUrl(String gameUrl) throws ChessHogScannerException {
+    public PGNGame scanUrl(String gameUrl) throws ScannerException {
         String pgn = regex(
                 request(
                         gameUrl
@@ -99,7 +99,7 @@ public class ChessGamesScanner extends AbstractSettingsScanner implements Scanne
                 getSettings().getGameUrlRegex()
         );
         if (pgn == null || !isPgnFormat(pgn)) {
-            throw new ChessHogScannerException(
+            throw new ScannerException(
                     String.format("Failed to get PGN for requesting URL: %s", gameUrl)
             );
         }
@@ -109,7 +109,7 @@ public class ChessGamesScanner extends AbstractSettingsScanner implements Scanne
         );
     }
 
-    private void assignTournamentGames(PGNTournament tournament) throws ChessHogScannerException {
+    private void assignTournamentGames(PGNTournament tournament) throws ScannerException {
         tournament.clearGames();
         List<String> gamesId = new ArrayList<>();
 
index e43795a..55a53e9 100644 (file)
@@ -20,14 +20,14 @@ import java.util.List;
 
 import org.apache.commons.text.StringEscapeUtils;
 
-import org.hedgecode.chess.scanner.ChessHogScannerException;
 import org.hedgecode.chess.scanner.Scanner;
+import org.hedgecode.chess.scanner.ScannerException;
 import org.hedgecode.chess.scanner.entity.PGNGame;
 import org.hedgecode.chess.scanner.entity.PGNTournament;
 import org.hedgecode.chess.scanner.format.lichess.Format;
 import org.hedgecode.chess.scanner.format.lichess.GameFormat;
 
-import static org.hedgecode.chess.scanner.ChessHogScannerConstants.*;
+import static org.hedgecode.chess.scanner.ScannerConstants.*;
 
 /**
  * LiChessScanner
@@ -44,26 +44,26 @@ public class LiChessScanner extends AbstractSettingsScanner implements Scanner {
     }
 
     @Override
-    public PGNTournament scanTournament(String tournamentId) throws ChessHogScannerException {
+    public PGNTournament scanTournament(String tournamentId) throws ScannerException {
         PGNTournament tournament = new PGNTournament(tournamentId);
         assignTournamentGames(tournament);
         return tournament;
     }
 
     @Override
-    public PGNTournament findTournament(String tournamentName) throws ChessHogScannerException {
-        throw new ChessHogScannerException(
+    public PGNTournament findTournament(String tournamentName) throws ScannerException {
+        throw new ScannerException(
                 "Lichess does not support searching for a tournament by name!"
         );
     }
 
     @Override
-    public PGNGame scanGame(String gameId) throws ChessHogScannerException {
+    public PGNGame scanGame(String gameId) throws ScannerException {
         String pgn = request(
                 assignUrl(gameId)
         );
         if (!isPgnFormat(pgn)) {
-            throw new ChessHogScannerException(
+            throw new ScannerException(
                     String.format("Failed to get PGN for requesting game ID: %s", gameId)
             );
         }
@@ -73,12 +73,12 @@ public class LiChessScanner extends AbstractSettingsScanner implements Scanner {
     }
 
     @Override
-    public PGNGame scanGame(String gameId, String tournamentId) throws ChessHogScannerException {
+    public PGNGame scanGame(String gameId, String tournamentId) throws ScannerException {
         return scanGame(gameId);
     }
 
     @Override
-    public PGNGame scanUrl(String gameUrl) throws ChessHogScannerException {
+    public PGNGame scanUrl(String gameUrl) throws ScannerException {
         String gamePage = request(gameUrl);
         String pgn = regex(
                 gamePage,
@@ -90,7 +90,7 @@ public class LiChessScanner extends AbstractSettingsScanner implements Scanner {
                     getSettings().getGameJsonUrlRegex()
             );
             if (pgn == null) {
-                throw new ChessHogScannerException(
+                throw new ScannerException(
                         String.format("Failed to get source data for requesting URL: %s", gameUrl)
                 );
             }
@@ -102,7 +102,7 @@ public class LiChessScanner extends AbstractSettingsScanner implements Scanner {
         } else {
             pgn = StringEscapeUtils.unescapeHtml4(pgn);
             if (!isPgnFormat(pgn)) {
-                throw new ChessHogScannerException(
+                throw new ScannerException(
                         String.format("Failed to get PGN for requesting URL: %s", gameUrl)
                 );
             }
@@ -113,7 +113,7 @@ public class LiChessScanner extends AbstractSettingsScanner implements Scanner {
         }
     }
 
-    private void assignTournamentGames(PGNTournament tournament) throws ChessHogScannerException {
+    private void assignTournamentGames(PGNTournament tournament) throws ScannerException {
         tournament.clearGames();
         List<String> pgnGames = split(
                 assignUrl(
index 781d8d4..b54fece 100644 (file)
@@ -19,7 +19,7 @@ package org.hedgecode.chess.scanner.proxy;
 import org.hedgecode.chess.scanner.proxy.type.HTTPSetter;
 import org.hedgecode.chess.scanner.proxy.type.SOCKSSetter;
 
-import static org.hedgecode.chess.scanner.ChessHogScannerConstants.*;
+import static org.hedgecode.chess.scanner.ScannerConstants.*;
 
 /**
  * Setter for proxy settings.
index 0b80b09..94fd7ab 100644 (file)
@@ -19,7 +19,7 @@ package org.hedgecode.chess.scanner.regex;
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
 
-import static org.hedgecode.chess.scanner.ChessHogScannerConstants.*;
+import static org.hedgecode.chess.scanner.ScannerConstants.*;
 
 /**
  * RegexBuilder
index 2e50b8c..38be337 100644 (file)
@@ -23,7 +23,7 @@ import org.hedgecode.chess.scanner.regex.AbstractRegexResult;
 import org.hedgecode.chess.scanner.regex.RegexMatcher;
 import org.hedgecode.chess.scanner.regex.RegexResult;
 
-import static org.hedgecode.chess.scanner.ChessHogScannerConstants.*;
+import static org.hedgecode.chess.scanner.ScannerConstants.*;
 
 /**
  * RegexBlockFinder
index 92ddcbd..8b18f54 100644 (file)
@@ -25,7 +25,7 @@ import org.hedgecode.chess.scanner.regex.AbstractRegexResult;
 import org.hedgecode.chess.scanner.regex.RegexMatcher;
 import org.hedgecode.chess.scanner.regex.RegexResult;
 
-import static org.hedgecode.chess.scanner.ChessHogScannerConstants.*;
+import static org.hedgecode.chess.scanner.ScannerConstants.*;
 
 /**
  * RegexSplitter