X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2FReader.java;h=f98f12c53f0c21b811341bc79703799bbc646080;hb=16a81ef7656c5c692fb831927e75edde25dd77a0;hp=09d45c15f3943ccffac23a7d774e71a351996765;hpb=6322ab64949f9f4ae2b04b9504d58a301039d670;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/reader/Reader.java b/src/be/nikiroo/fanfix/reader/Reader.java index 09d45c1..f98f12c 100644 --- a/src/be/nikiroo/fanfix/reader/Reader.java +++ b/src/be/nikiroo/fanfix/reader/Reader.java @@ -3,11 +3,17 @@ package be.nikiroo.fanfix.reader; import java.io.IOException; import java.net.URL; +import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.fanfix.data.Story; import be.nikiroo.fanfix.library.BasicLibrary; -import be.nikiroo.fanfix.library.LocalLibrary; import be.nikiroo.utils.Progress; +/** + * A {@link Reader} is a class that will handle {@link Story} reading and + * browsing. + * + * @author niki + */ public interface Reader { /** * A type of {@link BasicReader}. @@ -34,54 +40,75 @@ public interface Reader { String pkg = "be.nikiroo.fanfix.reader."; switch (this) { case CLI: - return pkg + "CliReader"; + return pkg + "cli.CliReader"; case TUI: - return pkg + "TuiReader"; + return pkg + "tui.TuiReader"; case GUI: - return pkg + "GuiReader"; + return pkg + "ui.GuiReader"; } return null; } - }; + } /** - * Return the current {@link Story}. + * Return the current target {@link MetaData}. + * + * @return the meta + */ + public MetaData getMeta(); + + /** + * Return the current {@link Story} as described by the current + * {@link MetaData}. + * + * @param pg + * the optional progress * * @return the {@link Story} */ - public Story getStory(); + public Story getStory(Progress pg); /** - * The {@link LocalLibrary} to load the stories from (by default, takes the - * default {@link LocalLibrary}). + * The {@link BasicLibrary} to load the stories from (by default, takes the + * default {@link BasicLibrary}). * - * @return the {@link LocalLibrary} + * @return the {@link BasicLibrary} */ public BasicLibrary getLibrary(); /** - * Change the {@link LocalLibrary} that will be managed by this + * Change the {@link BasicLibrary} that will be managed by this * {@link BasicReader}. * * @param lib - * the new {@link LocalLibrary} + * the new {@link BasicLibrary} */ - public void setLibrary(LocalLibrary lib); + public void setLibrary(BasicLibrary lib); /** - * Set a {@link Story} from the current {@link Library} into the + * Set a {@link Story} from the current {@link BasicLibrary} into the * {@link Reader}. * * @param luid * the {@link Story} ID - * @param pg - * the optional progress reporter * * @throws IOException * in case of I/O error */ - public void setStory(String luid, Progress pg) throws IOException; + public void setMeta(String luid) throws IOException; + + /** + * Set a {@link Story} from the current {@link BasicLibrary} into the + * {@link Reader}. + * + * @param meta + * the meta + * + * @throws IOException + * in case of I/O error + */ + public void setMeta(MetaData meta) throws IOException; /** * Set an external {@link Story} into this {@link Reader}. @@ -94,7 +121,7 @@ public interface Reader { * @throws IOException * in case of I/O error */ - public void setStory(URL source, Progress pg) throws IOException; + public void setMeta(URL source, Progress pg) throws IOException; /** * Start the {@link Story} Reading. @@ -106,16 +133,21 @@ public interface Reader { public void read() throws IOException; /** - * Read the selected chapter (starting at 1, 0 = description, -1 = none). + * The selected chapter to start reading at (starting at 1, 0 = description, + * -1 = none). + * + * @return the chapter, or -1 for "no chapter" + */ + public int getChapter(); + + /** + * The selected chapter to start reading at (starting at 1, 0 = description, + * -1 = none). * * @param chapter * the chapter, or -1 for "no chapter" - * - * @throws IOException - * in case of I/O error or if the {@link Story} was not - * previously set */ - public void read(int chapter) throws IOException; + public void setChapter(int chapter); /** * Start the reader in browse mode for the given source (or pass NULL for @@ -126,4 +158,18 @@ public interface Reader { * all */ public void browse(String source); + + /** + * Open the {@link Story} with an external reader (the program will be + * passed the main file associated with this {@link Story}). + * + * @param lib + * the {@link BasicLibrary} to select the {@link Story} from + * @param luid + * the {@link Story} LUID + * + * @throws IOException + * in case of I/O error + */ + public void openExternal(BasicLibrary lib, String luid) throws IOException; }