Skip to content

Commit 36eb2e3

Browse files
committed
fix javadoc errors
fix 50% of the warnings
1 parent 1bc68c3 commit 36eb2e3

10 files changed

+163
-54
lines changed

src/main/java/serpapi/BaiduSearch.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,38 @@
88
*
99
* Usage
1010
* ---
11-
* ```java
11+
* <pre>
12+
* {@code
1213
* Map<String, String> parameter = new HashMap<>();
1314
* parameter.put("q", "Coffee");
1415
* BaiduSearch baidu = new BaiduSearch(parameter, "secret api key");
1516
* JsonObject data = baidu.getJson();
1617
* JsonArray organic_results = data.get("organic_results").getAsJsonArray();
17-
* ```
18+
* }
19+
* </pre>
1820
*/
1921
public class BaiduSearch extends SerpApiSearch {
2022

23+
/**
24+
* Constructor
25+
* @param parameter search parameter
26+
* @param apiKey secret API key
27+
*/
2128
public BaiduSearch(Map<String, String> parameter, String apiKey) {
2229
super(parameter, apiKey, "baidu");
2330
}
2431

32+
/**
33+
* Constructor
34+
*/
2535
public BaiduSearch() {
2636
super("baidu");
2737
}
2838

39+
/**
40+
* Constructor
41+
* @param parameter search parameter
42+
*/
2943
public BaiduSearch(Map<String, String> parameter) {
3044
super(parameter, "baidu");
3145
}

src/main/java/serpapi/BingSearch.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,38 @@
88
*
99
* Usage
1010
* ---
11-
* ```java
11+
* <pre>
12+
* {@code
1213
* Map<String, String> parameter = new HashMap<>();
1314
* parameter.put("q", "Coffee");
1415
* BingSearch bing = new BingSearch(parameter, "secret api key");
1516
* JsonObject data = bing.getJson();
1617
* JsonArray organic_results = data.get("organic_results").getAsJsonArray();
17-
* ```
18+
* }
19+
* </pre>
1820
*/
1921
public class BingSearch extends SerpApiSearch {
2022

23+
/**
24+
* Constructor
25+
* @param parameter search parameter
26+
* @param apiKey secret API key
27+
*/
2128
public BingSearch(Map<String, String> parameter, String apiKey) {
2229
super(parameter, apiKey, "bing");
2330
}
2431

32+
/**
33+
* Constructor
34+
*/
2535
public BingSearch() {
2636
super("bing");
2737
}
2838

39+
/**
40+
* Constructor
41+
* @param parameter search parameter
42+
*/
2943
public BingSearch(Map<String, String> parameter) {
3044
super(parameter, "bing");
3145
}

src/main/java/serpapi/EbaySearch.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,38 @@
88
*
99
* Usage
1010
* ---
11-
* ```java
11+
* <pre>
12+
* {@code
1213
* Map<String, String> parameter = new HashMap<>();
1314
* parameter.put("_nkw", "Coffee");
1415
* EbaySearch ebay = new EbaySearch(parameter, "secret api key");
1516
* JsonObject data = ebay.getJson();
1617
* JsonArray organic_results = data.get("organic_results").getAsJsonArray();
17-
* ```
18+
* }
19+
* </pre>
1820
*/
1921
public class EbaySearch extends SerpApiSearch {
2022

23+
/**
24+
* Constructor
25+
* @param parameter search parameter
26+
* @param apiKey secret API key
27+
*/
2128
public EbaySearch(Map<String, String> parameter, String apiKey) {
2229
super(parameter, apiKey, "ebay");
2330
}
2431

32+
/**
33+
* Constructor
34+
*/
2535
public EbaySearch() {
2636
super("ebay");
2737
}
2838

39+
/**
40+
* Constructor
41+
* @param parameter search parameter
42+
*/
2943
public EbaySearch(Map<String, String> parameter) {
3044
super(parameter, "ebay");
3145
}

src/main/java/serpapi/GoogleSearch.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,38 @@
88
*
99
* Usage
1010
* ---
11-
* ```java
11+
* <pre>
12+
* {@code
1213
* Map<String, String> parameter = new HashMap<>();
1314
* parameter.put("q", "Coffee");
1415
* GoogleSearch google = new GoogleSearch(parameter, "secret api key");
1516
* JsonObject data = google.getJson();
1617
* JsonArray organic_results = data.get("organic_results").getAsJsonArray();
17-
* ```
18+
* }
19+
* </pre>
1820
*/
1921
public class GoogleSearch extends SerpApiSearch {
2022

23+
/**
24+
* Constructor
25+
* @param parameter search parameter
26+
* @param apiKey secret API key
27+
*/
2128
public GoogleSearch(Map<String, String> parameter, String apiKey) {
2229
super(parameter, apiKey, "google");
2330
}
2431

32+
/**
33+
* Constructor
34+
*/
2535
public GoogleSearch() {
2636
super("google");
2737
}
2838

39+
/**
40+
* Constructor
41+
* @param parameter search parameter
42+
*/
2943
public GoogleSearch(Map<String, String> parameter) {
3044
super(parameter, "google");
3145
}

src/main/java/serpapi/ParameterStringBuilder.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@
44
import java.net.URLEncoder;
55
import java.util.Map;
66

7+
/***
8+
* Encode parameter hash into a string
9+
* to be sent over HTTP
10+
*/
711
public class ParameterStringBuilder
812
{
13+
/***
14+
* @param params search parameters
15+
*/
916
public static String getParamsString(Map<String, String> params)
1017
throws UnsupportedEncodingException
1118
{

src/main/java/serpapi/SerpApiHttpClient.java

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,21 @@ public class SerpApiHttpClient {
2121
private int httpConnectionTimeout;
2222
private int httpReadTimeout;
2323

24+
// current API version
2425
public static String VERSION = "2.0.1";
26+
27+
// backend service
2528
public static String BACKEND = "https://serpapi.com";
2629

2730
// initialize gson
2831
private static Gson gson = new Gson();
2932

30-
// path
33+
// current backend HTTP path
3134
public String path;
3235

3336
/***
34-
* @param String path
37+
* Constructor
38+
* @param path
3539
*/
3640
public SerpApiHttpClient(String path) {
3741
this.path = path;
@@ -40,12 +44,12 @@ public SerpApiHttpClient(String path) {
4044
/***
4145
* Build URL
4246
*
43-
* @param path url end point
44-
* @param param hash
47+
* @param path url end point
48+
* @param parameter search parameter map like: { "q": "coffee", "location": "Austin, TX"}
4549
* @return httpUrlConnection
46-
* @throws IOException
50+
* @throws SerpApiSearchException
4751
*/
48-
public HttpURLConnection buildConnection(String path, Map<String, String> parameter) throws SerpApiSearchException {
52+
protected HttpURLConnection buildConnection(String path, Map<String, String> parameter) throws SerpApiSearchException {
4953
HttpURLConnection con;
5054
try {
5155
allowHTTPS();
@@ -115,7 +119,7 @@ public boolean verify(String hostname, SSLSession session) {
115119
/***
116120
* Get results
117121
*
118-
* @param parameter
122+
* @param parameter user search parameters
119123
* @return http response body
120124
*/
121125
public String getResults(Map<String, String> parameter) throws SerpApiSearchException {
@@ -162,7 +166,7 @@ public String getResults(Map<String, String> parameter) throws SerpApiSearchExce
162166
return content.toString();
163167
}
164168

165-
public void triggerSerpApiClientException(String content) throws SerpApiSearchException {
169+
protected void triggerSerpApiClientException(String content) throws SerpApiSearchException {
166170
String errorMessage;
167171
try {
168172
JsonObject element = gson.fromJson(content, JsonObject.class);
@@ -173,18 +177,30 @@ public void triggerSerpApiClientException(String content) throws SerpApiSearchEx
173177
throw new SerpApiSearchException(errorMessage);
174178
}
175179

180+
/**
181+
* @return current HTTP connection timeout
182+
*/
176183
public int getHttpConnectionTimeout() {
177184
return httpConnectionTimeout;
178185
}
179186

187+
/**
188+
* @param httpConnectionTimeout set HTTP connection timeout
189+
*/
180190
public void setHttpConnectionTimeout(int httpConnectionTimeout) {
181191
this.httpConnectionTimeout = httpConnectionTimeout;
182192
}
183193

194+
/**
195+
* @return current HTTP read timeout
196+
*/
184197
public int getHttpReadTimeout() {
185198
return httpReadTimeout;
186199
}
187200

201+
/**
202+
* @param httpReadTimeout set HTTP read timeout
203+
*/
188204
public void setHttpReadTimeout(int httpReadTimeout) {
189205
this.httpReadTimeout = httpReadTimeout;
190206
}

0 commit comments

Comments
 (0)