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
*/
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();
}
}
} catch (IOException cause) {
- throw new ChessHogScannerException(
+ throw new ScannerException(
String.format("Error occurred for requesting URL: %s", url), cause
);
} finally {
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
}
protected Map<String, String> matchMap(String url, String match, boolean isFirst)
- throws ChessHogScannerException
+ throws ScannerException
{
RegexMatcher matcher = new RegexTypeMatcher(
RegexType.FIND, match
}
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
}
protected Map<String, String> matchMap(String url, String startMatch, String endMatch, boolean isFirst)
- throws ChessHogScannerException
+ throws ScannerException
{
RegexMatcher matcher = new RegexTypeMatcher(
startMatch, endMatch
}
protected RegexResult matchRequest(String url, RegexMatcher matcher, boolean isFirst)
- throws ChessHogScannerException
+ throws ScannerException
{
HttpGet request = new HttpGet(url);
CloseableHttpResponse response = null;
}
}
} catch (IOException cause) {
- throw new ChessHogScannerException(
+ throw new ScannerException(
String.format("Error occurred for requesting URL: %s", url), cause
);
} finally {