Skip to content

Commit 2a78746

Browse files
committed
[refactor] update javadoc
1 parent eafb9c2 commit 2a78746

12 files changed

Lines changed: 73 additions & 4 deletions

extensions/modules/http-client/src/main/java/org/exist/xquery/modules/httpclient/ContentTypeHelper.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ private ContentTypeHelper() {
5050

5151
/**
5252
* Tests whether the content type represents XML that should be parsed.
53+
*
54+
* @param contentType the content type to test
55+
* @return {@code true} if the content type is XML
5356
*/
5457
public static boolean isXml(final String contentType) {
5558
final String mediaType = extractMediaType(contentType);
@@ -60,6 +63,9 @@ public static boolean isXml(final String contentType) {
6063

6164
/**
6265
* Tests whether the content type represents HTML that should be parsed.
66+
*
67+
* @param contentType the content type to test
68+
* @return {@code true} if the content type is HTML
6369
*/
6470
public static boolean isHtml(final String contentType) {
6571
final String mediaType = extractMediaType(contentType);
@@ -71,6 +77,9 @@ public static boolean isHtml(final String contentType) {
7177
* Tests whether the content type represents text that should be returned as xs:string.
7278
*
7379
* <p>Excludes XML and HTML types (which are parsed as documents instead).</p>
80+
*
81+
* @param contentType the content type to test
82+
* @return {@code true} if the content type is text
7483
*/
7584
public static boolean isText(final String contentType) {
7685
final String mediaType = extractMediaType(contentType);

extensions/modules/http-client/src/main/java/org/exist/xquery/modules/httpclient/HttpClientFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* holds at most 25 entries and evicts entries that have not been accessed for one hour.
4343
* It is also cleared on JVM shutdown via a registered shutdown hook.</p>
4444
*/
45-
class HttpClientFactory {
45+
public class HttpClientFactory {
4646

4747
private static final Cache<HttpClientOptions, HttpClient> CLIENT_CACHE =
4848
Caffeine.newBuilder()

extensions/modules/http-client/src/main/java/org/exist/xquery/modules/httpclient/HttpClientModule.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,31 +45,46 @@
4545
*/
4646
public class HttpClientModule extends AbstractInternalModule {
4747

48+
/** Namespace URI for the module. */
4849
public static final String NAMESPACE_URI = "http://expath.org/ns/http-client";
50+
/** Default prefix for the module. */
4951
public static final String PREFIX = "http";
52+
/** Release version of the module. */
5053
public static final String RELEASE = "0.9.0-SNAPSHOT";
5154

55+
/** Namespace URI for EXPath error codes. */
5256
public static final String ERROR_NS = "http://expath.org/ns/error";
5357

5458
// EXPath HTTP Client error codes
59+
/** An HTTP error occurred. */
5560
public static final ErrorCodes.ErrorCode HC001 = new ErrorCodes.ErrorCode(
5661
new QName("HC001", ERROR_NS, "err"), "An HTTP error occurred");
62+
/** Error parsing entity content as XML or HTML. */
5763
public static final ErrorCodes.ErrorCode HC002 = new ErrorCodes.ErrorCode(
5864
new QName("HC002", ERROR_NS, "err"), "Error parsing entity content as XML or HTML");
65+
/** Multipart override-media-type violation. */
5966
public static final ErrorCodes.ErrorCode HC003 = new ErrorCodes.ErrorCode(
6067
new QName("HC003", ERROR_NS, "err"), "Multipart override-media-type violation");
68+
/** src attribute conflicts with body content. */
6169
public static final ErrorCodes.ErrorCode HC004 = new ErrorCodes.ErrorCode(
6270
new QName("HC004", ERROR_NS, "err"), "src attribute conflicts with body content");
71+
/** Invalid request element structure. */
6372
public static final ErrorCodes.ErrorCode HC005 = new ErrorCodes.ErrorCode(
6473
new QName("HC005", ERROR_NS, "err"), "Invalid request element structure");
74+
/** Timeout waiting for response. */
6575
public static final ErrorCodes.ErrorCode HC006 = new ErrorCodes.ErrorCode(
6676
new QName("HC006", ERROR_NS, "err"), "Timeout waiting for response");
6777

78+
/** The functions defined in this module. */
6879
public static final FunctionDef[] functions = functionDefs(
6980
functionDefs(SendRequestFunction.class,
7081
SendRequestFunction.FS_SEND_REQUEST)
7182
);
7283

84+
/**
85+
* Creates a new module instance.
86+
* @param parameters the module parameters
87+
*/
7388
public HttpClientModule(final Map<String, List<?>> parameters) {
7489
super(functions, parameters);
7590
}

extensions/modules/http-client/src/main/java/org/exist/xquery/modules/httpclient/RequestBuilder.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
*/
6565
public class RequestBuilder {
6666

67+
6768
private static final String HTTP_NS = HttpClientModule.NAMESPACE_URI;
6869

6970
private String method;
@@ -160,6 +161,9 @@ private void validate() throws XPathException {
160161
/**
161162
* Builds the {@link java.net.http.HttpRequest} from the parsed parameters, sending credentials
162163
* preemptively only when {@code @send-authorization} is true.
164+
*
165+
* @return the built HttpRequest
166+
* @throws XPathException if the URI is invalid
163167
*/
164168
public HttpRequest build() throws XPathException {
165169
return build(null);
@@ -171,6 +175,8 @@ public HttpRequest build() throws XPathException {
171175
* @param authorizationHeader when non-null, attach this exact {@code Authorization} header
172176
* value — used to answer a 401 challenge with a Basic or Digest response computed by
173177
* {@link #challengeResponse(String)} (see {@link #shouldAttemptChallenge()}).
178+
* @return the built HttpRequest
179+
* @throws XPathException if the URI is invalid
174180
*/
175181
public HttpRequest build(final String authorizationHeader) throws XPathException {
176182
final URI uri;
@@ -413,6 +419,10 @@ private static String md5(final String s) {
413419
}
414420
}
415421

422+
/**
423+
* Returns the parsed request options.
424+
* @return the request options
425+
*/
416426
public RequestOptions getOptions() {
417427
return allOptions;
418428
}

extensions/modules/http-client/src/main/java/org/exist/xquery/modules/httpclient/ResponseHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public class ResponseHandler {
8585
* @param statusOnly if true, return only the response element (no body)
8686
* @param overrideMedia if non-null, use this media type instead of the response Content-Type
8787
* @return the result sequence
88+
* @throws XPathException if an error occurs during result building
8889
*/
8990
public static Sequence buildResult(final HttpResponse<byte[]> response,
9091
final XQueryContext context,

extensions/modules/http-client/src/main/java/org/exist/xquery/modules/httpclient/SendRequestFunction.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public class SendRequestFunction extends BasicFunction {
5454
"The response is a sequence where the first item is an http:response element " +
5555
"with status, message, and header information, followed by the response body content.";
5656

57+
/** The function signature for http:send-request. */
5758
public static final FunctionSignature[] FS_SEND_REQUEST = functionSignatures(
5859
HttpClientModule.qname(FS_SEND_REQUEST_NAME),
5960
FS_SEND_REQUEST_DESCRIPTION,
@@ -75,6 +76,12 @@ public class SendRequestFunction extends BasicFunction {
7576
)
7677
);
7778

79+
/**
80+
* Creates a new function instance.
81+
*
82+
* @param context the XQuery context
83+
* @param signature the function signature
84+
*/
7885
public SendRequestFunction(final XQueryContext context, final FunctionSignature signature) {
7986
super(context, signature);
8087
}

extensions/modules/http-client/src/main/java/org/exist/xquery/modules/httpclient/config/HttpClientOptions.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,20 @@
2828
*
2929
* <p>All fields correspond directly to attributes on the {@code http:request} element
3030
* as defined by the EXPath HTTP Client specification.</p>
31+
*
32+
* @param followRedirect whether to follow HTTP redirects
33+
* @param timeout connection timeout in seconds
34+
* @param httpVersion the HTTP version to use
35+
* @param autoAcceptEncoding whether to automatically add the {@code Accept-Encoding} header
3136
*/
3237
public record HttpClientOptions(
3338
boolean followRedirect,
3439
int timeout,
3540
HttpClient.Version httpVersion,
3641
boolean autoAcceptEncoding
3742
) {
38-
/** Default options: follow redirects, no timeout, HTTP/1.1, auto-accept encoding. */
43+
/**
44+
* Default options: follow redirects, no timeout, HTTP/1.1, auto-accept encoding.
45+
*/
3946
public static final HttpClientOptions DEFAULTS = new HttpClientOptions(true, 0, HttpClient.Version.HTTP_1_1, true);
4047
}

extensions/modules/http-client/src/main/java/org/exist/xquery/modules/httpclient/config/RequestOptions.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
/**
2727
* Combines the parsed {@link HttpClientOptions}, {@link ResponseOptions}, and {@link UserCredentials}
2828
* returned by {@link RequestOptionsParser#parse(org.w3c.dom.Element)}.
29+
*
30+
* @param requestOptions the parsed HTTP client options
31+
* @param responseOptions the parsed response handling options
32+
* @param userCredentials the parsed user credentials for authentication
2933
*/
3034
public record RequestOptions(
3135
HttpClientOptions requestOptions,

extensions/modules/http-client/src/main/java/org/exist/xquery/modules/httpclient/config/ResponseOptions.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,16 @@
2626
*
2727
* <p>These fields control how the HTTP response is interpreted and returned,
2828
* as defined by the EXPath HTTP Client specification.</p>
29+
*
30+
* @param statusOnly whether to return only the status code and headers, omitting the body
31+
* @param overrideMediaType an optional media type to use when parsing the response body
2932
*/
3033
public record ResponseOptions(
3134
boolean statusOnly,
3235
String overrideMediaType
3336
) {
34-
/** Default response options: return full body, no media-type override. */
37+
/**
38+
* Default response options: return full body, no media-type override.
39+
*/
3540
public static final ResponseOptions DEFAULTS = new ResponseOptions(false, null);
3641
}

extensions/modules/http-client/src/main/java/org/exist/xquery/modules/httpclient/config/UserCredentials.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,20 @@
2727
* <p>Holds the authentication-related attributes ({@code username}, {@code password},
2828
* {@code auth-method}, {@code send-authorization}) as defined by the EXPath HTTP Client
2929
* specification.</p>
30+
*
31+
* @param username the username for authentication
32+
* @param password the password for authentication
33+
* @param authMethod the authentication method (e.g., "Basic", "Digest")
34+
* @param sendAuthorization whether to send the Authorization header preemptively
3035
*/
3136
public record UserCredentials(
3237
String username, //user
3338
String password, //user
3439
String authMethod, // user
3540
boolean sendAuthorization //
3641
) {
37-
/** Default credentials: no authentication. */
42+
/**
43+
* Default credentials: no authentication.
44+
*/
3845
public static final UserCredentials DEFAULTS = new UserCredentials(null, null, null, false);
3946
}

0 commit comments

Comments
 (0)