public final class SearchInputParsingUtils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
compressWhitespace(String text)
Compress whitespace (tab, newline, multiple spaces) by removing leading and trailing whitespace, and reducing
inbetween whitespace to one space.
|
static boolean |
isSpecialChar(char c) |
static String |
parse(String input,
boolean allowSingleNonLeadingWildCardPerTerm)
Returns a parsed version of the input
|
static String |
parse(String input,
boolean allowSingleNonLeadingWildCardPerTerm,
int maxLength)
Returns a parsed version of the input
|
static String |
removeInvalidAndEscapeChars(String input,
boolean allowSingleNonLeadingWildCardPerTerm)
Removes invalid chars, escapes some chars.
|
static String |
removeLeadingOrTrailingOrOperator(String input)
Removes the logical operator "OR" at the end of the query.
|
static String |
removeLeadingWildCardsFromWords(String input) |
public static String parse(String input, boolean allowSingleNonLeadingWildCardPerTerm)
input
- the user inputallowSingleNonLeadingWildCardPerTerm
- if there is allowed one wildcard (* or ?) per term (however, still not allowed as leading for a term)input
. When input
is null
, null
is returnedpublic static String parse(String input, boolean allowSingleNonLeadingWildCardPerTerm, int maxLength)
input
- the user inputallowSingleNonLeadingWildCardPerTerm
- if there is allowed one wildcard (* or ?) per term (however, still not allowed as leading for a term)maxLength
- the maxLength of the returned parsed inputinput
. When input
is null
, null
is returnedpublic static String removeInvalidAndEscapeChars(String input, boolean allowSingleNonLeadingWildCardPerTerm)
Removes invalid chars, escapes some chars. If allowSingleNonLeadingWildCard
is true
, there
is one single non leading *
or ?
allowed. Note, that this wildcard is not allowed to be
leading of a new word.
Recommended is to remove all wildcards
input
- allowSingleNonLeadingWildCardPerTerm
- input
public static boolean isSpecialChar(char c)
public static String removeLeadingOrTrailingOrOperator(String input)
input
- the original (possibly invalid) query stringpublic static String compressWhitespace(String text)
text
- the text to compress (may be null)Copyright © 2008-2013 Hippo B.V. (http://www.onehippo.com). All Rights Reserved.