OSDN Git Service

- Added the ability to do special refreshes for debugging. - Added the ability to...
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / threads / IndexRunner.java
index b17fe94..d5fb25c 100644 (file)
@@ -74,6 +74,10 @@ public class IndexRunner extends QObject implements Runnable {
        public boolean                                          keepRunning;\r
        private final QDomDocument                      doc;\r
        private static String                           regex = Global.getWordRegex();\r
+       public String                                           specialIndexCharacters = "";\r
+       public boolean                                          indexNoteBody = true;\r
+       public boolean                                          indexNoteTitle = true;\r
+       public boolean                                          indexImageRecognition = true;\r
        private final DatabaseConnection        conn;\r
        private volatile LinkedBlockingQueue<String> workQueue;\r
        private static int MAX_QUEUED_WAITING = 1000;\r
@@ -164,14 +168,21 @@ public class IndexRunner extends QObject implements Runnable {
                \r
                logger.log(logger.EXTREME, "Getting note content");\r
                Note n = conn.getNoteTable().getNote(guid,true,false,true,true, true);\r
-               String data = n.getContent();\r
-               data = conn.getNoteTable().getNoteContentNoUTFConversion(n.getGuid());\r
+               String data;\r
+               if (indexNoteBody) {\r
+                       data = n.getContent();\r
+                       data = conn.getNoteTable().getNoteContentNoUTFConversion(n.getGuid());\r
                \r
-               logger.log(logger.EXTREME, "Removing any encrypted data");\r
-               data = removeEnCrypt(data.toString());\r
-               logger.log(logger.EXTREME, "Removing xml markups");\r
-               String text =  removeTags(StringEscapeUtils.unescapeHtml(data) +" "+\r
-               n.getTitle());\r
+                       logger.log(logger.EXTREME, "Removing any encrypted data");\r
+                       data = removeEnCrypt(data.toString());\r
+                       logger.log(logger.EXTREME, "Removing xml markups");\r
+               } else\r
+                       data = "";\r
+               String text;\r
+               if (indexNoteTitle)\r
+                       text =  removeTags(StringEscapeUtils.unescapeHtml(data) +" "+ n.getTitle());\r
+               else\r
+                       text = removeTags(StringEscapeUtils.unescapeHtml(data));\r
                                \r
                logger.log(logger.EXTREME, "Splitting words");\r
                String[] result = text.toString().split(regex);\r
@@ -235,7 +246,10 @@ public class IndexRunner extends QObject implements Runnable {
                        return;\r
                foundWords.clear();\r
                Resource r = conn.getNoteTable().noteResourceTable.getNoteResourceRecognition(guid);\r
-               if (r == null || r.getRecognition() == null || r.getRecognition().getBody() == null || r.getRecognition().getBody().length == 0) \r
+               if (!indexImageRecognition || \r
+                               r == null || r.getRecognition() == null || \r
+                               r.getRecognition().getBody() == null || \r
+                               r.getRecognition().getBody().length == 0) \r
                        resourceBinary = new QByteArray(" ");\r
                else\r
                        resourceBinary = new QByteArray(r.getRecognition().getBody());\r
@@ -605,7 +619,7 @@ public class IndexRunner extends QObject implements Runnable {
                        return;\r
                StringBuffer buffer = new StringBuffer(word.toLowerCase());\r
                for (int i=buffer.length()-1; i>=0; i--) {\r
-                       if (!Character.isLetterOrDigit(buffer.charAt(i)))\r
+                       if (!Character.isLetterOrDigit(buffer.charAt(i)) && specialIndexCharacters.indexOf(buffer.charAt(i)) == -1)\r
                                buffer.deleteCharAt(i);\r
                        else\r
                                break;\r