X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsearchable%2FBasicSearchable.java;h=d8076fa7a1b87f99e452cddcef30100305884c7b;hb=e92e4ae338d932e6b65e855b4b710e14b5ace1b7;hp=979bf5ecee225e2656afb8b862adb3c98b7e307f;hpb=8ffc8b73e96e80657545f7d713cd065cf7ede786;p=nikiroo-utils.git
diff --git a/src/be/nikiroo/fanfix/searchable/BasicSearchable.java b/src/be/nikiroo/fanfix/searchable/BasicSearchable.java
index 979bf5e..d8076fa 100644
--- a/src/be/nikiroo/fanfix/searchable/BasicSearchable.java
+++ b/src/be/nikiroo/fanfix/searchable/BasicSearchable.java
@@ -34,6 +34,38 @@ public abstract class BasicSearchable {
support = BasicSupport.getSupport(getType(), null);
}
+ /**
+ * Find the given tag by its hierarchical IDs.
+ *
+ * I.E., it will take the tag A, subtag B, subsubtag C...
+ *
+ * @param ids
+ * the IDs to look for
+ *
+ * @return the appropriate tag fully filled, or NULL if not found
+ *
+ * @throws IOException
+ * in case of I/O error
+ */
+ public SearchableTag getTag(Integer... ids) throws IOException {
+ SearchableTag tag = null;
+ List tags = getTags();
+
+ for (Integer tagIndex : ids) {
+ // ! 1-based index !
+ if (tagIndex == null || tags == null || tagIndex <= 0
+ || tagIndex > tags.size()) {
+ return null;
+ }
+
+ tag = tags.get(tagIndex - 1);
+ fillTag(tag);
+ tags = tag.getChildren();
+ }
+
+ return tag;
+ }
+
/**
* The support type.
*
@@ -85,6 +117,20 @@ public abstract class BasicSearchable {
*/
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
* search term.
@@ -175,7 +221,7 @@ public abstract class BasicSearchable {
*
* @return an implementation that supports it, or NULL
*/
- public static BasicSearchable getSearchable(SupportType type) {
+ static public BasicSearchable getSearchable(SupportType type) {
BasicSearchable support = null;
switch (type) {
@@ -198,7 +244,7 @@ public abstract class BasicSearchable {
// TODO
break;
case MANGA_LEL:
- // TODO
+ support = new MangaLel();
break;
case CBZ:
case HTML: