// Path: src/main/java/com/civilizer/utils/Pair.java
// public final class Pair<A, B> {
// 	
//     private final A first;
//     private final B second;
// 
//     public Pair(A first, B second) {
//     	this.first = first;
//     	this.second = second;
//     }
// 
//     public int hashCode() {
//     	int hashFirst = first != null ? first.hashCode() : 0;
//     	int hashSecond = second != null ? second.hashCode() : 0;
// 
//     	return (hashFirst + hashSecond) * hashSecond + hashFirst;
//     }
// 
//     public boolean equals(Object other) {
//     	if (other instanceof Pair) {
//     		Pair<?, ?> otherPair = (Pair<?, ?>) other;
//     		return 
//     		((  this.first == otherPair.first ||
//     			( this.first != null && otherPair.first != null &&
//     			  this.first.equals(otherPair.first))) &&
//     		 (	this.second == otherPair.second ||
//     			( this.second != null && otherPair.second != null &&
//     			  this.second.equals(otherPair.second))) );
//     	}
// 
//     	return false;
//     }
// 
//     public String toString()
//     { 
//            return "(" + first + ", " + second + ")"; 
//     }
// 
//     public A getFirst() {
//     	return first;
//     }
// 
//     public B getSecond() {
//     	return second;
//     }
//     
// }


import java.io.Serializable;
import java.util.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import com.civilizer.utils.Pair;
			if (word.startsWith("\"") && word.endsWith("\"")) {
				// [RULE] "..." treats phrases containing spaces as a single unit
			    // Also any flag or directive inside the quotes will be treated as normal trivial characters
				if (word.length() > 1) {
					word = word.substring(1, word.length() - 1);
				}
			}
			
			if (beginningWith && endingWith)
				wholeWord = true;
			if (wholeWord)
			    beginningWith = endingWith = true;
			if (regex) {
			    // 'r' flag assumes case sensitivity regardless of the value of 'c' flag
			    caseSensitive = true;
			    // also 'r' flag ignores other pattern matching flags
			    wholeWord = beginningWith = endingWith = false;
			}
			
			this.word = word;
			this.caseSensitive = caseSensitive;
			this.wholeWord = wholeWord;
			this.beginningWith = beginningWith;
			this.endingWith = endingWith;
			this.regex = regex;
			this.inverse = inverse;
			this.id = id;
			this.tagHeirarchy = tagHeirarchy;
		}
		
// Path: src/main/java/com/civilizer/utils/Pair.java
// public final class Pair<A, B> {
// 	
//     private final A first;
//     private final B second;
// 
//     public Pair(A first, B second) {
//     	this.first = first;
//     	this.second = second;
//     }
// 
//     public int hashCode() {
//     	int hashFirst = first != null ? first.hashCode() : 0;
//     	int hashSecond = second != null ? second.hashCode() : 0;
// 
//     	return (hashFirst + hashSecond) * hashSecond + hashFirst;
//     }
// 
//     public boolean equals(Object other) {
//     	if (other instanceof Pair) {
//     		Pair<?, ?> otherPair = (Pair<?, ?>) other;
//     		return 
//     		((  this.first == otherPair.first ||
//     			( this.first != null && otherPair.first != null &&
//     			  this.first.equals(otherPair.first))) &&
//     		 (	this.second == otherPair.second ||
//     			( this.second != null && otherPair.second != null &&
//     			  this.second.equals(otherPair.second))) );
//     	}
// 
//     	return false;
//     }
// 
//     public String toString()
//     { 
//            return "(" + first + ", " + second + ")"; 
//     }
// 
//     public A getFirst() {
//     	return first;
//     }
// 
//     public B getSecond() {
//     	return second;
//     }
//     
// }


// Path: src/main/java/com/civilizer/domain/SearchParams.java
import java.io.Serializable;
import java.util.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import com.civilizer.utils.Pair;

			if (word.startsWith("\"") && word.endsWith("\"")) {
				// [RULE] "..." treats phrases containing spaces as a single unit
			    // Also any flag or directive inside the quotes will be treated as normal trivial characters
				if (word.length() > 1) {
					word = word.substring(1, word.length() - 1);
				}
			}
			
			if (beginningWith && endingWith)
				wholeWord = true;
			if (wholeWord)
			    beginningWith = endingWith = true;
			if (regex) {
			    // 'r' flag assumes case sensitivity regardless of the value of 'c' flag
			    caseSensitive = true;
			    // also 'r' flag ignores other pattern matching flags
			    wholeWord = beginningWith = endingWith = false;
			}
			
			this.word = word;
			this.caseSensitive = caseSensitive;
			this.wholeWord = wholeWord;
			this.beginningWith = beginningWith;
			this.endingWith = endingWith;
			this.regex = regex;
			this.inverse = inverse;
			this.id = id;
			this.tagHeirarchy = tagHeirarchy;
		}
		
		public static Pair<String, Character> escapeSqlWildcardCharacters(String word) {