19 package org.sleuthkit.autopsy.keywordsearch;
21 import java.awt.Component;
23 import java.util.logging.Level;
25 import javax.swing.JOptionPane;
30 class KeywordSearchUtil {
46 public static String quoteQuery(String query) {
48 final int length = query.length();
49 if (length > 1 && query.charAt(0) ==
'"'
50 && query.charAt(length - 1) ==
'"') {
54 StringBuilder sb =
new StringBuilder();
55 sb.append(
"\"").append(query).append(
"\"");
67 public static String escapeLuceneQuery(String query) {
68 String queryEscaped = null;
69 String inputString = query.trim();
71 if (inputString.length() == 0) {
75 final String ESCAPE_CHARS =
"/+-&|!(){}[]^\"~*?:\\";
76 StringBuilder sb =
new StringBuilder();
77 final int length = inputString.length();
80 boolean quotedQuery =
false;
81 if (length > 1 && inputString.charAt(0) ==
'"' && inputString.charAt(length - 1) ==
'"') {
85 for (
int i = 0; i < length; ++i) {
86 final char c = inputString.charAt(i);
88 if (ESCAPE_CHARS.contains(Character.toString(c))) {
90 if (quotedQuery ==
false || (i > 0 && i < length - 1)) {
96 queryEscaped = inputString = sb.toString();
102 public static void displayDialog(
final String title,
final String message,
final DIALOG_MESSAGE_TYPE type) {
104 if (type == DIALOG_MESSAGE_TYPE.ERROR) {
105 messageType = JOptionPane.ERROR_MESSAGE;
106 }
else if (type == DIALOG_MESSAGE_TYPE.WARN) {
107 messageType = JOptionPane.WARNING_MESSAGE;
109 messageType = JOptionPane.INFORMATION_MESSAGE;
112 final Component parentComponent = null;
113 JOptionPane.showMessageDialog(
120 public static boolean displayConfirmDialog(
final String title,
final String message,
final DIALOG_MESSAGE_TYPE type) {
122 if (type == DIALOG_MESSAGE_TYPE.ERROR) {
123 messageType = JOptionPane.ERROR_MESSAGE;
124 }
else if (type == DIALOG_MESSAGE_TYPE.WARN) {
125 messageType = JOptionPane.WARNING_MESSAGE;
127 messageType = JOptionPane.INFORMATION_MESSAGE;
129 if (JOptionPane.showConfirmDialog(null, message, title, JOptionPane.YES_NO_OPTION, messageType) == JOptionPane.YES_OPTION) {
142 static boolean isXMLList(String absPath) {
144 return new File(absPath).getName().endsWith(
".xml");
static Logger getLogger(String name)