OSDN Git Service

ノートコンテンツをwordテーブルに登録しないように変更。
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / Global.java
index 739c45c..f73ea0a 100644 (file)
@@ -53,6 +53,7 @@ import cx.fbn.nevernote.config.StartupConfig;
 import cx.fbn.nevernote.gui.ContainsAttributeFilterTable;
 import cx.fbn.nevernote.gui.DateAttributeFilterTable;
 import cx.fbn.nevernote.gui.ShortcutKeys;
+import cx.fbn.nevernote.sql.driver.NSqlQuery;
 import cx.fbn.nevernote.utilities.ApplicationLogger;
 import cx.fbn.nevernote.utilities.Pair;
 
@@ -2018,27 +2019,27 @@ public class Global {
     }
     
     // If we should automatically wildcard searches
-    public static boolean automaticWildcardSearches() {
-               settings.beginGroup("General");
-               try {
-                       String value = (String)settings.value("automaticWildcard", "false");
-                       settings.endGroup();
-                       if (value.equals("true"))
-                               return true;
-                       else
-                               return false;
-               } catch (java.lang.ClassCastException e) {
-                       Boolean value = (Boolean) settings.value("automaticWildcard", false);
-                       settings.endGroup();
-                       return value;
-               }
-
-    }
-    public static void setAutomaticWildcardSearches(boolean value) {
-               settings.beginGroup("General");
-               settings.setValue("automaticWildcard", value);
-               settings.endGroup();    
-    }
+//    public static boolean automaticWildcardSearches() {
+//             settings.beginGroup("General");
+//             try {
+//                     String value = (String)settings.value("automaticWildcard", "false");
+//                     settings.endGroup();
+//                     if (value.equals("true"))
+//                             return true;
+//                     else
+//                             return false;
+//             } catch (java.lang.ClassCastException e) {
+//                     Boolean value = (Boolean) settings.value("automaticWildcard", false);
+//                     settings.endGroup();
+//                     return value;
+//             }
+//
+//    }
+//    public static void setAutomaticWildcardSearches(boolean value) {
+//             settings.beginGroup("General");
+//             settings.setValue("automaticWildcard", value);
+//             settings.endGroup();    
+//    }
 
     // If we should automatically select the children of any tag
     public static boolean displayRightToLeft() {
@@ -2325,12 +2326,50 @@ public class Global {
        
        // タグを排除してプレーンテキストを抽出
        public static String extractPlainText(String sourceText) {
-               String plainText = sourceText.replaceAll("<.+?>", "");
-               plainText = plainText.replaceAll("\\s{2,}", " ");
+               String plainText = sourceText.replaceAll("<.+?>", "");  // タグを除去
+               plainText = plainText.replaceAll("\\s{2,}", " ");               // 2個以上の空白文字を1文字の空白に変換
                String kaigyo = System.getProperty("line.separator");
-               plainText = plainText.replaceAll(kaigyo, "");
+               plainText = plainText.replaceAll(kaigyo, "");                   // 改行を除去
+//             plainText = plainText.replaceAll("&lt;.+?&gt;", "");    // &lt;で始まり&gt;で終わる文字列を除去
+               
+               // HTML特殊文字のサニタイジングを解除
+               plainText = plainText.replaceAll("&#39;", "'");
+               plainText = plainText.replaceAll("&quot;", "\"");
+               plainText = plainText.replaceAll("&gt;", ">");
+               plainText = plainText.replaceAll("&lt;", "<");
+               plainText = plainText.replaceAll("&amp;", "&");
+               
+               plainText = plainText.replaceAll("&.+?;", "");                  // その他HTML特殊文字があれば除去
                
                return plainText;
        }
+       
+       // 全文検索機能の対象となるテーブルとカラムを再構築
+       public static boolean rebuildFullTextTarget(NSqlQuery query) {
+               StringBuilder noteTableTarget = new StringBuilder();
+               boolean success = true;
+               
+               if (Global.indexNoteBody()) {
+                       noteTableTarget.append("CONTENTTEXT");
+               }
+               if (Global.indexNoteTitle()) {
+                       if (noteTableTarget.length() > 0) {
+                               noteTableTarget.append(", ");
+                       }
+                       noteTableTarget.append("TITLE");
+               }
+               
+               // TODO 他の項目もあとで追加
+               
+               if (noteTableTarget.length() > 0) {
+                       query.prepare("CALL FTL_CREATE_INDEX('PUBLIC', 'NOTE', :column);");
+                       query.bindValue(":column", noteTableTarget.toString());
+                       if (!query.exec()) {
+                               success = false;
+                       }
+               }
+               
+               return success;
+       }
 }