org.hippoecm.hst.util
Class SearchInputParsingUtils

java.lang.Object
  extended by org.hippoecm.hst.util.SearchInputParsingUtils

public final class SearchInputParsingUtils
extends Object

Input utilities for user searches.


Method Summary
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 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parse

public static String parse(String input,
                           boolean allowSingleNonLeadingWildCardPerTerm)
Returns a parsed version of the input

Parameters:
input - the user input
allowSingleNonLeadingWildCardPerTerm - if there is allowed one wildcard (* or ?) per term (however, still not allowed as leading for a term)
Returns:
the parsed version of the input. When input is null, null is returned

parse

public static String parse(String input,
                           boolean allowSingleNonLeadingWildCardPerTerm,
                           int maxLength)
Returns a parsed version of the input

Parameters:
input - the user input
allowSingleNonLeadingWildCardPerTerm - 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 input
Returns:
the parsed version of the input. When input is null, null is returned

removeLeadingWildCardsFromWords

public static String removeLeadingWildCardsFromWords(String input)

removeInvalidAndEscapeChars

public 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

Parameters:
input -
allowSingleNonLeadingWildCardPerTerm -
Returns:
formatted version of input

removeLeadingOrTrailingOrOperator

public static String removeLeadingOrTrailingOrOperator(String input)
Removes the logical operator "OR" at the end of the query. Otherwise this will result in a Lucene parse exception.

Parameters:
input - the original (possibly invalid) query string
Returns:
a valid query string

compressWhitespace

public static String compressWhitespace(String text)
Compress whitespace (tab, newline, multiple spaces) by removing leading and trailing whitespace, and reducing inbetween whitespace to one space.

Parameters:
text - the text to compress (may be null)
Returns:
the compressed text, or null if the text to compress was null


Copyright © 2008-2012 Hippo. All Rights Reserved.