docs: private static String generateSQLSearchPattern(Object pattern)
  	{
  		if (pattern == null)
  		{
  			return null;
  		}
  		else
  		{
  			StringBuffer sqlpattern = new StringBuffer();
  			char[] chars = pattern.toString().toCharArray();
  
  			for (int i = 0; i < chars.length; i++)
  			{
  				if (chars[i] == escapeCharacter)
  				{
  					// for the escape character add the next char as is.
  					// find the next non-escape character.
  					int x = i + 1;
  					for (;(x < chars.length); x++)
  					{
  						if (chars[x] != escapeCharacter)
  						{
  							break;
  						}
  					}
  					boolean oddEscapes = (((x - i) % 2) > 0) ? true : false;
  					if (oddEscapes)
  					{
  						// only escape characters allowed are '%', '_', and '\'
  						// if the escaped character is a '\', then oddEscapes
  						// will be false.
  						// if the character following this last escape is not a
  						// '%' or an '_', eat this escape character.
  						if ((x < chars.length)
  							&& ((chars[x] == '%') || (chars[x] == '_')))
  						{
  							// leave the escape character in, along with the following char
  							x++;
  						}
  						else
  						{
  							// remove the escape character, will cause problems in sql statement.
  							i++; // removing the first escape character.
  							if ((x < chars.length)
  								&& ((chars[x] == '*') || (chars[x] == '?')))
  							{
  								// but if it is a '*' or a '?', we want to keep these
  								// characters as is, they were 'escaped' out.
  								x++; // include the first non-escape character.
  							}
  						}
  					}
  					if (i < chars.length)
  					{
  						sqlpattern.append(chars, i, x - i);
  					}
  					i = x - 1; // set index to last character copied.
  				}
  				else if (chars[i] == '*')
  				{
  					sqlpattern.append("%");
  				}
  				else if (chars[i] == '?')
  				{
  					sqlpattern.append("_");
  				}
  				else
  				{
  					sqlpattern.append(chars[i]);
  				}
  			}
  			return sqlpattern.toString();
  		}
  	}