Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.

Commit 7ed38e6

Browse files
SynapticloopSynapticloop
Synapticloop
authored and
Synapticloop
committed
fixed javadoc
1 parent a024a9c commit 7ed38e6

File tree

3 files changed

+75
-14
lines changed

3 files changed

+75
-14
lines changed

src/main/java/synapticloop/b2/request/B2DownloadFileByIdRequest.java

+11-7
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525

2626
/**
2727
* <p>Downloads one file from B2.</p>
28-
* <p>
28+
*
2929
* <p>The response contains the following headers, which contain the same information they did when the file was uploaded:</p>
30-
* <p>
30+
*
3131
* <ul>
3232
* <li>Content-Length</li>
3333
* <li>Content-Type</li>
@@ -36,18 +36,18 @@
3636
* <li>X-Bz-Content-Sha1</li>
3737
* <li>X-Bz-Info-*</li>
3838
* </ul>
39-
* <p>
39+
*
4040
* <p>HEAD requests are also supported, and work just like a GET, except that the
4141
* body of the response is not included. All of the same headers, including
4242
* Content-Length are returned. See the B2HeadFileByIdRequest</p>
43-
* <p>
43+
*
4444
* <p>If the bucket containing the file is set to require authorization, then you
4545
* must supply the bucket's auth token in the Authorzation header.</p>
46-
* <p>
46+
*
4747
* <p>Because errors can happen in network transmission, you should check the
4848
* SHA1 of the data you receive against the SHA1 returned in the
4949
* X-Bz-Content-Sha1 header.</p>
50-
* <p>
50+
*
5151
* This is the interaction class for the <strong>b2_download_file_by_id</strong> api calls, this was
5252
* generated from the backblaze api documentation - which can be found here:
5353
* <a href="http://www.backblaze.com/b2/docs/b2_download_file_by_id.html">http://www.backblaze.com/b2/docs/b2_download_file_by_id.html</a>
@@ -69,18 +69,22 @@ public B2DownloadFileByIdRequest(CloseableHttpClient client, B2AuthorizeAccountR
6969
}
7070

7171
/**
72-
* Create a download file by ID request to download the range of bytes
72+
* <p>Create a download file by ID request to download the range of bytes
7373
* between rangeStart and rangeEnd (inclusive)
74+
* </p>
7475
* <p>
7576
* A standard byte-range request, which will return just part of the stored file.
77+
* </p>
7678
* <p>
7779
* The value "bytes=0-99" selects bytes 0 through 99 (inclusive) of the file,
7880
* so it will return the first 100 bytes. Valid byte ranges will cause the
7981
* response to contain a Content-Range header that specifies which bytes are
8082
* returned. Invalid byte ranges will just return the whole file.
83+
* </p>
8184
* <p>
8285
* Note that the SHA1 checksum returned is still the checksum for the entire
8386
* file, so it cannot be used on the byte range.
87+
* </p>
8488
*
8589
* @param client Shared HTTP client instance
8690
* @param b2AuthorizeAccountResponse The authorize account response

src/main/java/synapticloop/b2/request/BaseB2Request.java

+9
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,29 @@ protected BaseB2Request(CloseableHttpClient client, B2AuthorizeAccountResponse b
115115

116116
/**
117117
* Add header to request replacing previous if any
118+
*
119+
* @param key the key to add
120+
* @param value the value to add
118121
*/
119122
protected void addHeader(String key, String value) {
120123
requestHeaders.put(key, value);
121124
}
122125

123126
/**
124127
* Add query parameter to request replacing previous if any
128+
*
129+
* @param key the key to add
130+
* @param value the value to add
125131
*/
126132
protected void addParameter(String key, String value) {
127133
requestParameters.put(key, value);
128134
}
129135

130136
/**
131137
* Add property to JSON request body
138+
*
139+
* @param key the key to add
140+
* @param value the value to add
132141
*/
133142
protected void addProperty(String key, Object value) {
134143
requestBodyData.put(key, value);

src/main/java/synapticloop/b2/response/BaseB2Response.java

+55-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package synapticloop.b2.response;
22

3+
import java.util.Iterator;
4+
35
/*
46
* Copyright (c) 2016 synapticloop.
57
*
@@ -21,9 +23,8 @@
2123
import org.json.JSONObject;
2224
import org.slf4j.Logger;
2325
import org.slf4j.LoggerFactory;
24-
import synapticloop.b2.exception.B2ApiException;
2526

26-
import java.util.Iterator;
27+
import synapticloop.b2.exception.B2ApiException;
2728

2829
public abstract class BaseB2Response {
2930
private static final Logger LOGGER = LoggerFactory.getLogger(BaseB2Response.class);
@@ -69,12 +70,24 @@ private static JSONObject parse(String json) throws B2ApiException {
6970
}
7071

7172
/**
72-
* Read and remove object with key from JSON
73+
* Read and remove String with key from JSON
74+
*
75+
* @param key the key to read as a string and remove
76+
*
77+
* @return the read key (or null if it doesn't exist)
7378
*/
7479
protected String readString(String key) {
7580
return this.readString(response, key);
7681
}
7782

83+
/**
84+
* Read and remove String with key from JSON object
85+
*
86+
* @param response The JSON object to read from
87+
* @param key the key to read as a string and remove
88+
*
89+
* @return the read key (or null if it doesn't exist)
90+
*/
7891
protected String readString(JSONObject response, String key) {
7992
final Object value = response.remove(key);
8093
if (null == value || JSONObject.NULL == value) {
@@ -85,7 +98,11 @@ protected String readString(JSONObject response, String key) {
8598
}
8699

87100
/**
88-
* Read and remove object with key from JSON
101+
* Read and remove int with key from JSON object
102+
*
103+
* @param key the key to read as an int and remove
104+
*
105+
* @return the read key (or -1 if it doesn't exist)
89106
*/
90107
protected int readInt(String key) {
91108
final Object value = response.remove(key);
@@ -97,7 +114,11 @@ protected int readInt(String key) {
97114
}
98115

99116
/**
100-
* Read and remove object with key from JSON
117+
* Read and remove long with key from JSON object
118+
*
119+
* @param key the key to read as a long and remove
120+
*
121+
* @return the read key (or -1L if it doesn't exist)
101122
*/
102123
protected long readLong(String key) {
103124
final Object value = response.remove(key);
@@ -108,10 +129,25 @@ protected long readLong(String key) {
108129
return value instanceof Number ? ((Number) value).longValue() : Long.parseLong(value.toString());
109130
}
110131

132+
/**
133+
* Read and remove JSONObject with key from JSON object
134+
*
135+
* @param key the key to read as a JSONObject and remove
136+
*
137+
* @return the read key (or null if it doesn't exist)
138+
*/
111139
protected JSONObject readObject(String key) {
112140
return this.readObject(response, key);
113141
}
114142

143+
/**
144+
* Read and remove JSONObject with key from JSON object
145+
*
146+
* @param response The JSON object to read from
147+
* @param key the key to read as a JSONObject and remove
148+
*
149+
* @return the read key (or null if it doesn't exist)
150+
*/
115151
protected JSONObject readObject(JSONObject response, String key) {
116152
final Object value = response.remove(key);
117153
if (null == value || JSONObject.NULL == value) {
@@ -122,7 +158,11 @@ protected JSONObject readObject(JSONObject response, String key) {
122158
}
123159

124160
/**
125-
* Read and remove object with key from JSON
161+
* Read and remove JSONArray with key from JSON object
162+
*
163+
* @param key the key to read as a JSONArray and remove
164+
*
165+
* @return the read key (or null if it doesn't exist)
126166
*/
127167
protected JSONArray readObjects(String key) {
128168
final Object value = response.remove(key);
@@ -139,7 +179,15 @@ protected JSONArray readObjects(String key) {
139179
* the response will not be mapped. This will loop through the JSON object
140180
* and any key left in the object will generate a 'WARN' message. The
141181
* response class __MUST__ remove the object (i.e. jsonObject.remove(KEY_NAME))
142-
* after getting the value
182+
* after getting the value, or use the utility methods in this class. This
183+
* is used more as a testing tool/sanity test than anything else as there
184+
* are some instances in where keys are returned, however are not listed in
185+
* the documentation.
186+
*
187+
* {@link BaseB2Response#readInt(String)}
188+
* {@link BaseB2Response#readLong(String)}
189+
* {@link BaseB2Response#readString(String)}
190+
* {@link BaseB2Response#readObject(String)}
143191
*
144192
* @param LOGGER The logger to use
145193
*/

0 commit comments

Comments
 (0)