009271e594cc51bcd6f47d357386465faa739621
1 package be
.nikiroo
.fanfix
.reader
;
3 import java
.io
.IOException
;
6 import be
.nikiroo
.fanfix
.Instance
;
7 import be
.nikiroo
.fanfix
.Library
;
8 import be
.nikiroo
.fanfix
.data
.Story
;
9 import be
.nikiroo
.fanfix
.supported
.BasicSupport
;
10 import be
.nikiroo
.fanfix
.supported
.BasicSupport
.SupportType
;
13 * Command line {@link Story} reader.
15 * Will output stories to the console.
19 public abstract class FanfixReader
{
23 * Return the current {@link Story}.
25 * @return the {@link Story}
27 public Story
getStory() {
32 * Create a new {@link FanfixReader} for a {@link Story} in the
36 * the {@link Story} ID
38 * in case of I/O error
40 public void setStory(String luid
) throws IOException
{
41 story
= Instance
.getLibrary().getStory(luid
);
43 throw new IOException("Cannot retrieve story from library: " + luid
);
48 * Create a new {@link FanfixReader} for an external {@link Story}.
51 * the {@link Story} {@link URL}
53 * in case of I/O error
55 public void setStory(URL source
) throws IOException
{
56 BasicSupport support
= BasicSupport
.getSupport(source
);
57 if (support
== null) {
58 throw new IOException("URL not supported: " + source
.toString());
61 story
= support
.process(source
);
63 throw new IOException(
64 "Cannot retrieve story from external source: "
71 * Start the {@link Story} Reading.
74 * in case of I/O error or if the {@link Story} was not
77 public abstract void read() throws IOException
;
80 * Read the selected chapter (starting at 1).
85 public abstract void read(int chapter
);
88 * Start the reader in browse mode for the given type (or pass NULL for all
92 * the type of {@link Story} to take into account, or NULL for
95 public abstract void start(SupportType type
);