22
33import com .github .bottomlessarchive .warc .service .content .domain .WarcContentBlock ;
44import com .github .bottomlessarchive .warc .service .record .domain .WarcRecord ;
5+ import lombok .NonNull ;
6+ import org .jetbrains .annotations .NotNull ;
57
68import java .io .BufferedInputStream ;
79import java .io .IOException ;
@@ -20,15 +22,23 @@ public class WarcRecordIteratorFactory {
2022 private WarcRecordIteratorFactory () {
2123 }
2224
23- public static <T extends WarcContentBlock > Iterator <WarcRecord <T >> iteratorOf (final URI uri ) {
25+ public static <T extends WarcContentBlock > Iterator <WarcRecord <T >> iteratorOf (@ NotNull @ NonNull final String location ) {
26+ try {
27+ return iteratorOf (new URL (location ));
28+ } catch (MalformedURLException e ) {
29+ throw new WarcNetworkException ("Unable to parse WARC location: " + location + "!" , e );
30+ }
31+ }
32+
33+ public static <T extends WarcContentBlock > Iterator <WarcRecord <T >> iteratorOf (@ NotNull @ NonNull final URI uri ) {
2434 try {
2535 return iteratorOf (uri .toURL ());
2636 } catch (MalformedURLException e ) {
2737 throw new WarcNetworkException ("Unable to parse WARC location: " + uri + "!" , e );
2838 }
2939 }
3040
31- public static <T extends WarcContentBlock > Iterator <WarcRecord <T >> iteratorOf (final URL url ) {
41+ public static <T extends WarcContentBlock > Iterator <WarcRecord <T >> iteratorOf (@ NotNull @ NonNull final URL url ) {
3242 try {
3343 return iteratorOf (new AvailableInputStream (new BufferedInputStream (url .openStream (), ONE_MEGABYTE_IN_BYTE )),
3444 WarcReader .DEFAULT_CHARSET , true );
@@ -37,15 +47,17 @@ public static <T extends WarcContentBlock> Iterator<WarcRecord<T>> iteratorOf(fi
3747 }
3848 }
3949
40- public static <T extends WarcContentBlock > Iterator <WarcRecord <T >> iteratorOf (final InputStream inputStream ) {
50+ public static <T extends WarcContentBlock > Iterator <WarcRecord <T >> iteratorOf (@ NotNull @ NonNull final InputStream inputStream ) {
4151 return iteratorOf (inputStream , WarcReader .DEFAULT_CHARSET );
4252 }
4353
44- public static <T extends WarcContentBlock > Iterator <WarcRecord <T >> iteratorOf (final InputStream inputStream , final Charset charset ) {
54+ public static <T extends WarcContentBlock > Iterator <WarcRecord <T >> iteratorOf (@ NotNull @ NonNull final InputStream inputStream ,
55+ @ NotNull @ NonNull final Charset charset ) {
4556 return iteratorOf (new BufferedInputStream (inputStream , ONE_MEGABYTE_IN_BYTE ), charset , true );
4657 }
4758
48- public static <T extends WarcContentBlock > Iterator <WarcRecord <T >> iteratorOf (final InputStream inputStream , final Charset charset ,
59+ public static <T extends WarcContentBlock > Iterator <WarcRecord <T >> iteratorOf (@ NotNull @ NonNull final InputStream inputStream ,
60+ @ NotNull @ NonNull final Charset charset ,
4961 final boolean compressed ) {
5062 final WarcReader warcReader = new WarcReader (inputStream , charset , compressed );
5163
0 commit comments