com.arsdigita.cms
Class SearchFormatter

java.lang.Object
  extended bycom.arsdigita.cms.SearchFormatter

public class SearchFormatter
extends Object

Contains utility methods which are useful for constructing search queries

Version:
$Id: //cms/dev/src/com/arsdigita/cms/SearchFormatter.java#5 $
Author:
Stanislav Freidin (sfreidin@arsdigita.com)

Field Summary
static String AND
          An "and" join clause
static String[] COMMON_WORDS
          A list of common words which will be filtered out
static String OR
          An "or" join clause
static String SPECIAL_CHARS
          A list of all the special characters which will be filtered out
static String versionId
           
static String WILD_CARD
          An Intermedia wildcard that matches any sequence of characters
 
Constructor Summary
SearchFormatter()
           
 
Method Summary
static String createIntermediaClause(String words)
          Convert some keywords which are typed in by the user to an Intermedia search clause.
static String createIntermediaClause(String words, String joinClause, String wildcard)
          Convert some keywords which are typed in by the user to an Intermedia search clause.
 boolean isCommonWord(String s)
          Determine if the string represents a common word.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values

SPECIAL_CHARS

public static final String SPECIAL_CHARS
A list of all the special characters which will be filtered out

See Also:
Constant Field Values

COMMON_WORDS

public static final String[] COMMON_WORDS
A list of common words which will be filtered out


WILD_CARD

public static final String WILD_CARD
An Intermedia wildcard that matches any sequence of characters

See Also:
Constant Field Values

AND

public static final String AND
An "and" join clause

See Also:
Constant Field Values

OR

public static final String OR
An "or" join clause

See Also:
Constant Field Values
Constructor Detail

SearchFormatter

public SearchFormatter()
Method Detail

isCommonWord

public boolean isCommonWord(String s)
Determine if the string represents a common word. Common words, such as "the", "of", etc., should not be included in search clauses.

Parameters:
s - a search keyword
Returns:
true if s is a common word, false otherwise

createIntermediaClause

public static String createIntermediaClause(String words)
Convert some keywords which are typed in by the user to an Intermedia search clause. Clean out all the special characters, and remove common words. Surround each word with the '%' wildcard. For example, the search string "cat, fish and bird" will be converted to "%cat% and %fish% and %bird%"

Parameters:
words - a string which contains some search keywords

createIntermediaClause

public static String createIntermediaClause(String words,
                                            String joinClause,
                                            String wildcard)
Convert some keywords which are typed in by the user to an Intermedia search clause. Clean out all the special characters, and remove common words. Surround each word with the '%' wildcard. For example, the search string "cat, fish and bird" will be converted to "%cat% and %fish% and %bird%"

Parameters:
words - a string which contains some search keywords
joinClause - a string which will be used to combine the keywords. Should be "and", "or", or a similar boolean operator.
wildcard - a wildcard which will be appened to the right and to the left of each keyword


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 19 2004:2352 UTC