search should now be OK (CLI, Fanfiction only)
[fanfix.git] / src / be / nikiroo / fanfix / searchable / BasicSearchable.java
index 25c388a8e268aa1bde8a26f84c4d10a2721be070..1e5e9da67298e37874600f449700db154f0b1786 100644 (file)
@@ -83,7 +83,21 @@ public abstract class BasicSearchable {
         * @throws IOException
         *             in case of I/O error
         */
-       abstract protected void fillTag(SearchableTag tag) throws IOException;
+       abstract public void fillTag(SearchableTag tag) throws IOException;
+
+       /**
+        * Search for the given term and return the number of pages of results of
+        * stories satisfying this search term.
+        * 
+        * @param search
+        *            the term to search for
+        * 
+        * @return a number of pages
+        * 
+        * @throws IOException
+        *             in case of I/O error
+        */
+       abstract public int searchPages(String search) throws IOException;
 
        /**
         * Search for the given term and return a list of stories satisfying this
@@ -96,13 +110,16 @@ public abstract class BasicSearchable {
         * 
         * @param search
         *            the term to search for
+        * @param page
+        *            the page to use for result pagination, index is 1-based
         * 
         * @return a list of stories that satisfy that search term
         * 
         * @throws IOException
         *             in case of I/O error
         */
-       abstract public List<MetaData> search(String search) throws IOException;
+       abstract public List<MetaData> search(String search, int page)
+                       throws IOException;
 
        /**
         * Search for the given tag and return a list of stories satisfying this
@@ -113,28 +130,36 @@ public abstract class BasicSearchable {
         * <p>
         * URL is guaranteed to be usable, LUID will always be NULL.
         * 
-        * @param tagId
+        * @param tag
         *            the tag to search for
+        * @param page
+        *            the page to use for result pagination (see
+        *            {@link SearchableTag#getPages()}, remember to check for -1),
+        *            index is 1-based
         * 
         * @return a list of stories that satisfy that search term
         * 
         * @throws IOException
         *             in case of I/O error
         */
-       abstract public List<MetaData> search(SearchableTag tag) throws IOException;
+       abstract public List<MetaData> search(SearchableTag tag, int page)
+                       throws IOException;
 
        /**
         * Load a document from its url.
         * 
         * @param url
         *            the URL to load
+        * @param stable
+        *            TRUE for more stable resources, FALSE when they often change
+        * 
         * @return the document
         * 
         * @throws IOException
         *             in case of I/O error
         */
-       protected Document load(String url) throws IOException {
-               return load(new URL(url));
+       protected Document load(String url, boolean stable) throws IOException {
+               return load(new URL(url), stable);
        }
 
        /**
@@ -142,13 +167,16 @@ public abstract class BasicSearchable {
         * 
         * @param url
         *            the URL to load
+        * @param stable
+        *            TRUE for more stable resources, FALSE when they often change
+        * 
         * @return the document
         * 
         * @throws IOException
         *             in case of I/O error
         */
-       protected Document load(URL url) throws IOException {
-               return DataUtil.load(Instance.getCache().open(url, support, false),
+       protected Document load(URL url, boolean stable) throws IOException {
+               return DataUtil.load(Instance.getCache().open(url, support, stable),
                                "UTF-8", url.toString());
        }