+ private final Set<ScannerType> initScanners = new HashSet<>();
+
+ /**
+ * Get Scanner by {@code ScannerType}.
+ *
+ * @param type Scanner type (binding to specific chess portal).
+ * @return Implementation of {@code Scanner} for specific portal.
+ */
+ public static Scanner scanner(ScannerType type) {
+ return getStore().getScanner(type);
+ }
+
+ /**
+ * Scan PGN game by URL (for all scanner types).
+ *
+ * @param url URL string for scan.
+ * @return PGN game.
+ * @throws ChessHogScannerException Incorrect URL or unknown chess portal.
+ */
+ public static PGNGame scan(String url) throws ChessHogScannerException {
+ String hostName;
+ try {
+ hostName = new URL(url).getHost();
+ } catch (MalformedURLException cause) {
+ throw new ChessHogScannerException(
+ String.format("Incorrect URL: %s", url), cause
+ );
+ }
+ ScannerType type = ScannerType.byHost(hostName);
+ if (type == null) {
+ throw new ChessHogScannerException(
+ String.format("Host %s is not among the known for the scanner", hostName)
+ );
+ }
+ return scanner(type).scanUrl(url);