// We will let it fail later
}
}
+
+ /**
+ * Check if the {@link Story} denoted by this Library UID is present in the
+ * cache (if we have no cache, we default to </t>true</tt>).
+ *
+ * @param luid
+ * the Library UID
+ *
+ * @return TRUE if it is
+ */
+ public boolean isCached(String luid) {
+ // By default, everything is cached
+ return true;
+ }
+
+ /**
+ * Clear the {@link Story} from the cache, if needed.
+ * <p>
+ * The next time we try to retrieve the {@link Story}, it may be required to
+ * cache it again.
+ *
+ * @param luid
+ * the story to clear
+ *
+ * @throws IOException
+ * in case of I/O error
+ */
+ public void clearFromCache(String luid) throws IOException {
+ // By default, this is a noop.
+ }
/**
* List all the known types (sources) of stories.
* @throws IOException in case of IOException
*
* @deprecated use {@link BasicLibrary#getList(Progress)} and
- * {@link MetaResultList#filter(List, List, List)}
+ * {@link MetaResultList#filter(String, String, String)}
*/
@Deprecated
public synchronized List<MetaData> getListBySource(String source) throws IOException {
- List<String> sources = null;
- if (source != null) {
- sources = new ArrayList<String>();
- sources.add(source);
- }
-
- return getList(null).filter(sources, null, null);
+ return getList(null).filter(source, null, null);
}
/**
* in case of IOException
*
* @deprecated use {@link BasicLibrary#getList(Progress)} and
- * {@link MetaResultList#filter(List, List, List)}
+ * {@link MetaResultList#filter(String, String, String)}
*/
public synchronized List<MetaData> getListByAuthor(String author) throws IOException {
- List<String> authors = null;
- if (author != null) {
- authors = new ArrayList<String>();
- authors.add(author);
- }
-
- return getList(null).filter(null, authors, null);
+ return getList(null).filter(null, author, null);
}
/**
invalidateInfo(luid);
}
- /**
- * Check if the {@link Story} denoted by this Library UID is present in the
- * cache.
- *
- * @param luid
- * the Library UID
- *
- * @return TRUE if it is
- */
+ @Override
public boolean isCached(String luid) {
try {
return cacheLib.getInfo(luid) != null;
}
}
- /**
- * Clear the {@link Story} from the cache.
- * <p>
- * The next time we try to retrieve the {@link Story}, it may be required to
- * cache it again.
- *
- * @param luid
- * the story to clear
- *
- * @throws IOException
- * in case of I/O error
- */
+ @Override
public void clearFromCache(String luid) throws IOException {
if (isCached(luid)) {
cacheLib.delete(luid);
package be.nikiroo.fanfix.library;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
return authors;
}
+ // helper
+ public List<MetaData> filter(String source, String author, String tag) {
+ List<String> sources = source == null ? null : Arrays.asList(source);
+ List<String> authors = author == null ? null : Arrays.asList(author);
+ List<String> tags = tag == null ? null : Arrays.asList(tag);
+
+ return filter(sources, authors, tags);
+ }
+
// null or empty -> no check, rest = must be included
// source: a source ending in "/" means "this or any source starting with this",
// i;e., to enable source hierarchy