From: Niki Roo Date: Sat, 8 Jul 2017 04:23:51 +0000 (+0200) Subject: Add more warnings source to 1.6) and fix warnings X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=211f7ddb50f68aa8a999023ef6d63d5756bdace6;p=nikiroo-utils.git Add more warnings source to 1.6) and fix warnings --- diff --git a/src/be/nikiroo/fanfix/Cache.java b/src/be/nikiroo/fanfix/Cache.java index f7e1a81..40ce15e 100644 --- a/src/be/nikiroo/fanfix/Cache.java +++ b/src/be/nikiroo/fanfix/Cache.java @@ -396,16 +396,21 @@ public class Cache { * * @param url * the resource to open + * @param allowTooOld + * allow files even if they are considered too old + * @param stable + * a stable file (that dones't change too often) -- parameter + * used to check if the file is too old to keep or not * * @return the opened resource if found, NULL i not * * @throws IOException * in case of I/O error */ - private InputStream load(URL url, boolean allowOld, boolean stable) + private InputStream load(URL url, boolean allowTooOld, boolean stable) throws IOException { File cached = getCached(url); - if (cached.exists() && !isOld(cached, stable)) { + if (cached.exists() && (allowTooOld || !isOld(cached, stable))) { return new MarkableFileInputStream(new FileInputStream(cached)); } diff --git a/src/be/nikiroo/fanfix/Main.java b/src/be/nikiroo/fanfix/Main.java index adbd5a3..9ac4884 100644 --- a/src/be/nikiroo/fanfix/Main.java +++ b/src/be/nikiroo/fanfix/Main.java @@ -199,6 +199,7 @@ public class Main { mainProgress.addProgressListener(new Progress.ProgressListener() { private int current = mainProgress.getMin(); + @Override public void progress(Progress progress, String name) { int diff = progress.getProgress() - current; current += diff; diff --git a/src/be/nikiroo/fanfix/bundles/StringId.java b/src/be/nikiroo/fanfix/bundles/StringId.java index c49627f..6ccb772 100644 --- a/src/be/nikiroo/fanfix/bundles/StringId.java +++ b/src/be/nikiroo/fanfix/bundles/StringId.java @@ -142,4 +142,4 @@ public enum StringId { writer.write("# Also, the comments always refer to the key below them.\n"); writer.write("# \n"); } -}; +} diff --git a/src/be/nikiroo/fanfix/data/Chapter.java b/src/be/nikiroo/fanfix/data/Chapter.java index d9f285f..86856b0 100644 --- a/src/be/nikiroo/fanfix/data/Chapter.java +++ b/src/be/nikiroo/fanfix/data/Chapter.java @@ -19,6 +19,7 @@ public class Chapter implements Iterable { /** * Empty constructor, not to use. */ + @SuppressWarnings("unused") private Chapter() { // for serialisation purposes } @@ -96,6 +97,7 @@ public class Chapter implements Iterable { /** * Get an iterator on the {@link Paragraph}s. */ + @Override public Iterator iterator() { return paragraphs == null ? empty.iterator() : paragraphs.iterator(); } diff --git a/src/be/nikiroo/fanfix/data/MetaData.java b/src/be/nikiroo/fanfix/data/MetaData.java index 872baff..c969ec9 100644 --- a/src/be/nikiroo/fanfix/data/MetaData.java +++ b/src/be/nikiroo/fanfix/data/MetaData.java @@ -377,6 +377,7 @@ public class MetaData implements Cloneable, Comparable { this.fakeCover = fakeCover; } + @Override public int compareTo(MetaData o) { String oUuid = o == null ? null : o.getUuid(); return getUuid().compareTo(oUuid); diff --git a/src/be/nikiroo/fanfix/data/Paragraph.java b/src/be/nikiroo/fanfix/data/Paragraph.java index 8a9130b..1a7429a 100644 --- a/src/be/nikiroo/fanfix/data/Paragraph.java +++ b/src/be/nikiroo/fanfix/data/Paragraph.java @@ -33,6 +33,7 @@ public class Paragraph { /** * Empty constructor, not to use. */ + @SuppressWarnings("unused") private Paragraph() { // for serialisation purposes } diff --git a/src/be/nikiroo/fanfix/data/Story.java b/src/be/nikiroo/fanfix/data/Story.java index cb65119..7ebfbc5 100644 --- a/src/be/nikiroo/fanfix/data/Story.java +++ b/src/be/nikiroo/fanfix/data/Story.java @@ -55,6 +55,7 @@ public class Story implements Iterable { /** * Get an iterator on the {@link Chapter}s. */ + @Override public Iterator iterator() { return chapters == null ? empty.iterator() : chapters.iterator(); } diff --git a/src/be/nikiroo/fanfix/library/LocalLibrary.java b/src/be/nikiroo/fanfix/library/LocalLibrary.java index e4dc5e9..d7fd521 100644 --- a/src/be/nikiroo/fanfix/library/LocalLibrary.java +++ b/src/be/nikiroo/fanfix/library/LocalLibrary.java @@ -161,9 +161,9 @@ public class LocalLibrary extends BasicLibrary { private OutputType getOutputType(MetaData meta) { if (meta != null && meta.isImageDocument()) { return image; - } else { - return text; } + + return text; } /** @@ -238,39 +238,39 @@ public class LocalLibrary extends BasicLibrary { MetaData meta = getInfo(luid); if (meta == null) { throw new IOException("Story not found: " + luid); - } else { - File infoFile = getStories(null).get(meta)[0]; - File targetFile = getStories(null).get(meta)[1]; + } - files.add(infoFile); - files.add(targetFile); + File infoFile = getStories(null).get(meta)[0]; + File targetFile = getStories(null).get(meta)[1]; - String readerExt = getOutputType(meta).getDefaultExtension(true); - String fileExt = getOutputType(meta).getDefaultExtension(false); + files.add(infoFile); + files.add(targetFile); - String path = targetFile.getAbsolutePath(); - if (readerExt != null && !readerExt.equals(fileExt)) { - path = path.substring(0, path.length() - readerExt.length()) - + fileExt; - File relatedFile = new File(path); + String readerExt = getOutputType(meta).getDefaultExtension(true); + String fileExt = getOutputType(meta).getDefaultExtension(false); - if (relatedFile.exists()) { - files.add(relatedFile); - } - } + String path = targetFile.getAbsolutePath(); + if (readerExt != null && !readerExt.equals(fileExt)) { + path = path.substring(0, path.length() - readerExt.length()) + + fileExt; + File relatedFile = new File(path); - String coverExt = "." - + Instance.getConfig().getString(Config.IMAGE_FORMAT_COVER); - File coverFile = new File(path + coverExt); - if (!coverFile.exists()) { - coverFile = new File(path.substring(0, - path.length() - fileExt.length()) - + coverExt); + if (relatedFile.exists()) { + files.add(relatedFile); } + } - if (coverFile.exists()) { - files.add(coverFile); - } + String coverExt = "." + + Instance.getConfig().getString(Config.IMAGE_FORMAT_COVER); + File coverFile = new File(path + coverExt); + if (!coverFile.exists()) { + coverFile = new File(path.substring(0, + path.length() - fileExt.length()) + + coverExt); + } + + if (coverFile.exists()) { + files.add(coverFile); } return files; @@ -301,6 +301,7 @@ public class LocalLibrary extends BasicLibrary { lastId = 0; File[] dirs = baseDir.listFiles(new FileFilter() { + @Override public boolean accept(File file) { return file != null && file.isDirectory(); } @@ -311,6 +312,7 @@ public class LocalLibrary extends BasicLibrary { for (File dir : dirs) { File[] infoFiles = dir.listFiles(new FileFilter() { + @Override public boolean accept(File file) { return file != null && file.getPath().toLowerCase() diff --git a/src/be/nikiroo/fanfix/library/RemoteLibrary.java b/src/be/nikiroo/fanfix/library/RemoteLibrary.java index 6c1e56f..511d1c1 100644 --- a/src/be/nikiroo/fanfix/library/RemoteLibrary.java +++ b/src/be/nikiroo/fanfix/library/RemoteLibrary.java @@ -57,6 +57,7 @@ public class RemoteLibrary extends BasicLibrary { try { new ConnectActionClient(host, port, true, null) { + @Override public void action(Version serverVersion) throws Exception { try { Object rep = send("GET_METADATA *"); @@ -83,6 +84,7 @@ public class RemoteLibrary extends BasicLibrary { final File[] tmp = new File[1]; try { new ConnectActionClient(host, port, true, null) { + @Override public void action(Version serverVersion) throws Exception { try { Object rep = send("GET_STORY " + luid); diff --git a/src/be/nikiroo/fanfix/output/BasicOutput.java b/src/be/nikiroo/fanfix/output/BasicOutput.java index 909c8fe..4607827 100644 --- a/src/be/nikiroo/fanfix/output/BasicOutput.java +++ b/src/be/nikiroo/fanfix/output/BasicOutput.java @@ -45,6 +45,7 @@ public abstract class BasicOutput { ; + @Override public String toString() { return super.toString().toLowerCase(); } @@ -267,25 +268,32 @@ public abstract class BasicOutput { * * @return the extension */ - public String getDefaultExtension(boolean readerTarget) { + public String getDefaultExtension( + @SuppressWarnings("unused") boolean readerTarget) { return ""; } + @SuppressWarnings("unused") protected void writeStoryHeader(Story story) throws IOException { } + @SuppressWarnings("unused") protected void writeChapterHeader(Chapter chap) throws IOException { } + @SuppressWarnings("unused") protected void writeParagraphHeader(Paragraph para) throws IOException { } + @SuppressWarnings("unused") protected void writeStoryFooter(Story story) throws IOException { } + @SuppressWarnings("unused") protected void writeChapterFooter(Chapter chap) throws IOException { } + @SuppressWarnings("unused") protected void writeParagraphFooter(Paragraph para) throws IOException { } @@ -367,6 +375,7 @@ public abstract class BasicOutput { writeParagraphFooter(para); } + @SuppressWarnings("unused") protected void writeTextLine(ParagraphType type, String line) throws IOException { } diff --git a/src/be/nikiroo/fanfix/output/Html.java b/src/be/nikiroo/fanfix/output/Html.java index dca0fc4..581c949 100644 --- a/src/be/nikiroo/fanfix/output/Html.java +++ b/src/be/nikiroo/fanfix/output/Html.java @@ -64,9 +64,9 @@ class Html extends BasicOutput { public String getDefaultExtension(boolean readerTarget) { if (readerTarget) { return File.separator + "index.html"; - } else { - return ""; } + + return ""; } @Override diff --git a/src/be/nikiroo/fanfix/reader/BasicReader.java b/src/be/nikiroo/fanfix/reader/BasicReader.java index cf83788..a261c04 100644 --- a/src/be/nikiroo/fanfix/reader/BasicReader.java +++ b/src/be/nikiroo/fanfix/reader/BasicReader.java @@ -48,6 +48,7 @@ public abstract class BasicReader implements Reader { } } + @Override public synchronized Story getStory(Progress pg) { if (story == null) { story = getLibrary().getStory(meta.getLuid(), pg); @@ -56,6 +57,7 @@ public abstract class BasicReader implements Reader { return story; } + @Override public BasicLibrary getLibrary() { if (lib == null) { lib = defaultLibrary; @@ -64,18 +66,22 @@ public abstract class BasicReader implements Reader { return lib; } + @Override public void setLibrary(BasicLibrary lib) { this.lib = lib; } + @Override public MetaData getMeta() { return meta; } + @Override public synchronized void setMeta(MetaData meta) throws IOException { setMeta(meta == null ? null : meta.getLuid()); // must check the library } + @Override public synchronized void setMeta(String luid) throws IOException { story = null; meta = getLibrary().getInfo(luid); @@ -85,6 +91,7 @@ public abstract class BasicReader implements Reader { } } + @Override public synchronized void setMeta(URL source, Progress pg) throws IOException { BasicSupport support = BasicSupport.getSupport(source); @@ -102,10 +109,12 @@ public abstract class BasicReader implements Reader { meta = story.getMeta(); } + @Override public int getChapter() { return chapter; } + @Override public void setChapter(int chapter) { this.chapter = chapter; } diff --git a/src/be/nikiroo/fanfix/reader/CliReader.java b/src/be/nikiroo/fanfix/reader/CliReader.java index 8a45885..2f0b8ce 100644 --- a/src/be/nikiroo/fanfix/reader/CliReader.java +++ b/src/be/nikiroo/fanfix/reader/CliReader.java @@ -18,6 +18,7 @@ import be.nikiroo.fanfix.data.Story; * @author niki */ class CliReader extends BasicReader { + @Override public void read() throws IOException { MetaData meta = getMeta(); @@ -78,6 +79,7 @@ class CliReader extends BasicReader { } } + @Override public void browse(String source) { List stories; stories = getLibrary().getListBySource(source); diff --git a/src/be/nikiroo/fanfix/reader/GuiReader.java b/src/be/nikiroo/fanfix/reader/GuiReader.java index 9324258..0faea6e 100644 --- a/src/be/nikiroo/fanfix/reader/GuiReader.java +++ b/src/be/nikiroo/fanfix/reader/GuiReader.java @@ -70,6 +70,7 @@ class GuiReader extends BasicReader { localLibrary = new LocalLibrary(dir, text, images); } + @Override public void read() throws IOException { MetaData meta = getMeta(); @@ -127,6 +128,7 @@ class GuiReader extends BasicReader { return localLibrary.getInfo(luid) != null; } + @Override public void browse(String type) { // TODO: improve presentation of update message final VersionCheck updates = VersionCheck.check(); @@ -154,6 +156,7 @@ class GuiReader extends BasicReader { // handle link events updateMessage.addHyperlinkListener(new HyperlinkListener() { + @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType().equals( HyperlinkEvent.EventType.ACTIVATED)) @@ -172,6 +175,7 @@ class GuiReader extends BasicReader { final String typeFinal = type; EventQueue.invokeLater(new Runnable() { + @Override public void run() { if (updates.isNewVersionAvailable()) { int rep = JOptionPane.showConfirmDialog(null, diff --git a/src/be/nikiroo/fanfix/reader/GuiReaderBook.java b/src/be/nikiroo/fanfix/reader/GuiReaderBook.java index 1334518..6475bd9 100644 --- a/src/be/nikiroo/fanfix/reader/GuiReaderBook.java +++ b/src/be/nikiroo/fanfix/reader/GuiReaderBook.java @@ -189,26 +189,31 @@ class GuiReaderBook extends JPanel { private void setupListeners() { listeners = new ArrayList(); addMouseListener(new MouseListener() { + @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { popup(e); } } + @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { popup(e); } } + @Override public void mouseExited(MouseEvent e) { setHovered(false); } + @Override public void mouseEntered(MouseEvent e) { setHovered(true); } + @Override public void mouseClicked(MouseEvent e) { if (isEnabled()) { Date now = new Date(); diff --git a/src/be/nikiroo/fanfix/reader/GuiReaderFrame.java b/src/be/nikiroo/fanfix/reader/GuiReaderFrame.java index 59663fe..e88c977 100644 --- a/src/be/nikiroo/fanfix/reader/GuiReaderFrame.java +++ b/src/be/nikiroo/fanfix/reader/GuiReaderFrame.java @@ -101,6 +101,7 @@ class GuiReaderFrame extends JFrame { add(pgBar, BorderLayout.SOUTH); pgBar.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { invalidate(); pgBar.setProgress(null); @@ -110,6 +111,7 @@ class GuiReaderFrame extends JFrame { }); pgBar.addUpdateListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { invalidate(); validate(); @@ -124,6 +126,7 @@ class GuiReaderFrame extends JFrame { final Progress pg = new Progress(); final String typeF = type; outOfUi(pg, new Runnable() { + @Override public void run() { GuiReaderFrame.this.reader.getLibrary().refresh(false, pg); invalidate(); @@ -181,10 +184,12 @@ class GuiReaderFrame extends JFrame { this.validate(); bookPane.setActionListener(new BookActionListener() { + @Override public void select(GuiReaderBook book) { selectedBook = book; } + @Override public void popupRequested(GuiReaderBook book, MouseEvent e) { JPopupMenu popup = new JPopupMenu(); popup.add(createMenuItemOpenBook()); @@ -198,6 +203,7 @@ class GuiReaderFrame extends JFrame { popup.show(e.getComponent(), e.getX(), e.getY()); } + @Override public void action(final GuiReaderBook book) { openBook(book); } @@ -248,18 +254,21 @@ class GuiReaderFrame extends JFrame { JMenuItem imprt = new JMenuItem("Import URL...", KeyEvent.VK_U); imprt.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { imprt(true); } }); JMenuItem imprtF = new JMenuItem("Import File...", KeyEvent.VK_F); imprtF.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { imprt(false); } }); JMenuItem exit = new JMenuItem("Exit", KeyEvent.VK_X); exit.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { GuiReaderFrame.this.dispatchEvent(new WindowEvent( GuiReaderFrame.this, WindowEvent.WINDOW_CLOSING)); @@ -292,6 +301,7 @@ class GuiReaderFrame extends JFrame { JMenuItem vauthors = new JMenuItem("Author"); vauthors.setMnemonic(KeyEvent.VK_A); vauthors.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { words = false; refreshBooks(); @@ -301,6 +311,7 @@ class GuiReaderFrame extends JFrame { JMenuItem vwords = new JMenuItem("Word count"); vwords.setMnemonic(KeyEvent.VK_W); vwords.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { words = true; refreshBooks(); @@ -317,6 +328,7 @@ class GuiReaderFrame extends JFrame { for (final String type : tt) { JMenuItem item = new JMenuItem(type == null ? "All" : type); item.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { removeBookPanes(); addBookPane(type, true); @@ -341,6 +353,7 @@ class GuiReaderFrame extends JFrame { JMenuItem item = new JMenuItem(author == null ? "All" : author.isEmpty() ? "[unknown]" : author); item.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { removeBookPanes(); addBookPane(author, false); @@ -376,6 +389,7 @@ class GuiReaderFrame extends JFrame { item.setMnemonic(KeyEvent.VK_F); item.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { ConfigEditor ed = new ConfigEditor( Config.class, Instance.getConfig(), @@ -401,6 +415,7 @@ class GuiReaderFrame extends JFrame { item.setMnemonic(KeyEvent.VK_U); item.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { ConfigEditor ed = new ConfigEditor( UiConfig.class, Instance.getUiConfig(), @@ -451,6 +466,7 @@ class GuiReaderFrame extends JFrame { JMenuItem export = new JMenuItem("Save as...", KeyEvent.VK_S); export.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { if (selectedBook != null) { fc.showDialog(GuiReaderFrame.this, "Save"); @@ -461,6 +477,7 @@ class GuiReaderFrame extends JFrame { + type.getDefaultExtension(false); final Progress pg = new Progress(); outOfUi(pg, new Runnable() { + @Override public void run() { try { reader.getLibrary().export( @@ -510,14 +527,17 @@ class GuiReaderFrame extends JFrame { private JMenuItem createMenuItemClearCache() { JMenuItem refresh = new JMenuItem("Clear cache", KeyEvent.VK_C); refresh.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { if (selectedBook != null) { outOfUi(null, new Runnable() { + @Override public void run() { reader.clearLocalReaderCache(selectedBook.getMeta() .getLuid()); selectedBook.setCached(false); SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { selectedBook.repaint(); } @@ -554,6 +574,7 @@ class GuiReaderFrame extends JFrame { final String ftype = type; item.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { if (selectedBook != null) { String type = ftype; @@ -563,15 +584,17 @@ class GuiReaderFrame extends JFrame { "Moving story", JOptionPane.QUESTION_MESSAGE, null, null, selectedBook.getMeta().getSource()); + if (rep == null) { return; - } else { - type = rep.toString(); } + + type = rep.toString(); } final String ftype = type; outOfUi(null, new Runnable() { + @Override public void run() { reader.changeType(selectedBook.getMeta() .getLuid(), ftype); @@ -579,6 +602,7 @@ class GuiReaderFrame extends JFrame { selectedBook = null; SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { setJMenuBar(createMenu()); } @@ -601,10 +625,12 @@ class GuiReaderFrame extends JFrame { private JMenuItem createMenuItemRedownload() { JMenuItem refresh = new JMenuItem("Redownload", KeyEvent.VK_R); refresh.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { if (selectedBook != null) { final MetaData meta = selectedBook.getMeta(); imprt(meta.getUrl(), new Runnable() { + @Override public void run() { reader.delete(meta.getLuid()); GuiReaderFrame.this.selectedBook = null; @@ -625,9 +651,11 @@ class GuiReaderFrame extends JFrame { private JMenuItem createMenuItemDelete() { JMenuItem delete = new JMenuItem("Delete", KeyEvent.VK_D); delete.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { if (selectedBook != null) { outOfUi(null, new Runnable() { + @Override public void run() { reader.delete(selectedBook.getMeta().getLuid()); selectedBook = null; @@ -648,6 +676,7 @@ class GuiReaderFrame extends JFrame { private JMenuItem createMenuItemOpenBook() { JMenuItem open = new JMenuItem("Open", KeyEvent.VK_O); open.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { if (selectedBook != null) { openBook(selectedBook); @@ -667,10 +696,12 @@ class GuiReaderFrame extends JFrame { private void openBook(final GuiReaderBook book) { final Progress pg = new Progress(); outOfUi(pg, new Runnable() { + @Override public void run() { try { reader.read(book.getMeta().getLuid(), pg); SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { book.setCached(true); } @@ -711,6 +742,7 @@ class GuiReaderFrame extends JFrame { setEnabled(false); new Thread(new Runnable() { + @Override public void run() { run.run(); refreshBooks(); @@ -782,6 +814,7 @@ class GuiReaderFrame extends JFrame { pg.addProgress(pgOnSuccess, 5); outOfUi(pg, new Runnable() { + @Override public void run() { Exception ex = null; try { @@ -798,6 +831,7 @@ class GuiReaderFrame extends JFrame { if (!ok) { Instance.syserr(e); SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { JOptionPane.showMessageDialog(GuiReaderFrame.this, "Cannot import: " + url, e.getMessage(), diff --git a/src/be/nikiroo/fanfix/reader/GuiReaderGroup.java b/src/be/nikiroo/fanfix/reader/GuiReaderGroup.java index ca3768d..041e8bc 100644 --- a/src/be/nikiroo/fanfix/reader/GuiReaderGroup.java +++ b/src/be/nikiroo/fanfix/reader/GuiReaderGroup.java @@ -109,15 +109,18 @@ public class GuiReaderGroup extends JPanel { books.add(book); book.addActionListener(new BookActionListener() { + @Override public void select(GuiReaderBook book) { for (GuiReaderBook abook : books) { abook.setSelected(abook == book); } } + @Override public void popupRequested(GuiReaderBook book, MouseEvent e) { } + @Override public void action(GuiReaderBook book) { } }); diff --git a/src/be/nikiroo/fanfix/reader/Reader.java b/src/be/nikiroo/fanfix/reader/Reader.java index d2984bd..d540d39 100644 --- a/src/be/nikiroo/fanfix/reader/Reader.java +++ b/src/be/nikiroo/fanfix/reader/Reader.java @@ -49,7 +49,7 @@ public interface Reader { return null; } - }; + } /** * Return the current target {@link MetaData}. diff --git a/src/be/nikiroo/fanfix/reader/TuiReader.java b/src/be/nikiroo/fanfix/reader/TuiReader.java index 8456da3..11640cf 100644 --- a/src/be/nikiroo/fanfix/reader/TuiReader.java +++ b/src/be/nikiroo/fanfix/reader/TuiReader.java @@ -49,6 +49,7 @@ class TuiReader extends BasicReader { return backendType; } + @Override public void read() throws IOException { try { TuiReaderApplication app = new TuiReaderApplication(this, @@ -59,6 +60,7 @@ class TuiReader extends BasicReader { } } + @Override public void browse(String source) { List metas = getLibrary().getListBySource(source); try { diff --git a/src/be/nikiroo/fanfix/reader/TuiReaderApplication.java b/src/be/nikiroo/fanfix/reader/TuiReaderApplication.java index 93a0167..f95cbf3 100644 --- a/src/be/nikiroo/fanfix/reader/TuiReaderApplication.java +++ b/src/be/nikiroo/fanfix/reader/TuiReaderApplication.java @@ -46,6 +46,8 @@ class TuiReaderApplication extends TApplication implements Reader { new TuiReaderMainWindow(this).setMetas(stories); } + @SuppressWarnings("unused") + @Override public void read() throws IOException { MetaData meta = getMeta(); @@ -66,42 +68,52 @@ class TuiReaderApplication extends TApplication implements Reader { } } + @Override public MetaData getMeta() { return reader.getMeta(); } + @Override public Story getStory(Progress pg) { return reader.getStory(pg); } + @Override public BasicLibrary getLibrary() { return reader.getLibrary(); } + @Override public void setLibrary(BasicLibrary lib) { reader.setLibrary(lib); } + @Override public void setMeta(MetaData meta) throws IOException { reader.setMeta(meta); } + @Override public void setMeta(String luid) throws IOException { reader.setMeta(luid); } + @Override public void setMeta(URL source, Progress pg) throws IOException { reader.setMeta(source, pg); } + @Override public void browse(String source) { reader.browse(source); } + @Override public int getChapter() { return reader.getChapter(); } + @Override public void setChapter(int chapter) { reader.setChapter(chapter); } diff --git a/src/be/nikiroo/fanfix/reader/TuiReaderStoryWindow.java b/src/be/nikiroo/fanfix/reader/TuiReaderStoryWindow.java index 9bc18fe..e8dafc3 100644 --- a/src/be/nikiroo/fanfix/reader/TuiReaderStoryWindow.java +++ b/src/be/nikiroo/fanfix/reader/TuiReaderStoryWindow.java @@ -52,21 +52,25 @@ class TuiReaderStoryWindow extends TWindow { // button is // pressed navigationButtons.add(addButton("<< ", 0, row, new TAction() { + @Override public void DO() { setChapter(0); } })); navigationButtons.add(addButton("< ", 4, row, new TAction() { + @Override public void DO() { setChapter(TuiReaderStoryWindow.this.chapter - 1); } })); navigationButtons.add(addButton("> ", 7, row, new TAction() { + @Override public void DO() { setChapter(TuiReaderStoryWindow.this.chapter + 1); } })); navigationButtons.add(addButton(">> ", 10, row, new TAction() { + @Override public void DO() { setChapter(getStory().getChapters().size()); } diff --git a/src/be/nikiroo/fanfix/supported/BasicSupport.java b/src/be/nikiroo/fanfix/supported/BasicSupport.java index fc6bbd2..d56e52d 100644 --- a/src/be/nikiroo/fanfix/supported/BasicSupport.java +++ b/src/be/nikiroo/fanfix/supported/BasicSupport.java @@ -374,7 +374,7 @@ public abstract class BasicSupport { pg.setProgress(50); - if (meta != null && meta.getCover() == null) { + if (meta.getCover() == null) { meta.setCover(getDefaultCover(meta.getSubject())); } @@ -576,6 +576,7 @@ public abstract class BasicSupport { * @throws IOException * on I/O error */ + @SuppressWarnings("unused") protected void preprocess(URL source, InputStream in) throws IOException { } @@ -755,9 +756,9 @@ public abstract class BasicSupport { if (image != null) { return new Paragraph(image); - } else { - return processPara(line); } + + return processPara(line); } /** @@ -840,9 +841,9 @@ public abstract class BasicSupport { static String[] getImageExt(boolean emptyAllowed) { if (emptyAllowed) { return new String[] { "", ".png", ".jpg", ".jpeg", ".gif", ".bmp" }; - } else { - return new String[] { ".png", ".jpg", ".jpeg", ".gif", ".bmp" }; } + + return new String[] { ".png", ".jpg", ".jpeg", ".gif", ".bmp" }; } /** @@ -1161,9 +1162,9 @@ public abstract class BasicSupport { if (prev == car) { builder.append(closeDoubleQuote); continue; - } else { - builder.append(closeQuote); } + + builder.append(closeQuote); } } diff --git a/src/be/nikiroo/fanfix/supported/E621.java b/src/be/nikiroo/fanfix/supported/E621.java index 527e092..1baa620 100644 --- a/src/be/nikiroo/fanfix/supported/E621.java +++ b/src/be/nikiroo/fanfix/supported/E621.java @@ -102,7 +102,7 @@ class E621 extends BasicSupport { return null; } - private String getAuthor(URL source, InputStream in) throws IOException { + private String getAuthor(URL source, InputStream in) { String author = getLine(in, "href=\"/post/show/", 0); if (author != null) { String key = "href=\""; @@ -144,7 +144,7 @@ class E621 extends BasicSupport { return null; } - private String getTitle(InputStream in) throws IOException { + private String getTitle(InputStream in) { String title = getLine(in, "", 0); if (title != null) { int pos = title.indexOf('>'); @@ -222,14 +222,17 @@ class E621 extends BasicSupport { final String key = Integer.toString(i); final URL value = new URL(source.toString() + "?page=" + i); urls.add(new Entry<String, URL>() { + @Override public URL setValue(URL value) { return null; } + @Override public URL getValue() { return value; } + @Override public String getKey() { return key; } diff --git a/src/be/nikiroo/fanfix/supported/EHentai.java b/src/be/nikiroo/fanfix/supported/EHentai.java index 3636354..fe993a1 100644 --- a/src/be/nikiroo/fanfix/supported/EHentai.java +++ b/src/be/nikiroo/fanfix/supported/EHentai.java @@ -78,8 +78,7 @@ class EHentai extends BasicSupport { return true; } - private BufferedImage getCover(URL source, InputStream in) - throws IOException { + private BufferedImage getCover(URL source, InputStream in) { BufferedImage author = null; String coverLine = getKeyLine(in, "<div id=\"gd1\"", " url(", ")"); if (coverLine != null) { @@ -167,7 +166,7 @@ class EHentai extends BasicSupport { return tags; } - private String getTitle(InputStream in) throws IOException { + private String getTitle(InputStream in) { String siteName = " - E-Hentai Galleries"; String title = getLine(in, "<title>", 0); @@ -233,14 +232,17 @@ class EHentai extends BasicSupport { final String key = Integer.toString(i + 1); final URL value = new URL(source.toString() + "?p=" + i); urls.add(new Entry<String, URL>() { + @Override public URL setValue(URL value) { return null; } + @Override public URL getValue() { return value; } + @Override public String getKey() { return key; } diff --git a/src/be/nikiroo/fanfix/supported/Fanfiction.java b/src/be/nikiroo/fanfix/supported/Fanfiction.java index 1d1f3f4..fd51493 100644 --- a/src/be/nikiroo/fanfix/supported/Fanfiction.java +++ b/src/be/nikiroo/fanfix/supported/Fanfiction.java @@ -74,7 +74,7 @@ class Fanfiction extends BasicSupport { return null; } - private List<String> getTags(InputStream in) throws IOException { + private List<String> getTags(InputStream in) { List<String> tags = new ArrayList<String>(); String key = "title=\"Send Private Message\""; @@ -245,14 +245,17 @@ class Fanfiction extends BasicSupport { final String chapName = name.trim(); final URL chapURL = new URL(base + i + suffix); urls.add(new Entry<String, URL>() { + @Override public URL setValue(URL value) { return null; } + @Override public URL getValue() { return chapURL; } + @Override public String getKey() { return chapName; } @@ -270,14 +273,17 @@ class Fanfiction extends BasicSupport { final String chapName = getTitle(reset(in)); final URL chapURL = source; urls.add(new Entry<String, URL>() { + @Override public URL setValue(URL value) { return null; } + @Override public URL getValue() { return chapURL; } + @Override public String getKey() { return chapName; } diff --git a/src/be/nikiroo/fanfix/supported/Fimfiction.java b/src/be/nikiroo/fanfix/supported/Fimfiction.java index 08d1712..cb26ac6 100644 --- a/src/be/nikiroo/fanfix/supported/Fimfiction.java +++ b/src/be/nikiroo/fanfix/supported/Fimfiction.java @@ -235,14 +235,17 @@ class Fimfiction extends BasicSupport { final URL value = new URL("http://www.fimfiction.net" + line); urls.add(new Entry<String, URL>() { + @Override public URL setValue(URL value) { return null; } + @Override public String getKey() { return key; } + @Override public URL getValue() { return value; } diff --git a/src/be/nikiroo/fanfix/supported/InfoReader.java b/src/be/nikiroo/fanfix/supported/InfoReader.java index 571f77b..466a885 100644 --- a/src/be/nikiroo/fanfix/supported/InfoReader.java +++ b/src/be/nikiroo/fanfix/supported/InfoReader.java @@ -31,11 +31,11 @@ public class InfoReader { in.close(); in = null; } - } else { - throw new FileNotFoundException( - "File given as argument does not exists: " - + infoFile.getAbsolutePath()); } + + throw new FileNotFoundException( + "File given as argument does not exists: " + + infoFile.getAbsolutePath()); } private static MetaData createMeta(URL sourceInfoFile, InputStream in, diff --git a/src/be/nikiroo/fanfix/supported/MangaFox.java b/src/be/nikiroo/fanfix/supported/MangaFox.java index c8eaa1d..d6f1464 100644 --- a/src/be/nikiroo/fanfix/supported/MangaFox.java +++ b/src/be/nikiroo/fanfix/supported/MangaFox.java @@ -118,18 +118,18 @@ class MangaFox extends BasicSupport { if (authors.isEmpty()) { return null; - } else { - StringBuilder builder = new StringBuilder(); - for (String author : authors) { - if (builder.length() > 0) { - builder.append(", "); - } + } - builder.append(author); + StringBuilder builder = new StringBuilder(); + for (String author : authors) { + if (builder.length() > 0) { + builder.append(", "); } - return builder.toString(); + builder.append(author); } + + return builder.toString(); } private String getDate(InputStream in) { @@ -246,14 +246,17 @@ class MangaFox extends BasicSupport { final String key = name; final URL value = new URL(url); urls.add(new Entry<String, URL>() { + @Override public URL setValue(URL value) { return null; } + @Override public String getKey() { return key; } + @Override public URL getValue() { return value; } diff --git a/src/be/nikiroo/fanfix/supported/Text.java b/src/be/nikiroo/fanfix/supported/Text.java index 6715695..c9ebd18 100644 --- a/src/be/nikiroo/fanfix/supported/Text.java +++ b/src/be/nikiroo/fanfix/supported/Text.java @@ -57,7 +57,7 @@ class Text extends BasicSupport { meta.setPublisher(""); meta.setUuid(source.toString()); meta.setLuid(""); - meta.setLang(getLang(source, reset(in))); // default is EN + meta.setLang(getLang(reset(in))); // default is EN meta.setSubject(getSubject(source)); meta.setType(getType().toString()); meta.setImageDocument(false); @@ -77,7 +77,7 @@ class Text extends BasicSupport { } - private String getLang(URL source, InputStream in) throws IOException { + private String getLang(InputStream in) { @SuppressWarnings("resource") Scanner scan = new Scanner(in, "UTF-8"); scan.useDelimiter("\\n"); @@ -103,14 +103,14 @@ class Text extends BasicSupport { return lang; } - private String getTitle(InputStream in) throws IOException { + private String getTitle(InputStream in) { @SuppressWarnings("resource") Scanner scan = new Scanner(in, "UTF-8"); scan.useDelimiter("\\n"); return scan.next(); } - private String getAuthor(InputStream in) throws IOException { + private String getAuthor(InputStream in) { @SuppressWarnings("resource") Scanner scan = new Scanner(in, "UTF-8"); scan.useDelimiter("\\n"); @@ -126,7 +126,7 @@ class Text extends BasicSupport { return fixAuthor(author); } - private String getDate(InputStream in) throws IOException { + private String getDate(InputStream in) { @SuppressWarnings("resource") Scanner scan = new Scanner(in, "UTF-8"); scan.useDelimiter("\\n"); @@ -151,7 +151,7 @@ class Text extends BasicSupport { return getChapterContent(source, in, 0, null); } - private BufferedImage getCover(URL source) throws IOException { + private BufferedImage getCover(URL source) { String path; try { path = new File(source.toURI()).getPath(); @@ -188,14 +188,17 @@ class Text extends BasicSupport { final URL value = source; final String key = chapName; chaps.add(new Entry<String, URL>() { + @Override public URL setValue(URL value) { return null; } + @Override public URL getValue() { return value; } + @Override public String getKey() { return key; } diff --git a/src/be/nikiroo/fanfix/supported/YiffStar.java b/src/be/nikiroo/fanfix/supported/YiffStar.java index 9813df8..ba24e50 100644 --- a/src/be/nikiroo/fanfix/supported/YiffStar.java +++ b/src/be/nikiroo/fanfix/supported/YiffStar.java @@ -36,7 +36,7 @@ class YiffStar extends BasicSupport { MetaData meta = new MetaData(); meta.setTitle(getTitle(reset(in))); - meta.setAuthor(getAuthor(source, reset(in))); + meta.setAuthor(getAuthor(reset(in))); meta.setDate(""); meta.setTags(getTags(reset(in))); meta.setSource(getSourceName()); @@ -159,7 +159,7 @@ class YiffStar extends BasicSupport { return null; } - private String getAuthor(URL source, InputStream in) throws IOException { + private String getAuthor(InputStream in) { String author = getLine(in, "class=\"onlinestatus", 0); if (author != null) { return StringUtils.unhtml(author).trim(); @@ -168,7 +168,7 @@ class YiffStar extends BasicSupport { return null; } - private String getTitle(InputStream in) throws IOException { + private String getTitle(InputStream in) { String title = getLine(in, "class=\"sflabel pagetitle", 0); if (title != null) { if (title.contains("(series)")) { @@ -206,14 +206,17 @@ class YiffStar extends BasicSupport { final URL value = guest(link); final String key = StringUtils.unhtml(line).trim(); urls.add(new Entry<String, URL>() { + @Override public URL setValue(URL value) { return null; } + @Override public URL getValue() { return value; } + @Override public String getKey() { return key; } @@ -271,11 +274,11 @@ class YiffStar extends BasicSupport { if (link.contains("?")) { if (link.contains("/?")) { return new URL(link.replace("?", "guest?")); - } else { - return new URL(link.replace("?", "/guest?")); } - } else { - return new URL(link + "/guest"); + + return new URL(link.replace("?", "/guest?")); } + + return new URL(link + "/guest"); } } diff --git a/src/be/nikiroo/fanfix/test/BasicSupportTest.java b/src/be/nikiroo/fanfix/test/BasicSupportTest.java index 40da442..af33f9d 100644 --- a/src/be/nikiroo/fanfix/test/BasicSupportTest.java +++ b/src/be/nikiroo/fanfix/test/BasicSupportTest.java @@ -180,7 +180,7 @@ public class BasicSupportTest extends TestLauncher { public void setUp() throws Exception { super.setUp(); - }; + } @Override public void tearDown() throws Exception { @@ -325,12 +325,12 @@ public class BasicSupportTest extends TestLauncher { + "Fanfan." + "\n" + "\n" + "Chapter 2: Chap2" + "\n" + "\n" // + "Tulipe." + "\n"); - }; + } @Override public void tearDown() throws Exception { tmp.delete(); - }; + } @Override public void test() throws Exception { @@ -368,12 +368,12 @@ public class BasicSupportTest extends TestLauncher { + "Fanfan." + "\n" + "\n" + "Chapter 2: Chap2" + "\n" + "\n" // + "Tulipe." + "\n"); - }; + } @Override public void tearDown() throws Exception { tmp.delete(); - }; + } @Override public void test() throws Exception {