public String writeToString() { if (text == null || text.isEmpty()) return ""; StringBuilder result = new StringBuilder(); result.append(mode.getCode()); if (caseSensitive) { result.append('C'); } if (regexSearch) { result.append('R'); } if (mapCSSSearch) { result.append('M'); } if (allElements) { result.append('A'); } result.append(' ').append(text); return result.toString(); }
/** * Returns the search mode matching the given character code. * * @param code character code * @return search mode matching the given character code */ public static SearchMode fromCode(char code) { for (SearchMode mode : values()) { if (mode.getCode() == code) return mode; } return null; }