From df574e5ec8ae08c1c50adbe30b597cd86e6ab3fa Mon Sep 17 00:00:00 2001 From: gotty Date: Sun, 19 Jan 2020 00:15:43 +0300 Subject: [PATCH] [LIB-13] Rename some common classes --- .../hedgecode/chess/scanner/ChessHogScanner.java | 12 ++++---- .../chess/scanner/ChessHogScannerApp.java | 13 ++++----- .../org/hedgecode/chess/scanner/Initiable.java | 2 +- .../java/org/hedgecode/chess/scanner/Scanner.java | 10 +++---- ...sHogScannerConsole.java => ScannerConsole.java} | 8 +++--- ...ScannerConstants.java => ScannerConstants.java} | 4 +-- ...ScannerException.java => ScannerException.java} | 10 +++---- ...annerProperties.java => ScannerProperties.java} | 6 ++-- .../org/hedgecode/chess/scanner/ScannerType.java | 2 +- .../hedgecode/chess/scanner/SettingsBuilder.java | 2 +- .../chess/scanner/json/JSONSettingsBuilder.java | 6 ++-- .../scanner/portal/AbstractRequestScanner.java | 32 +++++++++++----------- .../scanner/portal/AbstractSettingsScanner.java | 6 ++-- .../chess/scanner/portal/Chess24Scanner.java | 20 +++++++------- .../chess/scanner/portal/ChessBombScanner.java | 20 +++++++------- .../chess/scanner/portal/ChessComScanner.java | 20 +++++++------- .../chess/scanner/portal/ChessGamesScanner.java | 18 ++++++------ .../chess/scanner/portal/LiChessScanner.java | 24 ++++++++-------- .../org/hedgecode/chess/scanner/proxy/Proxy.java | 2 +- .../chess/scanner/regex/RegexBuilder.java | 2 +- .../chess/scanner/regex/type/RegexBlockFinder.java | 2 +- .../chess/scanner/regex/type/RegexSplitter.java | 2 +- 22 files changed, 110 insertions(+), 113 deletions(-) rename src/main/java/org/hedgecode/chess/scanner/{ChessHogScannerConsole.java => ScannerConsole.java} (92%) rename src/main/java/org/hedgecode/chess/scanner/{ChessHogScannerConstants.java => ScannerConstants.java} (95%) rename src/main/java/org/hedgecode/chess/scanner/{ChessHogScannerException.java => ScannerException.java} (75%) rename src/main/java/org/hedgecode/chess/scanner/{ChessHogScannerProperties.java => ScannerProperties.java} (94%) diff --git a/src/main/java/org/hedgecode/chess/scanner/ChessHogScanner.java b/src/main/java/org/hedgecode/chess/scanner/ChessHogScanner.java index 91a05c8..93c8143 100644 --- a/src/main/java/org/hedgecode/chess/scanner/ChessHogScanner.java +++ b/src/main/java/org/hedgecode/chess/scanner/ChessHogScanner.java @@ -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(); } } diff --git a/src/main/java/org/hedgecode/chess/scanner/ChessHogScannerApp.java b/src/main/java/org/hedgecode/chess/scanner/ChessHogScannerApp.java index 618a802..060773c 100644 --- a/src/main/java/org/hedgecode/chess/scanner/ChessHogScannerApp.java +++ b/src/main/java/org/hedgecode/chess/scanner/ChessHogScannerApp.java @@ -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); } diff --git a/src/main/java/org/hedgecode/chess/scanner/Initiable.java b/src/main/java/org/hedgecode/chess/scanner/Initiable.java index 4fd24d6..da729a4 100644 --- a/src/main/java/org/hedgecode/chess/scanner/Initiable.java +++ b/src/main/java/org/hedgecode/chess/scanner/Initiable.java @@ -23,6 +23,6 @@ package org.hedgecode.chess.scanner; */ public interface Initiable { - void init() throws ChessHogScannerException; + void init() throws ScannerException; } diff --git a/src/main/java/org/hedgecode/chess/scanner/Scanner.java b/src/main/java/org/hedgecode/chess/scanner/Scanner.java index 2c6095a..5188214 100644 --- a/src/main/java/org/hedgecode/chess/scanner/Scanner.java +++ b/src/main/java/org/hedgecode/chess/scanner/Scanner.java @@ -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; } diff --git a/src/main/java/org/hedgecode/chess/scanner/ChessHogScannerConsole.java b/src/main/java/org/hedgecode/chess/scanner/ScannerConsole.java similarity index 92% rename from src/main/java/org/hedgecode/chess/scanner/ChessHogScannerConsole.java rename to src/main/java/org/hedgecode/chess/scanner/ScannerConsole.java index 4b824fb..0037ef5 100644 --- a/src/main/java/org/hedgecode/chess/scanner/ChessHogScannerConsole.java +++ b/src/main/java/org/hedgecode/chess/scanner/ScannerConsole.java @@ -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") ) ) ); diff --git a/src/main/java/org/hedgecode/chess/scanner/ChessHogScannerConstants.java b/src/main/java/org/hedgecode/chess/scanner/ScannerConstants.java similarity index 95% rename from src/main/java/org/hedgecode/chess/scanner/ChessHogScannerConstants.java rename to src/main/java/org/hedgecode/chess/scanner/ScannerConstants.java index fba0733..a78a058 100644 --- a/src/main/java/org/hedgecode/chess/scanner/ChessHogScannerConstants.java +++ b/src/main/java/org/hedgecode/chess/scanner/ScannerConstants.java @@ -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()) ); diff --git a/src/main/java/org/hedgecode/chess/scanner/ChessHogScannerException.java b/src/main/java/org/hedgecode/chess/scanner/ScannerException.java similarity index 75% rename from src/main/java/org/hedgecode/chess/scanner/ChessHogScannerException.java rename to src/main/java/org/hedgecode/chess/scanner/ScannerException.java index 4636585..0ea2872 100644 --- a/src/main/java/org/hedgecode/chess/scanner/ChessHogScannerException.java +++ b/src/main/java/org/hedgecode/chess/scanner/ScannerException.java @@ -17,21 +17,21 @@ 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); } diff --git a/src/main/java/org/hedgecode/chess/scanner/ChessHogScannerProperties.java b/src/main/java/org/hedgecode/chess/scanner/ScannerProperties.java similarity index 94% rename from src/main/java/org/hedgecode/chess/scanner/ChessHogScannerProperties.java rename to src/main/java/org/hedgecode/chess/scanner/ScannerProperties.java index fdead40..d10237d 100644 --- a/src/main/java/org/hedgecode/chess/scanner/ChessHogScannerProperties.java +++ b/src/main/java/org/hedgecode/chess/scanner/ScannerProperties.java @@ -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() { } } diff --git a/src/main/java/org/hedgecode/chess/scanner/ScannerType.java b/src/main/java/org/hedgecode/chess/scanner/ScannerType.java index 306c316..49217ea 100644 --- a/src/main/java/org/hedgecode/chess/scanner/ScannerType.java +++ b/src/main/java/org/hedgecode/chess/scanner/ScannerType.java @@ -16,7 +16,7 @@ package org.hedgecode.chess.scanner; -import static org.hedgecode.chess.scanner.ChessHogScannerConstants.*; +import static org.hedgecode.chess.scanner.ScannerConstants.*; /** * ScannerType diff --git a/src/main/java/org/hedgecode/chess/scanner/SettingsBuilder.java b/src/main/java/org/hedgecode/chess/scanner/SettingsBuilder.java index f71899f..5e3f155 100644 --- a/src/main/java/org/hedgecode/chess/scanner/SettingsBuilder.java +++ b/src/main/java/org/hedgecode/chess/scanner/SettingsBuilder.java @@ -23,6 +23,6 @@ package org.hedgecode.chess.scanner; */ public interface SettingsBuilder { - Settings build(String name) throws ChessHogScannerException; + Settings build(String name) throws ScannerException; } diff --git a/src/main/java/org/hedgecode/chess/scanner/json/JSONSettingsBuilder.java b/src/main/java/org/hedgecode/chess/scanner/json/JSONSettingsBuilder.java index 0fb7eda..e0ddbcc 100644 --- a/src/main/java/org/hedgecode/chess/scanner/json/JSONSettingsBuilder.java +++ b/src/main/java/org/hedgecode/chess/scanner/json/JSONSettingsBuilder.java @@ -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 ); } diff --git a/src/main/java/org/hedgecode/chess/scanner/portal/AbstractRequestScanner.java b/src/main/java/org/hedgecode/chess/scanner/portal/AbstractRequestScanner.java index 0390848..e179d2c 100644 --- a/src/main/java/org/hedgecode/chess/scanner/portal/AbstractRequestScanner.java +++ b/src/main/java/org/hedgecode/chess/scanner/portal/AbstractRequestScanner.java @@ -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 split(String url, String splitMatch) throws ChessHogScannerException { + protected List split(String url, String splitMatch) throws ScannerException { RegexResult result = splitRequest(url, splitMatch); return result.resultList(); } - protected Map splitMap(String url, String splitMatch) throws ChessHogScannerException { + protected Map 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 result = match(url, match, true); return result.isEmpty() ? null : result.get(0); } protected List 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 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 result = match(url, startMatch, endMatch, true); return result.isEmpty() ? null : result.get(0); } protected List 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 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 { diff --git a/src/main/java/org/hedgecode/chess/scanner/portal/AbstractSettingsScanner.java b/src/main/java/org/hedgecode/chess/scanner/portal/AbstractSettingsScanner.java index 445b603..8d0ccf4 100644 --- a/src/main/java/org/hedgecode/chess/scanner/portal/AbstractSettingsScanner.java +++ b/src/main/java/org/hedgecode/chess/scanner/portal/AbstractSettingsScanner.java @@ -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 ); diff --git a/src/main/java/org/hedgecode/chess/scanner/portal/Chess24Scanner.java b/src/main/java/org/hedgecode/chess/scanner/portal/Chess24Scanner.java index 6d4b18c..476bc7e 100644 --- a/src/main/java/org/hedgecode/chess/scanner/portal/Chess24Scanner.java +++ b/src/main/java/org/hedgecode/chess/scanner/portal/Chess24Scanner.java @@ -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!" ); } diff --git a/src/main/java/org/hedgecode/chess/scanner/portal/ChessBombScanner.java b/src/main/java/org/hedgecode/chess/scanner/portal/ChessBombScanner.java index 6139ed4..096a36e 100644 --- a/src/main/java/org/hedgecode/chess/scanner/portal/ChessBombScanner.java +++ b/src/main/java/org/hedgecode/chess/scanner/portal/ChessBombScanner.java @@ -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) ); } diff --git a/src/main/java/org/hedgecode/chess/scanner/portal/ChessComScanner.java b/src/main/java/org/hedgecode/chess/scanner/portal/ChessComScanner.java index a7f94cd..313d8e0 100644 --- a/src/main/java/org/hedgecode/chess/scanner/portal/ChessComScanner.java +++ b/src/main/java/org/hedgecode/chess/scanner/portal/ChessComScanner.java @@ -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!" ); } diff --git a/src/main/java/org/hedgecode/chess/scanner/portal/ChessGamesScanner.java b/src/main/java/org/hedgecode/chess/scanner/portal/ChessGamesScanner.java index dfca440..247660a 100644 --- a/src/main/java/org/hedgecode/chess/scanner/portal/ChessGamesScanner.java +++ b/src/main/java/org/hedgecode/chess/scanner/portal/ChessGamesScanner.java @@ -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 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 gamesId = new ArrayList<>(); diff --git a/src/main/java/org/hedgecode/chess/scanner/portal/LiChessScanner.java b/src/main/java/org/hedgecode/chess/scanner/portal/LiChessScanner.java index e43795a..55a53e9 100644 --- a/src/main/java/org/hedgecode/chess/scanner/portal/LiChessScanner.java +++ b/src/main/java/org/hedgecode/chess/scanner/portal/LiChessScanner.java @@ -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 pgnGames = split( assignUrl( diff --git a/src/main/java/org/hedgecode/chess/scanner/proxy/Proxy.java b/src/main/java/org/hedgecode/chess/scanner/proxy/Proxy.java index 781d8d4..b54fece 100644 --- a/src/main/java/org/hedgecode/chess/scanner/proxy/Proxy.java +++ b/src/main/java/org/hedgecode/chess/scanner/proxy/Proxy.java @@ -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. diff --git a/src/main/java/org/hedgecode/chess/scanner/regex/RegexBuilder.java b/src/main/java/org/hedgecode/chess/scanner/regex/RegexBuilder.java index 0b80b09..94fd7ab 100644 --- a/src/main/java/org/hedgecode/chess/scanner/regex/RegexBuilder.java +++ b/src/main/java/org/hedgecode/chess/scanner/regex/RegexBuilder.java @@ -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 diff --git a/src/main/java/org/hedgecode/chess/scanner/regex/type/RegexBlockFinder.java b/src/main/java/org/hedgecode/chess/scanner/regex/type/RegexBlockFinder.java index 2e50b8c..38be337 100644 --- a/src/main/java/org/hedgecode/chess/scanner/regex/type/RegexBlockFinder.java +++ b/src/main/java/org/hedgecode/chess/scanner/regex/type/RegexBlockFinder.java @@ -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 diff --git a/src/main/java/org/hedgecode/chess/scanner/regex/type/RegexSplitter.java b/src/main/java/org/hedgecode/chess/scanner/regex/type/RegexSplitter.java index 92ddcbd..8b18f54 100644 --- a/src/main/java/org/hedgecode/chess/scanner/regex/type/RegexSplitter.java +++ b/src/main/java/org/hedgecode/chess/scanner/regex/type/RegexSplitter.java @@ -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 -- 2.10.0