com.gisgraphy.helper
Class StringHelper

java.lang.Object
  extended by com.gisgraphy.helper.StringHelper

public class StringHelper
extends Object

Provide some usefull method to copute strinfg for autocompletion and fulltextsearch

Author:
David Masclet

Field Summary
protected static org.slf4j.Logger logger
           
static int MAX_STRING_INDEXABLE_LENGTH
           
static char WHITESPACE_CHAR_DELIMITER
           
 
Constructor Summary
StringHelper()
           
 
Method Summary
static String getStackTraceAsString(Throwable aThrowable)
           
static boolean isEmptyString(String string)
          Usefull method to be compatible with jdk1.5 (jdk 1.6 already have this method)
static boolean isNotEmptyString(String string)
          Usefull method to be compatible with jdk1.5 (jdk 1.6 already have this method)
static String normalize(String originalString)
          Process a string to apply filter as lucene and solr does : - remove accent - lowercase - word delimiter ('-', '.'
static String splitCamelCase(String s)
           
static String transformStringForPartialWordIndexation(String originalString, char delimiter)
          Process a string to in order to be stored in a specific postgres field to allow the index usage for ilike (ilike(%String%): e.g : 'it s ok'=> s ok, s o, it s, t s o, t s, it s ok, ok, it s o, it, t s ok it remove duplicates and don't put single character.
static String transformStringForPartialWordSearch(String originalString, char delimiter)
           
static OpenStreetMap updateOpenStreetMapEntityForIndexation(OpenStreetMap openStreetMap)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_STRING_INDEXABLE_LENGTH

public static final int MAX_STRING_INDEXABLE_LENGTH
See Also:
Constant Field Values

WHITESPACE_CHAR_DELIMITER

public static final char WHITESPACE_CHAR_DELIMITER
See Also:
Constant Field Values

logger

protected static final org.slf4j.Logger logger
Constructor Detail

StringHelper

public StringHelper()
Method Detail

normalize

public static final String normalize(String originalString)
Process a string to apply filter as lucene and solr does : - remove accent - lowercase - word delimiter ('-', '.'

Parameters:
originalString - the string to process
Returns:
the transformed String or null if the original String is null

transformStringForPartialWordIndexation

public static final String transformStringForPartialWordIndexation(String originalString,
                                                                   char delimiter)
Process a string to in order to be stored in a specific postgres field to allow the index usage for ilike (ilike(%String%): e.g : 'it s ok'=> s ok, s o, it s, t s o, t s, it s ok, ok, it s o, it, t s ok it remove duplicates and don't put single character.

Parameters:
originalString - the string to process
delimiter - words will be delimited by this char (it should be the same as the one in transformStringForPartialWordSearch(String, char). For gisgraphy the char is WHITESPACE_CHAR_DELIMITER IMPORTANT NOTE : if the string is greater than MAX_STRING_INDEXABLE_LENGTH, the method will return null;
Returns:
the transformed String (or null if the original String is null) to be used by the postgres function to_ts_vector
See Also:
transformStringForPartialWordSearch(String, char)

transformStringForPartialWordSearch

public static final String transformStringForPartialWordSearch(String originalString,
                                                               char delimiter)
Parameters:
originalString - the string to transform
delimiter - the delimiter (it should be the same as the one use in transformStringForPartialWordIndexation(String, char)) For gisgraphy the char is WHITESPACE_CHAR_DELIMITER
Returns:
the transformed string (or null if the original String is null) to be use by the postgres function plainto_tsquery)
See Also:
transformStringForPartialWordIndexation(String, char)

updateOpenStreetMapEntityForIndexation

public static OpenStreetMap updateOpenStreetMapEntityForIndexation(OpenStreetMap openStreetMap)
Parameters:
openStreetMap - the openStreetMap Entity to update
Returns:
the same openstreetmap entity with the OpenStreetMap.PARTIALSEARCH_COLUMN_NAME and OpenStreetMap.FULLTEXTSEARCH_COLUMN_NAME

splitCamelCase

public static String splitCamelCase(String s)
Parameters:
s - a camel Case string
Returns:
a human readable string where upper char is replaced by a space and the lowercase char

isNotEmptyString

public static boolean isNotEmptyString(String string)
Usefull method to be compatible with jdk1.5 (jdk 1.6 already have this method)

Parameters:
string - the string to test
Returns:
true if the string is not null or empty (trimmed)

isEmptyString

public static boolean isEmptyString(String string)
Usefull method to be compatible with jdk1.5 (jdk 1.6 already have this method)

Parameters:
string - the string to test
Returns:
true if the sting is null or empty (trimmed)

getStackTraceAsString

public static String getStackTraceAsString(Throwable aThrowable)
Parameters:
aThrowable -
Returns:
the stacktrace as string


Copyright © 2012. All Rights Reserved.