Adding some documentation

This commit is contained in:
Shinokuni 2019-01-26 22:33:19 +00:00
parent 62f86341cb
commit 9704b2bb5c
2 changed files with 25 additions and 1 deletions

View File

@ -15,6 +15,11 @@ import java.util.List;
public final class PageParser {
/**
* Parse the html page to get the first rss url
* @param url url to request
* @return the first rss url found
*/
public static String getFeedLink(String url) {
String feedUrl = null;
@ -39,11 +44,17 @@ public final class PageParser {
return null;
}
private static boolean isTypeRssFeed(String type) {
return type.equals("application/rss+xml") || type.equals("application/atom+xml") || type.equals("application/json");
}
/**
* get the feed item image based on open graph metadata.
* Warning, This method is slow.
* @param url url to request
* @return the item image
*/
public static String getOGImageLink(String url) {
String imageUrl = null;

View File

@ -42,6 +42,14 @@ public class RSSNetwork {
callback.onSyncFailure(new Exception("Error " + response.code() + " when requesting url " + url));
}
/**
* Parse input feed
* @param stream inputStream to parse
* @param type rss type, important to know the format
* @param callback success callback
* @param url feed url
* @throws Exception
*/
private void parseFeed(InputStream stream, RSSType type, QueryCallback callback, String url) throws Exception {
//String xml = Utils.inputStreamToString(stream);
Serializer serializer = new Persister();
@ -63,6 +71,11 @@ public class RSSNetwork {
}
}
/**
* Get the rss type according to the content-type header
* @param contentType content-type header
* @return rss type according to the content-type header
*/
private RSSType getRSSType(String contentType) {
if (contentType.contains(RSSType.RSS_2.value))
return RSSType.RSS_2;