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;
}
// 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() {
// タグを排除してプレーンテキストを抽出
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("<.+?>", ""); // <で始まり>で終わる文字列を除去
+
+ // HTML特殊文字のサニタイジングを解除
+ plainText = plainText.replaceAll("'", "'");
+ plainText = plainText.replaceAll(""", "\"");
+ plainText = plainText.replaceAll(">", ">");
+ plainText = plainText.replaceAll("<", "<");
+ plainText = plainText.replaceAll("&", "&");
+
+ 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;
+ }
}