X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2FBasicReader.java;fp=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2FFanfixReader.java;h=eeb00af1c6ff2f5439af6c4bdfbe9bd8669142e4;hp=009271e594cc51bcd6f47d357386465faa739621;hb=3727aae2b0516c5ed5366cde29544565f1d6c6b0;hpb=89cb07a69f3ee217f9ea6a4284bec0df94ef77fa diff --git a/src/be/nikiroo/fanfix/reader/FanfixReader.java b/src/be/nikiroo/fanfix/reader/BasicReader.java similarity index 57% rename from src/be/nikiroo/fanfix/reader/FanfixReader.java rename to src/be/nikiroo/fanfix/reader/BasicReader.java index 009271e..eeb00af 100644 --- a/src/be/nikiroo/fanfix/reader/FanfixReader.java +++ b/src/be/nikiroo/fanfix/reader/BasicReader.java @@ -16,8 +16,41 @@ import be.nikiroo.fanfix.supported.BasicSupport.SupportType; * * @author niki */ -public abstract class FanfixReader { +public abstract class BasicReader { + public enum ReaderType { + /** Simple reader that outputs everything on the console */ + CLI, + /** Reader that starts local programs to handle the stories */ + LOCAL + } + + private static ReaderType defaultType; private Story story; + private ReaderType type; + + static { + // TODO: default type from config + } + + /** + * The type of this reader. + * + * @return the type + */ + public ReaderType getType() { + return type; + } + + /** + * The type of this reader. + * + * @param type + * the new type + */ + protected BasicReader setType(ReaderType type) { + this.type = type; + return this; + } /** * Return the current {@link Story}. @@ -29,7 +62,7 @@ public abstract class FanfixReader { } /** - * Create a new {@link FanfixReader} for a {@link Story} in the + * Create a new {@link BasicReader} for a {@link Story} in the * {@link Library} . * * @param luid @@ -45,7 +78,7 @@ public abstract class FanfixReader { } /** - * Create a new {@link FanfixReader} for an external {@link Story}. + * Create a new {@link BasicReader} for an external {@link Story}. * * @param source * the {@link Story} {@link URL} @@ -93,4 +126,41 @@ public abstract class FanfixReader { * all */ public abstract void start(SupportType type); + + /** + * Return a new {@link BasicReader} ready for use. + * + * @return a {@link BasicReader} + */ + public static BasicReader getReader() { + switch (defaultType) { + // case LOCAL: + // return new LocalReader().setType(ReaderType.LOCAL); + case CLI: + return new CliReader().setType(ReaderType.CLI); + } + + return null; + } + + /** + * The default {@link ReaderType} used when calling + * {@link BasicReader#getReader()}. + * + * @return the default type + */ + public static ReaderType getDefaultReaderType() { + return defaultType; + } + + /** + * The default {@link ReaderType} used when calling + * {@link BasicReader#getReader()}. + * + * @param defaultType + * the new default type + */ + public static void setDefaultReaderType(ReaderType defaultType) { + BasicReader.defaultType = defaultType; + } }