59ed024f42380a8a50f2b3e5fa199146d9092459
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}
75 public Story
getStory(Progress pg
);
78 * The {@link BasicLibrary} to load the stories from (by default, takes the
79 * default {@link BasicLibrary}).
81 * @return the {@link BasicLibrary}
83 public BasicLibrary
getLibrary();
86 * Change the {@link BasicLibrary} that will be managed by this
87 * {@link BasicReader}.
90 * the new {@link BasicLibrary}
92 public void setLibrary(BasicLibrary lib
);
95 * Set a {@link Story} from the current {@link BasicLibrary} into the
99 * the {@link Story} ID
101 * @throws IOException
102 * in case of I/O error
104 public void setMeta(String luid
) throws IOException
;
107 * Set a {@link Story} from the current {@link BasicLibrary} into the
113 * @throws IOException
114 * in case of I/O error
116 public void setMeta(MetaData meta
) throws IOException
;
119 * Set an external {@link Story} into this {@link Reader}.
122 * the {@link Story} {@link URL}
124 * the optional progress reporter
126 * @throws IOException
127 * in case of I/O error
129 public void setMeta(URL source
, Progress pg
) throws IOException
;
132 * Start the {@link Story} Reading.
135 * execute the process synchronously (wait until it is terminated
138 * @throws IOException
139 * in case of I/O error or if the {@link Story} was not
142 public void read(boolean sync
) throws IOException
;
145 * The selected chapter to start reading at (starting at 1, 0 = description,
148 * @return the chapter, or -1 for "no chapter"
150 public int getChapter();
153 * The selected chapter to start reading at (starting at 1, 0 = description,
157 * the chapter, or -1 for "no chapter"
159 public void setChapter(int chapter
);
162 * Start the reader in browse mode for the given source (or pass NULL for
165 * Note that this must be a <b>synchronous</b> action.
168 * the type of {@link Story} to take into account, or NULL for
171 public void browse(String source
);
174 * Search for the given terms and find stories that correspond if possible.
177 * the website to search on
179 * the words to search for (cannot be NULL)
181 * the page of results to show (0 = request the maximum number of
182 * pages, pages start at 1)
184 * the item to select (0 = do not select a specific item but show
185 * all the page, items start at 1)
187 * @throws IOException
188 * in case of I/O error
190 public void search(SupportType searchOn
, String keywords
, int page
, int item
)
194 * Search based upon a hierarchy of tags, or search for (sub)tags.
196 * We use the tags <tt>DisplayName</tt>.
198 * If no tag is given, the main tags will be shown.
200 * If a non-leaf tag is given, the subtags will be shown.
202 * If a leaf tag is given (or a full hierarchy ending with a leaf tag),
203 * stories will be shown.
205 * You can select the story you want with the <tt>item</tt> number.
208 * the website to search on
210 * the page of results to show (0 = request the maximum number of
211 * pages, pages start at 1)
213 * the item to select (0 = do not select a specific item but show
214 * all the page, items start at 1)
216 * the tags display names to search for (this is a tag
217 * <b>hierarchy</b>, <b>NOT</b> a multiple tags choice)
219 * @throws IOException
220 * in case of I/O error
222 public void searchTag(SupportType searchOn
, int page
, int item
,
223 String
... tags
) throws IOException
;
226 * Open the {@link Story} with an external reader (the program should be
227 * passed the main file associated with this {@link Story}).
230 * the {@link BasicLibrary} to select the {@link Story} from
232 * the {@link Story} LUID
234 * execute the process synchronously (wait until it is terminated
237 * @throws IOException
238 * in case of I/O error
240 public void openExternal(BasicLibrary lib
, String luid
, boolean sync
)