public virtual ICharSequence Escape(ICharSequence text, CultureInfo locale, EscapeQuerySyntax.Type type) { if (text == null || text.Length == 0) return text; // escape wildcards and the escape char (this has to be perform before // anything else) // since we need to preserve the UnescapedCharSequence and escape the // original escape chars if (text is UnescapedCharSequence) { text = ((UnescapedCharSequence)text).ToStringEscaped(wildcardChars); } else { text = new UnescapedCharSequence(text).ToStringEscaped(wildcardChars); } if (type == EscapeQuerySyntax.Type.STRING) { return EscapeQuoted(text, locale); } else { return EscapeTerm(text, locale); } }
// LUCENENET specific overload for text as string public virtual string Escape(string text, CultureInfo locale, EscapeQuerySyntax.Type type) { if (text == null || text.Length == 0) return text; return Escape(text.ToCharSequence(), locale, type).ToString(); }