diff --git a/.idea/compiler.xml b/.idea/compiler.xml index fb7f4a8..b589d56 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/src/main/java/io/github/eb4j/ebview/dictionary/epwing/EBDictionary.java b/src/main/java/io/github/eb4j/ebview/dictionary/epwing/EBDictionary.java index da401d4..5204afe 100644 --- a/src/main/java/io/github/eb4j/ebview/dictionary/epwing/EBDictionary.java +++ b/src/main/java/io/github/eb4j/ebview/dictionary/epwing/EBDictionary.java @@ -20,14 +20,14 @@ public class EBDictionary { static final Logger LOG = LoggerFactory.getLogger(EBDictionary.class.getName()); - static final Set ignoreBookList = new HashSet<>(); + static final Set IGNORE_BOOK_LIST = new HashSet<>(); private final List subBooks; static { - ignoreBookList.add("「広辞苑」紹介"); - ignoreBookList.add("EPWING電子カタログ"); - ignoreBookList.add("EPWING 紹介"); - ignoreBookList.add("書籍選択"); + IGNORE_BOOK_LIST.add("「広辞苑」紹介"); + IGNORE_BOOK_LIST.add("EPWING電子カタログ"); + IGNORE_BOOK_LIST.add("EPWING 紹介"); + IGNORE_BOOK_LIST.add("書籍選択"); } public EBDictionary(final File catalogFile) throws Exception { @@ -61,7 +61,7 @@ public SubBook getSubBook(final int index) { public Set getEBDictionarySubBooks() { Set result = new HashSet<>(); for (int i = 0, subBooksSize = subBooks.size(); i < subBooksSize; i++) { - if (!ignoreBookList.contains(subBooks.get(i).getTitle())) { + if (!IGNORE_BOOK_LIST.contains(subBooks.get(i).getTitle())) { result.add(new EBDictionarySubbook(this, i)); } } diff --git a/src/main/java/io/github/eb4j/ebview/dictionary/pdic/PdicDictionary.java b/src/main/java/io/github/eb4j/ebview/dictionary/pdic/PdicDictionary.java index b9596d5..f2e4882 100644 --- a/src/main/java/io/github/eb4j/ebview/dictionary/pdic/PdicDictionary.java +++ b/src/main/java/io/github/eb4j/ebview/dictionary/pdic/PdicDictionary.java @@ -39,8 +39,8 @@ public PdicDictionary(final File file) throws IOException { if (len == headerSize) { header = new PdicHeader(); if (header.load(headerbuff) != 0) { - // Unicode辞書 かつ ver6以上のみ許容 - if ((header.version & 0xFF00) < 0x0600 || header.os != 0x20) { + // Unicode辞書 かつ ver5以上のみ許容 + if ((header.version & 0xFF00) < 0x0500 || header.os != 0x20) { LOG.warn("Unsupported dictionary version" + srcFile.getName()); throw new RuntimeException(); } diff --git a/src/main/java/io/github/eb4j/ebview/dictionary/pdic/PdicHeader.java b/src/main/java/io/github/eb4j/ebview/dictionary/pdic/PdicHeader.java index 17321e9..cac72fc 100644 --- a/src/main/java/io/github/eb4j/ebview/dictionary/pdic/PdicHeader.java +++ b/src/main/java/io/github/eb4j/ebview/dictionary/pdic/PdicHeader.java @@ -46,57 +46,57 @@ final class PdicHeader { } /** - * @param header_block ヘッダーデータ部分 + * @param headerBlock ヘッダーデータ部分 * @return 辞書バージョン */ - public int load(final ByteBuffer header_block) throws RuntimeException { + public int load(final ByteBuffer headerBlock) throws RuntimeException { int ret = 0; // Charset sjisset = Charset.forName("X-SJIS"); byte[] headernamebuff = new byte[L_HEADERNAME]; byte[] dictitlebuff = new byte[L_DICTITLE]; - header_block.flip(); - header_block.order(ByteOrder.LITTLE_ENDIAN); - header_block.get(headernamebuff); + headerBlock.flip(); + headerBlock.order(ByteOrder.LITTLE_ENDIAN); + headerBlock.get(headernamebuff); // headername = sjisset.decode(ByteBuffer.wrap(headernamebuff)).toString(); - header_block.get(dictitlebuff); + headerBlock.get(dictitlebuff); // dictitle = sjisset.decode(ByteBuffer.wrap(dictitlebuff)).toString(); - version = header_block.getShort(); + version = headerBlock.getShort(); if ((version & 0xFF00) == 0x0500 || (version & 0xFF00) == 0x0600) { - header_block.getShort(); // lword - header_block.getShort(); // ljapa + headerBlock.getShort(); // lword + headerBlock.getShort(); // ljapa - block_size = header_block.getShort(); - index_block = header_block.getShort(); - header_size = header_block.getShort(); - header_block.getShort(); // index_size - header_block.getShort(); // empty_block - header_block.getShort(); // nindex - header_block.getShort(); // nblock + block_size = headerBlock.getShort(); + index_block = headerBlock.getShort(); + header_size = headerBlock.getShort(); + headerBlock.getShort(); // index_size + headerBlock.getShort(); // empty_block + headerBlock.getShort(); // nindex + headerBlock.getShort(); // nblock - header_block.getInt(); // nword + headerBlock.getInt(); // nword - header_block.get(); // dicorder - header_block.get(); // dictype - attrlen = header_block.get(); - os = header_block.get(); + headerBlock.get(); // dicorder + headerBlock.get(); // dictype + attrlen = headerBlock.get(); + os = headerBlock.get(); - header_block.getInt(); // ole_number + headerBlock.getInt(); // ole_number // lid_dummy - header_block.getShort(); - header_block.getShort(); - header_block.getShort(); - header_block.getShort(); - header_block.getShort(); - - index_blkbit = (header_block.get() != 0); - header_block.get(); // dummy0 - extheader = header_block.getInt(); - header_block.getInt(); //empty_block2 - nindex2 = header_block.getInt(); - header_block.getInt(); // nblock2 + headerBlock.getShort(); + headerBlock.getShort(); + headerBlock.getShort(); + headerBlock.getShort(); + headerBlock.getShort(); + + index_blkbit = (headerBlock.get() != 0); + headerBlock.get(); // dummy0 + extheader = headerBlock.getInt(); + headerBlock.getInt(); //empty_block2 + nindex2 = headerBlock.getInt(); + headerBlock.getInt(); // nblock2 // 固定部分チェック if (attrlen == 1) { diff --git a/src/main/java/io/github/eb4j/ebview/dictionary/pdic/PdicInfo.java b/src/main/java/io/github/eb4j/ebview/dictionary/pdic/PdicInfo.java index c08b2a1..d00d7d2 100644 --- a/src/main/java/io/github/eb4j/ebview/dictionary/pdic/PdicInfo.java +++ b/src/main/java/io/github/eb4j/ebview/dictionary/pdic/PdicInfo.java @@ -91,15 +91,15 @@ public int searchIndexBlock(final String word) { int min = 0; int max = m_nindex - 1; - ByteBuffer __word = mEncodeCache.get(word); - if (__word == null) { - __word = encodetoByteBuffer(mMainCharset, word); - mEncodeCache.put(word, __word); + ByteBuffer buffer = mEncodeCache.get(word); + if (buffer == null) { + buffer = encodetoByteBuffer(mMainCharset, word); + mEncodeCache.put(word, buffer); } - int limit = __word.limit(); - byte[] _word = new byte[limit]; - System.arraycopy(__word.array(), 0, _word, 0, limit); - int _wordlen = _word.length; + int limit = buffer.limit(); + byte[] bytes = new byte[limit]; + System.arraycopy(buffer.array(), 0, bytes, 0, limit); + int wordlen = bytes.length; int[] indexPtr = mIndexPtr; int blockbits = m_blockbits; @@ -111,7 +111,7 @@ public int searchIndexBlock(final String word) { } final int look = (int) (((long) min + max) / 2); final int len = indexPtr[look + 1] - indexPtr[look] - blockbits; - final int comp = pdicInfoCache.compare(_word, 0, _wordlen, indexPtr[look], len); + final int comp = pdicInfoCache.compare(bytes, 0, wordlen, indexPtr[look], len); if (comp < 0) { max = look; } else if (comp > 0) { @@ -246,12 +246,12 @@ public String getDicName() { } // 単語を検索する - public boolean searchWord(final String _word) { + public boolean searchWord(final String word) { // 検索結果クリア int cnt = 0; mSearchResult.clear(); - int ret = searchIndexBlock(_word); + int ret = searchIndexBlock(word); boolean match = false; @@ -264,7 +264,7 @@ public boolean searchWord(final String _word) { byte[] pblk = readBlockData(block); if (pblk != null) { mAnalyze.setBuffer(pblk); - mAnalyze.setSearch(_word); + mAnalyze.setSearch(word); searchret = mAnalyze.searchWord(); // 未発見でEOBの時のみもう一回、回る if (!searchret && mAnalyze.mEob) { @@ -283,7 +283,7 @@ public boolean searchWord(final String _word) { break; } // 完全一致するかチェック - if (res.mIndex.compareTo(_word) == 0) { + if (res.mIndex.compareTo(word) == 0) { match = true; } mSearchResult.add(res); @@ -296,8 +296,8 @@ public boolean searchWord(final String _word) { } // 前方一致する単語の有無を返す - boolean searchPrefix(final String _word) { - int ret = searchIndexBlock(_word); + boolean searchPrefix(final String word) { + int ret = searchIndexBlock(word); for (int blk = 0; blk < 2; blk++) { // 最終ブロックは超えない @@ -311,7 +311,7 @@ boolean searchPrefix(final String _word) { if (pblk != null) { mAnalyze.setBuffer(pblk); - mAnalyze.setSearch(_word); + mAnalyze.setSearch(word); if (mAnalyze.searchWord()) { return true; @@ -417,7 +417,7 @@ final class AnalyzeBlock { private int mCompLen = 0; private boolean mEob = false; - public AnalyzeBlock() { + AnalyzeBlock() { } public void setBuffer(final byte[] buff) { @@ -431,10 +431,10 @@ public void setBuffer(final byte[] buff) { } public void setSearch(final String word) { - ByteBuffer __word = encodetoByteBuffer(mMainCharset, word); - mEncodeCache.put(word, __word); - mWord = new byte[__word.limit()]; - System.arraycopy(__word.array(), 0, mWord, 0, __word.limit()); + ByteBuffer buffer = encodetoByteBuffer(mMainCharset, word); + mEncodeCache.put(word, buffer); + mWord = new byte[buffer.limit()]; + System.arraycopy(buffer.array(), 0, mWord, 0, buffer.limit()); } public boolean isEob() { @@ -445,11 +445,11 @@ public boolean isEob() { * ブロックデータの中から指定語を探す. */ public boolean searchWord() { - final byte[] _word = mWord; + final byte[] bytes = mWord; final byte[] buff = mBuff; final boolean longfield = mLongfield; final byte[] compbuff = mCompbuff; - final int wordlen = _word.length; + final int wordlen = bytes.length; mFoundPtr = -1; @@ -506,11 +506,11 @@ public boolean searchWord() { boolean equal = true; for (int i = 0; i < wordlen; i++) { - if (compbuff[i] != _word[i]) { + if (compbuff[i] != bytes[i]) { equal = false; int cc = compbuff[i]; cc &= 0xFF; - int cw = _word[i]; + int cw = bytes[i]; cw &= 0xFF; // 超えてたら打ち切る if (cc > cw) { @@ -613,7 +613,7 @@ PdicElement getRecord() { // 次の項目が検索語に前方一致するかチェックする public boolean hasMoreResult(final boolean incrementptr) { - byte[] _word; + byte[] word; final byte[] buff = mBuff; final boolean longfield = mLongfield; final byte[] compbuff = mCompbuff; @@ -622,9 +622,9 @@ public boolean hasMoreResult(final boolean incrementptr) { if (mFoundPtr == -1) { return false; } - _word = mWord; + word = mWord; - int wordlen = _word.length; + int wordlen = word.length; // 訳語データ読込 int ptr = mNextPtr; @@ -675,11 +675,11 @@ public boolean hasMoreResult(final boolean incrementptr) { // 前方一致で比較 boolean equal = true; for (int i = 0; i < wordlen; i++) { - if (compbuff[i] != _word[i]) { + if (compbuff[i] != word[i]) { equal = false; int cc = compbuff[i]; cc &= 0xFF; - int cw = _word[i]; + int cw = word[i]; cw &= 0xFF; // 超えてたら打ち切る if (cc > cw) { diff --git a/src/main/java/io/github/eb4j/ebview/gui/DictionaryPane.java b/src/main/java/io/github/eb4j/ebview/gui/DictionaryPane.java index 930e241..b44660d 100644 --- a/src/main/java/io/github/eb4j/ebview/gui/DictionaryPane.java +++ b/src/main/java/io/github/eb4j/ebview/gui/DictionaryPane.java @@ -4,9 +4,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.sound.sampled.AudioInputStream; -import javax.sound.sampled.AudioSystem; -import javax.sound.sampled.Clip; import javax.swing.JTextPane; import javax.swing.UIManager; import javax.swing.text.BadLocationException; @@ -25,7 +22,6 @@ import java.awt.event.FocusListener; import java.awt.font.TextAttribute; import java.awt.geom.Rectangle2D; -import java.io.File; import java.io.IOException; import java.io.Reader; import java.io.StringReader; diff --git a/src/main/java/io/github/eb4j/ebview/gui/EBViewerModel.java b/src/main/java/io/github/eb4j/ebview/gui/EBViewerModel.java index e3023ba..c4fb0c5 100644 --- a/src/main/java/io/github/eb4j/ebview/gui/EBViewerModel.java +++ b/src/main/java/io/github/eb4j/ebview/gui/EBViewerModel.java @@ -11,9 +11,9 @@ public final class EBViewerModel { - private static final DefaultListModel dictionaryInfoModel = new DefaultListModel<>(); - private static final DefaultListModel historyModel = new DefaultListModel<>(); - private static final DefaultListModel headingsModel = new DefaultListModel<>(); + private static final DefaultListModel DICTIONARY_INFO_MODEL = new DefaultListModel<>(); + private static final DefaultListModel HISTORY_MODEL = new DefaultListModel<>(); + private static final DefaultListModel HEADINGS_MODEL = new DefaultListModel<>(); private final Set selectedDicts = new HashSet<>(); private final List ourResult = new ArrayList<>(); @@ -22,23 +22,23 @@ public EBViewerModel() { } DefaultListModel getDictionaryInfoModel() { - return dictionaryInfoModel; + return DICTIONARY_INFO_MODEL; } DefaultListModel getHeadingsModel() { - return headingsModel; + return HEADINGS_MODEL; } DefaultListModel getHistoryModel() { - return historyModel; + return HISTORY_MODEL; } void selectAllDict() { selectedDicts.clear(); - int[] indecs = new int[dictionaryInfoModel.getSize()]; - for (int i = 0; i < dictionaryInfoModel.getSize(); i++) { + int[] indecs = new int[DICTIONARY_INFO_MODEL.getSize()]; + for (int i = 0; i < DICTIONARY_INFO_MODEL.getSize(); i++) { indecs[i] = i; - selectedDicts.add(dictionaryInfoModel.get(i)); + selectedDicts.add(DICTIONARY_INFO_MODEL.get(i)); } MainWindow.updateDictionaryList(indecs); updateResult(); @@ -55,25 +55,25 @@ Set getSelectedDicts() { void selectDicts(final int[] indecs) { selectedDicts.clear(); for (int idx: indecs) { - String dictName = dictionaryInfoModel.get(idx); + String dictName = DICTIONARY_INFO_MODEL.get(idx); selectedDicts.add(dictName); } updateResult(); } void setDictionaryList(final List dictList) { - dictionaryInfoModel.removeAllElements(); - dictionaryInfoModel.addAll(dictList); + DICTIONARY_INFO_MODEL.removeAllElements(); + DICTIONARY_INFO_MODEL.addAll(dictList); selectedDicts.addAll(dictList); } void addToHistory(final String word) { - historyModel.add(0, word); + HISTORY_MODEL.add(0, word); } void updateHeadingsModel(final List wordList) { - headingsModel.removeAllElements(); - headingsModel.addAll(wordList); + HEADINGS_MODEL.removeAllElements(); + HEADINGS_MODEL.addAll(wordList); } public void updateResult(final List result) { diff --git a/src/main/java/io/github/eb4j/ebview/gui/LinkActionListener.java b/src/main/java/io/github/eb4j/ebview/gui/LinkActionListener.java index 7381dd7..670f4b7 100644 --- a/src/main/java/io/github/eb4j/ebview/gui/LinkActionListener.java +++ b/src/main/java/io/github/eb4j/ebview/gui/LinkActionListener.java @@ -14,7 +14,7 @@ public class LinkActionListener implements HyperlinkListener { - private static final String[] movieExts = {".mpg", ".MPG", ".ogv", ".mp4", ".mov"}; + private static final String[] MOVIE_EXTS = {".mpg", ".MPG", ".ogv", ".mp4", ".mov"}; private static boolean hasExt(final String path, final String[] extrn) { return Arrays.stream(extrn).anyMatch(entry -> path.endsWith(entry)); @@ -42,7 +42,7 @@ public void hyperlinkUpdate(final HyperlinkEvent hyperlinkEvent) { String path = url.toURI().getPath(); if (path.endsWith(".wav") || path.endsWith(".WAV")) { playSound(new File(path)); - } else if (hasExt(path, movieExts)) { + } else if (hasExt(path, MOVIE_EXTS)) { MoviePlay player = new MoviePlay(354, 280); player.play(path); } diff --git a/src/main/java/io/github/eb4j/ebview/gui/MainWindow.java b/src/main/java/io/github/eb4j/ebview/gui/MainWindow.java index 94f0801..a31b39e 100644 --- a/src/main/java/io/github/eb4j/ebview/gui/MainWindow.java +++ b/src/main/java/io/github/eb4j/ebview/gui/MainWindow.java @@ -44,14 +44,14 @@ public final class MainWindow extends JFrame implements IMainWindow { private final EBViewerModel ebViewerModel; private static JList dictionaryInfoList; - private static final DictionaryPane dictionaryPane = new DictionaryPane(); + private static final DictionaryPane DICTIONARY_PANE = new DictionaryPane(); - private static final JTextField searchWordField = new JTextField(); + private static final JTextField SEARCH_WORD_FIELD = new JTextField(); private JLabel zoomLevel; private JLabel selectAllDictionary; - JList headingsList; - JList history; + private JList headingsList; + private JList history; public MainWindow(final DictionariesManager dictionariesManager) { super("EBViewer"); @@ -72,11 +72,11 @@ public static void setWindowIcon(final Window window) { public static String getSearchWord() { - return searchWordField.getText(); + return SEARCH_WORD_FIELD.getText(); } public static void setMessage(final String message) { - dictionaryPane.setText(message); + DICTIONARY_PANE.setText(message); } @Override @@ -90,8 +90,8 @@ public JFrame getApplicationFrame() { } public static void updateDictionaryPane(final List entries) { - dictionaryPane.setFoundResult(entries); - dictionaryPane.setCaretPosition(0); + DICTIONARY_PANE.setFoundResult(entries); + DICTIONARY_PANE.setCaretPosition(0); } public static void updateDictionaryList(final int[] indecs) { @@ -111,11 +111,11 @@ private void initializeGUI() { JPanel panel1 = new JPanel(); JLabel zoomLabel = new JLabel("zoom:"); zoomLevel = new JLabel(); - zoomLevel.setText(dictionaryPane.getZoomLevel()); + zoomLevel.setText(DICTIONARY_PANE.getZoomLevel()); panel1.setLayout(new FlowLayout()); - searchWordField.setPreferredSize(new Dimension(500, 30)); + SEARCH_WORD_FIELD.setPreferredSize(new Dimension(500, 30)); searchButton.setText("Search"); - panel1.add(searchWordField); + panel1.add(SEARCH_WORD_FIELD); panel1.add(searchButton); panel1.add(zoomLabel); panel1.add(zoomDownButton); @@ -126,7 +126,7 @@ private void initializeGUI() { JScrollPane headingsPane = new JScrollPane(headingsList); headingsPane.setPreferredSize(new Dimension(140, -1)); // - JScrollPane articlePane = new JScrollPane(dictionaryPane); + JScrollPane articlePane = new JScrollPane(DICTIONARY_PANE); articlePane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); // JPanel infoPanel = new JPanel(); @@ -147,7 +147,7 @@ private void initializeGUI() { getContentPane().add(headingsPane, BorderLayout.WEST); getContentPane().add(articlePane, BorderLayout.CENTER); getContentPane().add(infoPanel, BorderLayout.EAST); - dictionaryPane.setText("Please add dictionaries from Dictionary menu at first."); + DICTIONARY_PANE.setText("Please add dictionaries from Dictionary menu at first."); if (SystemTray.isSupported()) { setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); } else { @@ -161,7 +161,7 @@ private void startSearch() { } private void setActions() { - searchWordField.addActionListener(e -> { + SEARCH_WORD_FIELD.addActionListener(e -> { startSearch(); }); @@ -170,13 +170,13 @@ private void setActions() { }); zoomDownButton.addActionListener(e -> { - dictionaryPane.decreaseZoom(); - zoomLevel.setText(dictionaryPane.getZoomLevel()); + DICTIONARY_PANE.decreaseZoom(); + zoomLevel.setText(DICTIONARY_PANE.getZoomLevel()); }); zoomUpButton.addActionListener(e -> { - dictionaryPane.increaseZoom(); - zoomLevel.setText(dictionaryPane.getZoomLevel()); + DICTIONARY_PANE.increaseZoom(); + zoomLevel.setText(DICTIONARY_PANE.getZoomLevel()); }); headingsList.addListSelectionListener(e -> { @@ -187,7 +187,7 @@ private void setActions() { if (index == -1) { return; } - dictionaryPane.moveTo(index); + DICTIONARY_PANE.moveTo(index); headingsList.clearSelection(); }); @@ -198,7 +198,7 @@ private void setActions() { } Object obj = history.getSelectedValue(); if (obj != null) { - searchWordField.setText(obj.toString()); + SEARCH_WORD_FIELD.setText(obj.toString()); } }); @@ -208,7 +208,7 @@ public void mouseClicked(final MouseEvent me) { if (me.getClickCount() == 2) { Object obj = history.getSelectedValue(); if (obj != null) { - searchWordField.setText(obj.toString()); + SEARCH_WORD_FIELD.setText(obj.toString()); startSearch(); } } @@ -221,7 +221,7 @@ public void keyReleased(final KeyEvent ke) { if (ke.getKeyCode() == KeyEvent.VK_ENTER) { Object obj = history.getSelectedValue(); if (obj != null) { - searchWordField.setText(obj.toString()); + SEARCH_WORD_FIELD.setText(obj.toString()); startSearch(); } } diff --git a/src/main/java/io/github/eb4j/ebview/utils/Stemmer.java b/src/main/java/io/github/eb4j/ebview/utils/Stemmer.java index 506ea14..69e73f1 100644 --- a/src/main/java/io/github/eb4j/ebview/utils/Stemmer.java +++ b/src/main/java/io/github/eb4j/ebview/utils/Stemmer.java @@ -19,19 +19,19 @@ */ public class Stemmer { - public static final String[] EMPTY_STRINGS_LIST = new String[0]; + private static final String[] EMPTY_STRINGS_LIST = new String[0]; public Stemmer() { } - public String[] doStem(String str) { + public String[] doStem(final String str) { if (StringUtils.isBlank(str)) { return EMPTY_STRINGS_LIST; } return tokenizeTextToStringsNoCache(str); } - private static String[] tokenizeTextToStringsNoCache(String str) { + private static String[] tokenizeTextToStringsNoCache(final String str) { if (StringUtils.isBlank(str)) { return EMPTY_STRINGS_LIST; } diff --git a/src/main/java/io/github/eb4j/ebview/utils/WordIterator.java b/src/main/java/io/github/eb4j/ebview/utils/WordIterator.java index 8ea4a30..83a0eca 100644 --- a/src/main/java/io/github/eb4j/ebview/utils/WordIterator.java +++ b/src/main/java/io/github/eb4j/ebview/utils/WordIterator.java @@ -10,8 +10,8 @@ * @author Maxym Mykhalchuk */ public class WordIterator extends BreakIterator { - BreakIterator breaker; - String text; + private final BreakIterator breaker; + private String text; public WordIterator() { breaker = BreakIterator.getWordInstance(); @@ -24,7 +24,7 @@ public WordIterator() { * @param newText * new text to scan. */ - public void setText(String newText) { + public void setText(final String newText) { text = newText; breaker.setText(newText); nextItems.clear(); @@ -41,8 +41,7 @@ public int first() { } /** - * Return character index of the text boundary that was most recently - * returned by next(), previous(), first(), or last() + * Index of the text boundary that was most recently returned by next(), previous(), first(), or last(). * * @return The boundary most recently returned. */ @@ -50,7 +49,7 @@ public int current() { return breaker.current(); } - LinkedList nextItems = new LinkedList<>(); + private final LinkedList nextItems = new LinkedList<>(); /** * Return the boundary of the word following the current boundary. @@ -141,7 +140,7 @@ public int next() { * later boundaries. * @return The index of the nth boundary from the current position. */ - public int next(int n) { + public int next(final int n) { throw new RuntimeException("Not Implemented"); } @@ -159,7 +158,7 @@ public int next(int n) { * cause an IllegalArgumentException to be thrown. * @return The first boundary after the specified offset. */ - public int following(int offset) { + public int following(final int offset) { throw new RuntimeException("Not Implemented"); } @@ -173,7 +172,7 @@ public int following(int offset) { * @param newText * new text to scan. */ - public void setText(java.text.CharacterIterator newText) { + public void setText(final java.text.CharacterIterator newText) { throw new RuntimeException("Not Implemented"); }