Skip to content

Commit 8aee045

Browse files
committed
#9 - Created private methods for the static factories and fixed a couple other linting problems.
1 parent d389766 commit 8aee045

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

java-warc/src/main/java/com/github/bottomlessarchive/warc/service/AvailableInputStream.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,22 @@ public int read() throws IOException {
1919
return inputStream.read();
2020
}
2121

22+
@Override
2223
public int read(byte[] b) throws IOException {
2324
return inputStream.read(b);
2425
}
2526

27+
@Override
2628
public int read(byte[] b, int off, int len) throws IOException {
2729
return inputStream.read(b, off, len);
2830
}
2931

32+
@Override
3033
public void close() throws IOException {
3134
inputStream.close();
3235
}
3336

37+
@Override
3438
public int available() throws IOException {
3539
// Always say that we have 1 more byte in the
3640
// buffer, even when we don't

java-warc/src/main/java/com/github/bottomlessarchive/warc/service/WarcRecordIteratorFactory.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ public class WarcRecordIteratorFactory {
1717

1818
private static final int ONE_MEGABYTE_IN_BYTE = 1048576;
1919

20+
private WarcRecordIteratorFactory() {
21+
}
22+
2023
public static <T extends WarcContentBlock> Iterator<WarcRecord<T>> iteratorOf(final URI uri) {
2124
try {
2225
return iteratorOf(uri.toURL());

java-warc/src/main/java/com/github/bottomlessarchive/warc/service/WarcRecordStreamFactory.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ public class WarcRecordStreamFactory {
2222

2323
private static final List<WarcRecordType> EVERY_WARC_RECORD_TYPE = Arrays.asList(WarcRecordType.values());
2424

25+
private WarcRecordStreamFactory() {
26+
}
27+
2528
public static <T extends WarcContentBlock> Stream<WarcRecord<T>> streamOf(@NotNull @NonNull final URI uri) {
2629
try {
2730
return WarcRecordStreamFactory.streamOf(uri.toURL(), EVERY_WARC_RECORD_TYPE);

java-warc/src/main/java/com/github/bottomlessarchive/warc/service/content/response/domain/ResponseContentBlock.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ public Optional<Charset> getCharset() {
8484
* @return the payload of the content block as string
8585
*/
8686
public String getPayloadAsString() {
87-
final Charset charset = this.charset != null ? this.charset : WarcReader.DEFAULT_CHARSET;
87+
final Charset payloadCharset = this.charset != null ? this.charset : WarcReader.DEFAULT_CHARSET;
8888

8989
try {
90-
return IOUtils.toString(payload, charset);
90+
return IOUtils.toString(payload, payloadCharset);
9191
} catch (IOException e) {
9292
throw new WarcParsingException("Unable to parse the payload of a WARC document!", e);
9393
}

java-warc/src/main/java/com/github/bottomlessarchive/warc/service/http/HttpParser.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@
55
import java.io.InputStream;
66
import java.nio.charset.Charset;
77
import java.util.ArrayList;
8+
89
import org.apache.http.Header;
910
import org.apache.http.HttpException;
1011
import org.apache.http.ProtocolException;
1112
import org.apache.http.message.BasicHeader;
1213

1314
public class HttpParser {
1415

16+
private HttpParser() {
17+
}
18+
1519
/**
1620
* Read up to "\n" from an (unchunked) input stream. If the stream ends before the line terminator
1721
* is found, the last part of the string will still be returned. If no input data available,
@@ -80,10 +84,10 @@ public static byte[] readRawLine(InputStream inputStream) throws IOException {
8084
* @throws HttpException if there is an error parsing a header value
8185
*/
8286
public static Header[] parseHeaders(InputStream is, Charset charset)
83-
throws IOException, HttpException {
87+
throws IOException, HttpException {
8488
ArrayList<Header> headers = new ArrayList<>();
8589
String name = null;
86-
StringBuffer value = null;
90+
StringBuilder value = null;
8791
for (; ; ) {
8892
String line = readLine(is, charset);
8993
if ((line == null) || (line.trim().length() < 1)) {
@@ -114,7 +118,7 @@ public static Header[] parseHeaders(InputStream is, Charset charset)
114118
throw new ProtocolException("Unable to parse header: " + line);
115119
}
116120
name = line.substring(0, colon).trim();
117-
value = new StringBuffer(line.substring(colon + 1).trim());
121+
value = new StringBuilder(line.substring(colon + 1).trim());
118122
}
119123

120124
}

0 commit comments

Comments
 (0)