1 package be
.nikiroo
.fanfix
.reader
;
3 import java
.io
.IOException
;
6 import be
.nikiroo
.fanfix
.data
.MetaData
;
7 import be
.nikiroo
.fanfix
.data
.Story
;
8 import be
.nikiroo
.fanfix
.library
.BasicLibrary
;
9 import be
.nikiroo
.fanfix
.supported
.SupportType
;
10 import be
.nikiroo
.utils
.Progress
;
13 * A {@link Reader} is a class that will handle {@link Story} reading and
18 public interface Reader
{
20 * A type of {@link BasicReader}.
24 public enum ReaderType
{
25 /** Simple reader that outputs everything on the console */
27 /** Reader that starts local programs to handle the stories */
29 /** A text (UTF-8) reader with menu and text windows */
31 /** A GUI reader implemented with the Android framework */
37 * Return the full class name of a type that implements said
40 * @return the class name
42 public String
getTypeName() {
43 String pkg
= "be.nikiroo.fanfix.reader.";
46 return pkg
+ "cli.CliReader";
48 return pkg
+ "tui.TuiReader";
50 return pkg
+ "ui.GuiReader";
52 return pkg
+ "android.AndroidReader";
60 * Return the current target {@link MetaData}.
64 public MetaData
getMeta();
67 * Return the current {@link Story} as described by the current
71 * the optional progress
73 * @return the {@link Story}
76 * in case of I/O error
79 public Story
getStory(Progress pg
) throws IOException
;
82 * The {@link BasicLibrary} to load the stories from (by default, takes the
83 * default {@link BasicLibrary}).
85 * @return the {@link BasicLibrary}
87 public BasicLibrary
getLibrary();
90 * Change the {@link BasicLibrary} that will be managed by this
91 * {@link BasicReader}.
94 * the new {@link BasicLibrary}
96 public void setLibrary(BasicLibrary lib
);
99 * Set a {@link Story} from the current {@link BasicLibrary} into the
103 * the {@link Story} ID
105 * @throws IOException
106 * in case of I/O error
108 public void setMeta(String luid
) throws IOException
;
111 * Set a {@link Story} from the current {@link BasicLibrary} into the
117 * @throws IOException
118 * in case of I/O error
120 public void setMeta(MetaData meta
) throws IOException
;
123 * Set an external {@link Story} into this {@link Reader}.
126 * the {@link Story} {@link URL}
128 * the optional progress reporter
130 * @throws IOException
131 * in case of I/O error
133 public void setMeta(URL source
, Progress pg
) throws IOException
;
136 * Start the {@link Story} Reading.
139 * execute the process synchronously (wait until it is terminated
142 * @throws IOException
143 * in case of I/O error or if the {@link Story} was not
146 public void read(boolean sync
) throws IOException
;
149 * The selected chapter to start reading at (starting at 1, 0 = description,
152 * @return the chapter, or -1 for "no chapter"
154 public int getChapter();
157 * The selected chapter to start reading at (starting at 1, 0 = description,
161 * the chapter, or -1 for "no chapter"
163 public void setChapter(int chapter
);
166 * Start the reader in browse mode for the given source (or pass NULL for
169 * Note that this must be a <b>synchronous</b> action.
172 * the type of {@link Story} to take into account, or NULL for
175 * @throws IOException
176 * in case of I/O error
178 public void browse(String source
) throws IOException
;
181 * Display all supports that allow search operations.
184 * execute the process synchronously (wait until it is terminated
187 * @throws IOException
188 * in case of I/O error
190 public void search(boolean sync
) throws IOException
;
193 * Search for the given terms and find stories that correspond if possible.
196 * the website to search on
198 * the words to search for (cannot be NULL)
200 * the page of results to show (0 = request the maximum number of
201 * pages, pages start at 1)
203 * the item to select (0 = do not select a specific item but show
204 * all the page, items start at 1)
206 * execute the process synchronously (wait until it is terminated
209 * @throws IOException
210 * in case of I/O error
212 public void search(SupportType searchOn
, String keywords
, int page
,
213 int item
, boolean sync
) throws IOException
;
216 * Search based upon a hierarchy of tags, or search for (sub)tags.
218 * We use the tags <tt>DisplayName</tt>.
220 * If no tag is given, the main tags will be shown.
222 * If a non-leaf tag is given, the subtags will be shown.
224 * If a leaf tag is given (or a full hierarchy ending with a leaf tag),
225 * stories will be shown.
227 * You can select the story you want with the <tt>item</tt> number.
230 * the website to search on
232 * the page of results to show (0 = request the maximum number of
233 * pages, pages <b>start at 1</b>)
235 * the item to select (0 = do not select a specific item but show
236 * all the page, items <b>start at 1</b>)
238 * execute the process synchronously (wait until it is terminated
241 * the tags indices to search for (this is a tag
242 * <b>hierarchy</b>, <b>NOT</b> a multiple tags choice)
244 * @throws IOException
245 * in case of I/O error
247 public void searchTag(SupportType searchOn
, int page
, int item
,
248 boolean sync
, Integer
... tags
) throws IOException
;
251 * Open the {@link Story} with an external reader (the program should be
252 * passed the main file associated with this {@link Story}).
255 * the {@link BasicLibrary} to select the {@link Story} from
257 * the {@link Story} LUID
259 * execute the process synchronously (wait until it is terminated
262 * @throws IOException
263 * in case of I/O error
265 public void openExternal(BasicLibrary lib
, String luid
, boolean sync
)