[jsword-svn] r1949 - in trunk: bibledesktop/src/main/java/org/crosswire/bibledesktop/book common/src/main/java/org/crosswire/common/config common/src/main/java/org/crosswire/common/options common/src/main/java/org/crosswire/common/util common/src/main/java/org/crosswire/common/xml jsword/src/main/java/org/crosswire/jsword/book jsword/src/main/java/org/crosswire/jsword/book/basic jsword/src/main/java/org/crosswire/jsword/book/filter jsword/src/main/java/org/crosswire/jsword/book/filter/thml jsword/src/main/java/org/crosswire/jsword/book/install jsword/src/main/java/org/crosswire/jsword/book/sword jsword/src/main/java/org/crosswire/jsword/index/lucene jsword/src/main/java/org/crosswire/jsword/passage jsword-web
dmsmith at crosswire.org
dmsmith at crosswire.org
Sat Oct 3 10:49:52 MST 2009
Author: dmsmith
Date: 2009-10-03 10:49:52 -0700 (Sat, 03 Oct 2009)
New Revision: 1949
Modified:
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BooksComboBoxModel.java
trunk/common/src/main/java/org/crosswire/common/config/ConfigEvent.java
trunk/common/src/main/java/org/crosswire/common/options/GetOptions.java
trunk/common/src/main/java/org/crosswire/common/util/CWProject.java
trunk/common/src/main/java/org/crosswire/common/util/CallContext.java
trunk/common/src/main/java/org/crosswire/common/util/IOUtil.java
trunk/common/src/main/java/org/crosswire/common/util/Logger.java
trunk/common/src/main/java/org/crosswire/common/util/NetUtil.java
trunk/common/src/main/java/org/crosswire/common/xml/XMLUtil.java
trunk/jsword-web/build.xml
trunk/jsword/src/main/java/org/crosswire/jsword/book/BooksEvent.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBook.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractPassageBook.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/FilterFactory.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/CustomHandler.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/THMLFilter.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/install/InstallerEvent.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookPath.java
trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndex.java
trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndexManager.java
trunk/jsword/src/main/java/org/crosswire/jsword/passage/SetKeyList.java
Log:
Fixed CheckStyle and FindBugs warnings.
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BooksComboBoxModel.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BooksComboBoxModel.java 2009-10-03 14:57:20 UTC (rev 1948)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BooksComboBoxModel.java 2009-10-03 17:49:52 UTC (rev 1949)
@@ -86,7 +86,7 @@
{
if (book != null)
{
- int i = books.indexOf(book);
+ int i = getIndexOf(book);
if (i != -1)
{
current = book;
Modified: trunk/common/src/main/java/org/crosswire/common/config/ConfigEvent.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/config/ConfigEvent.java 2009-10-03 14:57:20 UTC (rev 1948)
+++ trunk/common/src/main/java/org/crosswire/common/config/ConfigEvent.java 2009-10-03 17:49:52 UTC (rev 1949)
@@ -21,6 +21,8 @@
*/
package org.crosswire.common.config;
+import java.io.IOException;
+import java.io.ObjectInputStream;
import java.util.EventObject;
/**
@@ -72,6 +74,20 @@
}
/**
+ * Serialization support.
+ *
+ * @param is
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException
+ {
+ // Broken but we don't serialize events
+ model = null;
+ is.defaultReadObject();
+ }
+
+ /**
* The name of the choice
*/
private String key;
Modified: trunk/common/src/main/java/org/crosswire/common/options/GetOptions.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/options/GetOptions.java 2009-10-03 14:57:20 UTC (rev 1948)
+++ trunk/common/src/main/java/org/crosswire/common/options/GetOptions.java 2009-10-03 17:49:52 UTC (rev 1949)
@@ -103,8 +103,10 @@
private void parse()
{
int nargs = args.length;
- for (int i = 0; i < nargs; i++)
+ int skip = 0;
+ for (int i = 0; i < nargs; i += 1 + skip)
{
+ skip = 0;
String nextArg = args[i];
// All options are 2 or more characters long and begin with a '-'.
// If this is a non-option then note it and advance
@@ -163,7 +165,8 @@
if (i + 1 < nargs)
{
// Add option with following argument to options
- String argument = args[i++];
+ String argument = args[i];
+ skip = 1;
suppliedOptions.put(option, argument);
continue;
}
@@ -203,7 +206,8 @@
if (i + 1 < nargs)
{
// Add option with following argument to options
- String argument = args[i++];
+ String argument = args[i];
+ skip = 1;
suppliedOptions.put(option, argument);
continue;
}
Modified: trunk/common/src/main/java/org/crosswire/common/util/CWProject.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/util/CWProject.java 2009-10-03 14:57:20 UTC (rev 1948)
+++ trunk/common/src/main/java/org/crosswire/common/util/CWProject.java 2009-10-03 17:49:52 UTC (rev 1949)
@@ -247,14 +247,17 @@
File oldDir = new File(oldPath.getPath());
File newDir = new File(newPath.getPath());
- // This will return false if it could not rename.
+ // renameTo will return false if it could not rename.
// This will happen if the directory already exists.
- oldDir.renameTo(newDir);
- if (NetUtil.isDirectory(newPath))
+ // So ensure that the directory does not currently exist.
+ if (!NetUtil.isDirectory(newPath))
{
- return newPath;
+ if (oldDir.renameTo(newDir))
+ {
+ return newPath;
+ }
+ return oldPath;
}
- return oldPath;
}
return newPath;
}
Modified: trunk/common/src/main/java/org/crosswire/common/util/CallContext.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/util/CallContext.java 2009-10-03 14:57:20 UTC (rev 1948)
+++ trunk/common/src/main/java/org/crosswire/common/util/CallContext.java 2009-10-03 17:49:52 UTC (rev 1949)
@@ -99,5 +99,5 @@
*/
private static final int CALL_CONTEXT_OFFSET = 3;
- private static CallContext resolver;
+ private static volatile CallContext resolver;
}
Modified: trunk/common/src/main/java/org/crosswire/common/util/IOUtil.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/util/IOUtil.java 2009-10-03 14:57:20 UTC (rev 1948)
+++ trunk/common/src/main/java/org/crosswire/common/util/IOUtil.java 2009-10-03 17:49:52 UTC (rev 1949)
@@ -71,10 +71,8 @@
// Is it already a directory ?
if (!parentDir.isDirectory())
{
- parentDir.mkdirs();
-
- // Did that work?
- if (!parentDir.isDirectory())
+ // Create the directory and make sure it worked.
+ if (!parentDir.mkdirs())
{
throw new MalformedURLException(UserMsg.CREATE_DIR_FAIL.toString(parentDir.toString()));
}
Modified: trunk/common/src/main/java/org/crosswire/common/util/Logger.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/util/Logger.java 2009-10-03 14:57:20 UTC (rev 1948)
+++ trunk/common/src/main/java/org/crosswire/common/util/Logger.java 2009-10-03 17:49:52 UTC (rev 1949)
@@ -231,7 +231,7 @@
private static final String ROOT_LOGGER = ""; //$NON-NLS-1$
private static final String CLASS_NAME = Logger.class.getName();
- private static Level level;
+ private static volatile Level level;
private java.util.logging.Logger logger;
}
Modified: trunk/common/src/main/java/org/crosswire/common/util/NetUtil.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/util/NetUtil.java 2009-10-03 14:57:20 UTC (rev 1948)
+++ trunk/common/src/main/java/org/crosswire/common/util/NetUtil.java 2009-10-03 17:49:52 UTC (rev 1949)
@@ -141,10 +141,8 @@
// Is it already a directory ?
if (!file.isDirectory())
{
- file.mkdirs();
-
- // Did that work?
- if (!file.isDirectory())
+ // Create the directory and make sure it worked.
+ if (!file.mkdirs())
{
throw new MalformedURLException(UserMsg.CREATE_DIR_FAIL.toString(orig));
}
Modified: trunk/common/src/main/java/org/crosswire/common/xml/XMLUtil.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/xml/XMLUtil.java 2009-10-03 14:57:20 UTC (rev 1948)
+++ trunk/common/src/main/java/org/crosswire/common/xml/XMLUtil.java 2009-10-03 17:49:52 UTC (rev 1949)
@@ -259,7 +259,7 @@
* @param broken the string to be cleaned
* @return the cleaned string
*/
- public static String closeEmptyTags(String broken)
+ public static String closeEmptyTags(String broken)
{
if (broken == null)
{
@@ -506,7 +506,7 @@
* Valid are: #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
*/
private static Pattern invalidCharacterPattern = Pattern.compile("[^\t\r\n\u0020-\uD7FF\uE000-\uFFFD]"); //$NON-NLS-1$
-
+
/**
* Pattern that matches open <br>,<hr> and <img> tags.
*/
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/BooksEvent.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/BooksEvent.java 2009-10-03 14:57:20 UTC (rev 1948)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/BooksEvent.java 2009-10-03 17:49:52 UTC (rev 1949)
@@ -21,6 +21,8 @@
*/
package org.crosswire.jsword.book;
+import java.io.IOException;
+import java.io.ObjectInputStream;
import java.util.EventObject;
/**
@@ -64,6 +66,20 @@
}
/**
+ * Serialization support.
+ *
+ * @param is
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException
+ {
+ // Broken but we don't serialize events
+ book = null;
+ is.defaultReadObject();
+ }
+
+ /**
* Is this an addition event?
*/
private boolean added;
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBook.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBook.java 2009-10-03 14:57:20 UTC (rev 1948)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractBook.java 2009-10-03 17:49:52 UTC (rev 1949)
@@ -324,11 +324,13 @@
{
key = key.get(0);
}
-
+
getRawText(key);
return true;
- } catch (Exception ex) {
+ }
+ catch (Exception ex)
+ {
return false;
}
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractPassageBook.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractPassageBook.java 2009-10-03 14:57:20 UTC (rev 1948)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/AbstractPassageBook.java 2009-10-03 17:49:52 UTC (rev 1949)
@@ -167,7 +167,7 @@
{
Element overse = (Element) data;
String text = OSISUtil.getPlainText(overse);
-
+
setRawText(key, text);
}
else
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/FilterFactory.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/FilterFactory.java 2009-10-03 14:57:20 UTC (rev 1948)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/FilterFactory.java 2009-10-03 17:49:52 UTC (rev 1949)
@@ -57,7 +57,7 @@
/**
* The lookup table of filters
*/
- private static Filter deft;
+ private static volatile Filter deft;
/**
* Populate the lookup table of filters and the default from the properties
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/CustomHandler.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/CustomHandler.java 2009-10-03 14:57:20 UTC (rev 1948)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/CustomHandler.java 2009-10-03 17:49:52 UTC (rev 1949)
@@ -74,16 +74,16 @@
{
Object top = stack.getFirst();
+ // If the element and its descendants are to be ignored
+ // then there is a null element on the stack
+ if (top == null)
+ {
+ return;
+ }
+
if (top instanceof Element) // It might be a text element
{
ele = (Element) top;
-
- // If the element and its descendants are to be ignored
- // then there is a null element on the stack
- if (ele == null)
- {
- return;
- }
}
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/THMLFilter.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/THMLFilter.java 2009-10-03 14:57:20 UTC (rev 1948)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/filter/thml/THMLFilter.java 2009-10-03 17:49:52 UTC (rev 1949)
@@ -124,7 +124,7 @@
String clean = XMLUtil.cleanAllCharacters(plain);
Element ele = parse(book, key, clean, "cleaning text"); //$NON-NLS-1$
- if (ele == null)
+ if (ele == null)
{
ele = parse(book, key, XMLUtil.closeEmptyTags(clean), "closing empty tags"); //$NON-NLS-1$
}
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/install/InstallerEvent.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/install/InstallerEvent.java 2009-10-03 14:57:20 UTC (rev 1948)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/install/InstallerEvent.java 2009-10-03 17:49:52 UTC (rev 1949)
@@ -21,6 +21,8 @@
*/
package org.crosswire.jsword.book.install;
+import java.io.IOException;
+import java.io.ObjectInputStream;
import java.util.EventObject;
/**
@@ -64,6 +66,20 @@
}
/**
+ * Serialization support.
+ *
+ * @param is
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException
+ {
+ // Broken but we don't serialize events
+ installer = null;
+ is.defaultReadObject();
+ }
+
+ /**
* Is this an addition event?
*/
private boolean added;
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookPath.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookPath.java 2009-10-03 14:57:20 UTC (rev 1948)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookPath.java 2009-10-03 17:49:52 UTC (rev 1949)
@@ -371,10 +371,11 @@
return true;
}
+ // make sure the parent exists
File parent = newPath.getParentFile();
- if (!parent.exists())
+ if (!parent.exists() && !parent.mkdirs())
{
- parent.mkdirs();
+ return false;
}
return oldPath.renameTo(newPath);
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndex.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndex.java 2009-10-03 14:57:20 UTC (rev 1948)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndex.java 2009-10-03 17:49:52 UTC (rev 1949)
@@ -192,7 +192,10 @@
job.setCancelable(false);
if (!job.isFinished())
{
- tempPath.renameTo(finalPath);
+ if (!tempPath.renameTo(finalPath))
+ {
+ throw new BookException(UserMsg.INSTALL_FAIL);
+ }
}
if (finalPath.exists())
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndexManager.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndexManager.java 2009-10-03 14:57:20 UTC (rev 1948)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndexManager.java 2009-10-03 17:49:52 UTC (rev 1949)
@@ -164,7 +164,10 @@
String finalCanonicalPath = storage.getCanonicalPath();
tempPath = new File(finalCanonicalPath + '.' + IndexStatus.CREATING.toString());
FileUtil.delete(tempPath);
- storage.renameTo(tempPath);
+ if (!storage.renameTo(tempPath))
+ {
+ throw new BookException(UserMsg.DELETE_FAILED);
+ }
book.setIndexStatus(IndexStatus.UNDONE);
}
catch (IOException ex)
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/passage/SetKeyList.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/passage/SetKeyList.java 2009-10-03 14:57:20 UTC (rev 1948)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/passage/SetKeyList.java 2009-10-03 17:49:52 UTC (rev 1949)
@@ -102,7 +102,12 @@
/* @Override */
public boolean equals(Object obj)
{
- return list.equals(obj);
+ if (obj instanceof SetKeyList)
+ {
+ SetKeyList that = (SetKeyList) obj;
+ return list.equals(that.list);
+ }
+ return false;
}
/* (non-Javadoc)
Modified: trunk/jsword-web/build.xml
===================================================================
--- trunk/jsword-web/build.xml 2009-10-03 14:57:20 UTC (rev 1948)
+++ trunk/jsword-web/build.xml 2009-10-03 17:49:52 UTC (rev 1949)
@@ -78,10 +78,8 @@
</javadoc>
</target>
- <!--=======================================================================
- Note: java is dumping in native code while executing java2html
- <target name="tools" depends="java2html,checkstyle,javancss,findbugs,pmd,cpd,jdepend"/> -->
- <target name="tools" depends="checkstyle,javancss,findbugs,pmd,cpd,jdepend"/>
+ <!--=======================================================================-->
+ <target name="tools" depends="java2html,checkstyle,javancss,findbugs,pmd,cpd,jdepend"/>
<!--=======================================================================-->
<target name="install"
More information about the jsword-svn
mailing list