support = BasicSupport.getSupport(getType(), null);
}
+ /**
+ * Find the given tag by its hierarchical IDs.
+ * <p>
+ * 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<SearchableTag> 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.
*
*/
abstract public int searchPages(String search) throws IOException;
+ /**
+ * Search for the given tag and return the number of pages of results of
+ * stories satisfying this tag.
+ *
+ * @param tag
+ * the tag to search for
+ *
+ * @return a number of pages
+ *
+ * @throws IOException
+ * in case of I/O error
+ */
+ abstract public int searchPages(SearchableTag tag) throws IOException;
+
/**
* Search for the given term and return a list of stories satisfying this
* search term.
* type, or NULL if it does not exist.
*
* @param type
- * the type, must not be NULL
+ * the type, can be NULL (will just return NULL, since we do not
+ * support it)
*
* @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) {
- case FIMFICTION:
- // TODO
- break;
- case FANFICTION:
- support = new Fanfiction(type);
- break;
- case MANGAFOX:
- // TODO
- break;
- case E621:
- // TODO
- break;
- case YIFFSTAR:
- // TODO
- break;
- case E_HENTAI:
- // TODO
- break;
- case MANGA_LEL:
- support = new MangaLel();
- break;
- case CBZ:
- case HTML:
- case INFO_TEXT:
- case TEXT:
- case EPUB:
- break;
+ if (type != null) {
+ switch (type) {
+ case FIMFICTION:
+ // TODO
+ break;
+ case FANFICTION:
+ support = new Fanfiction(type);
+ break;
+ case MANGAFOX:
+ // TODO
+ break;
+ case E621:
+ // TODO
+ break;
+ case YIFFSTAR:
+ // TODO
+ break;
+ case E_HENTAI:
+ // TODO
+ break;
+ case MANGA_LEL:
+ support = new MangaLel();
+ break;
+ case CBZ:
+ case HTML:
+ case INFO_TEXT:
+ case TEXT:
+ case EPUB:
+ break;
+ }
}
return support;