Found a 30 line (137 tokens) duplication in the following files: Starting at line 224 of /space/home/jsword/build/jsword/src/main/java/org/crosswire/jsword/book/sword/RawLDBackend.java Starting at line 271 of /space/home/jsword/build/jsword/src/main/java/org/crosswire/jsword/book/sword/ZLDBackend.java } /* (non-Javadoc) * @see org.crosswire.jsword.book.sword.AbstractBackend#getRawText(org.crosswire.jsword.passage.Key, java.lang.String) */ /* @Override */ public String getRawText(Key key) throws BookException { checkActive(); String charset = getBookMetaData().getBookCharset(); if (!(key instanceof IndexKey)) { throw new BookException(Msg.BAD_KEY, new Object[] { ClassUtil.getShortClassName(key.getClass()), key.getName() }); } IndexKey ikey = (IndexKey) key; try { byte[] data = SwordUtil.readRAF(datRaf, ikey.offset, ikey.size); int keyend = SwordUtil.findByte(data, SEPARATOR); if (keyend == -1) { throw new BookException(Msg.READ_FAIL); } int remainder = data.length - (keyend + 1); byte[] temp = new byte[remainder]; ===================================================================== Found a 47 line (136 tokens) duplication in the following files: Starting at line 169 of /space/home/jsword/build/bibledesktop/src/main/java/org/crosswire/bibledesktop/display/splitlist/SplitBookDataDisplay.java Starting at line 321 of /space/home/jsword/build/bibledesktop/src/main/java/org/crosswire/bibledesktop/passage/KeySidebar.java setKey(ev.getKey()); } /** * Add a command listener */ public synchronized void addKeyChangeListener(KeyChangeListener listener) { List temp = new ArrayList(2); if (keyChangeListeners != null) { temp.addAll(keyChangeListeners); } if (!temp.contains(listener)) { temp.add(listener); keyChangeListeners = temp; } } /** * Remove a command listener */ public synchronized void removeKeyChangeListener(KeyChangeListener listener) { if (keyChangeListeners != null && keyChangeListeners.contains(listener)) { List temp = new ArrayList(); temp.addAll(keyChangeListeners); temp.remove(listener); keyChangeListeners = temp; } } /** * Inform the command keyChangeListeners */ protected synchronized void fireKeyChanged(KeyChangeEvent ev) { if (keyChangeListeners != null) { for (int i = 0; i < keyChangeListeners.size(); i++) { KeyChangeListener li = (KeyChangeListener) keyChangeListeners.get(i); ===================================================================== Found a 28 line (121 tokens) duplication in the following files: Starting at line 167 of /space/home/jsword/build/jsword/src/main/java/org/crosswire/jsword/book/Books.java Starting at line 78 of /space/home/jsword/build/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBookList.java protected static synchronized void fireBooksChanged(Object source, Book book, boolean added) { // Guaranteed to return a non-null array Object[] contents = listeners.getListenerList(); // Process the listeners last to first, notifying // those that are interested in this event BooksEvent ev = null; for (int i = contents.length - 2; i >= 0; i -= 2) { if (contents[i] == BooksListener.class) { if (ev == null) { ev = new BooksEvent(source, book, added); } if (added) { ((BooksListener) contents[i + 1]).bookAdded(ev); } else { ((BooksListener) contents[i + 1]).bookRemoved(ev); } } } } ===================================================================== Found a 34 line (119 tokens) duplication in the following files: Starting at line 59 of /space/home/jsword/build/common/src/main/java/org/crosswire/common/util/ReflectionUtil.java Starting at line 118 of /space/home/jsword/build/common/src/main/java/org/crosswire/common/util/ReflectionUtil.java Class clazz = Class.forName(className); // The bad news is that we can't use something like: // clazz.getMethod(called_method_name, called_types); // because it does not cope with inheritance (at least in the MVM) // so we have to search ourselves... Method[] testMethods = clazz.getMethods(); outer: for (int i = 0; i < testMethods.length; i++) { // This this the right method name? if (!testMethods[i].getName().equals(methodName)) { continue outer; } // The right number of params Class[] testTypes = testMethods[i].getParameterTypes(); if (testTypes.length != calledTypes.length) { continue; } // Of the right types? for (int j = 0; j < testTypes.length; j++) { if (!testTypes[j].isAssignableFrom(calledTypes[j])) { continue outer; } } // So this is a match return testMethods[i].invoke(null, params); ===================================================================== Found a 18 line (117 tokens) duplication in the following files: Starting at line 193 of /space/home/jsword/build/jsword/src/main/java/org/crosswire/jsword/book/sword/RawLDBackend.java Starting at line 239 of /space/home/jsword/build/jsword/src/main/java/org/crosswire/jsword/book/sword/ZLDBackend.java String keytitle = SwordUtil.decode(keys, keydata, charset).trim(); // for some wierd reason plain text (i.e. SourceType=0) dicts // all get \ added to the ends of the index entries. if (keytitle.endsWith("\\")) //$NON-NLS-1$ { keytitle = keytitle.substring(0, keytitle.length() - 1); } if (isDailyDevotional) { String[] parts = StringUtil.splitAll(keytitle, '.'); greg.set(Calendar.MONTH, Integer.parseInt(parts[0]) - 1); greg.set(Calendar.DATE, Integer.parseInt(parts[1])); keytitle = nameDF.format(greg.getTime()); } Key key = new IndexKey(keytitle, offset, size, keys); ===================================================================== Found a 38 line (111 tokens) duplication in the following files: Starting at line 65 of /space/home/jsword/build/jsword/src/main/java/org/crosswire/jsword/book/filter/osis/OSISFilter.java Starting at line 77 of /space/home/jsword/build/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/THMLFilter.java catch (ParserConfigurationException e) { ex = e; } finally { if (ex != null) { DataPolice.report("Parse failed: " + ex.getMessage() + //$NON-NLS-1$ "\non: " + plain); //$NON-NLS-1$ } // Make sure that other places don't report this problem DataPolice.setKey(null); } if (ex != null) { ele = cleanTags(plain); } if (ele == null) { ele = OSISUtil.factory().createP(); } return ele.removeContent(); } private Element cleanTags(String plain) { // So just try to strip out all XML looking things String shawn = XMLUtil.cleanAllTags(plain); Exception ex = null; try { return parse(shawn); } catch (SAXException e) ===================================================================== Found a 33 line (110 tokens) duplication in the following files: Starting at line 155 of /space/home/jsword/build/common-swing/src/main/java/org/crosswire/common/config/swing/AdvancedConfigEditor.java Starting at line 196 of /space/home/jsword/build/common-swing/src/main/java/org/crosswire/common/config/swing/TreeConfigEditor.java title.setText(obj + " " + Msg.PROPERTIES); //$NON-NLS-1$ // Get the name of the current deck Object[] list = tree.getSelectionPath().getPath(); StringBuffer path = new StringBuffer(); for (int i = 1; i < list.length; i++) { if (i > 1) { path.append("."); //$NON-NLS-1$ } path.append(list[i].toString()); } String key = path.toString(); if (decks.containsKey(key)) { layout.show(deck, key); } else { layout.show(deck, BLANK); } deck.repaint(); } /** * The name of the blank tab */ protected static final String BLANK = "$$BLANK$$"; //$NON-NLS-1$ ===================================================================== Found a 42 line (109 tokens) duplication in the following files: Starting at line 322 of /space/home/jsword/build/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BibleViewPane.java Starting at line 634 of /space/home/jsword/build/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/DisplaySelectPane.java } /** * Add a TitleChangedEvent listener */ public synchronized void addTitleChangedListener(TitleChangedListener li) { listeners.add(TitleChangedListener.class, li); } /** * Remove a TitleChangedEvent listener */ public synchronized void removeTitleChangedListener(TitleChangedListener li) { listeners.remove(TitleChangedListener.class, li); } /** * Listen for changes to the title * @param ev the event to throw */ protected void fireTitleChanged(TitleChangedEvent ev) { // Guaranteed to return a non-null array Object[] contents = listeners.getListenerList(); // Process the listeners last to first, notifying // those that are interested in this event for (int i = contents.length - 2; i >= 0; i -= 2) { if (contents[i] == TitleChangedListener.class) { ((TitleChangedListener) contents[i + 1]).titleChanged(ev); } } } /** * Add a DisplaySelectEvent listener */ public synchronized void addCommandListener(DisplaySelectListener li) ===================================================================== Found a 16 line (103 tokens) duplication in the following files: Starting at line 63 of /space/home/jsword/build/common-swing/src/main/java/org/crosswire/common/config/swing/PathField.java Starting at line 65 of /space/home/jsword/build/common-swing/src/main/java/org/crosswire/common/config/swing/StringArrayField.java list = new JList(list_model); JPanel buttons = new JPanel(new FlowLayout()); list.setFont(new Font("Monospaced", Font.PLAIN, 12)); //$NON-NLS-1$ list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // list.setPreferredScrollableViewportSize(new Dimension(30, 100)); JScrollPane scroll = new JScrollPane(); scroll.setViewportView(list); buttons.add(new JButton(actions.getAction(ADD))); buttons.add(new JButton(actions.getAction(REMOVE))); buttons.add(new JButton(actions.getAction(UPDATE))); Border title = BorderFactory.createTitledBorder(Msg.COMPONENT_EDITOR.toString());