## org.eclipse.datatools.sqltools.sql.util
Class SQLUtil

    java.lang.Object
      org.eclipse.datatools.sqltools.sql.util.SQLUtil

    public class SQLUtil

extends java.lang.Object

Contains various SQL processing utilities.

Author:
  Hui Cao

Field Summary
`static java.util.regex.Pattern` `ID_PATTERN`
`static int` `MATCHING_DOUBLE_QUOTES`
`static int` `MATCHING_SINGLE_QUOTES`
`static int` `MAX_NAME_LENGTH_FOR_MESSAGE_DIALOGS`
`static int` `NO_MATCHING_QUOTES`
`static int` `NO_QUOTES`
`static java.util.regex.Pattern` `STRING_PATTERN`

Constructor Summary
`SQLUtil()`

Method Summary
`static int` `convert2SQLType(java.lang.String datatype)`
`static java.lang.String` `describeSQL(java.lang.String sql, int length)` Describe the sql string by truncating the characters after `length-3` and appending ellipses if it's longer than `length`.
`static boolean` `equalsIgnoreQuote(java.lang.String s1, java.lang.String s2, boolean caseSensitive)` Returns whether the 2 Strings are equal by ignoring the surrounding quotes
`static int` `findQuotes(java.lang.String content)`
`static java.lang.String[]` `getAvaiableCurrencySymbols()` Returns all the currency symbols
`static boolean` `isBinaryType(IDatatype datatype)`
`static boolean` `isBinaryType(java.lang.String datatype)`
`static boolean` `isNumericType(IDatatype datatype)`
`static boolean` `isNumericType(int datatype)`
`static boolean` `isNumericType(java.lang.String datatype)`
`static boolean` `isStringType(IDatatype datatype)`
`static boolean` `isStringType(int sqlType)`
`static boolean` `isStringType(java.lang.String datatype)`
`static java.lang.String[]` `parseDatabaseObject(java.lang.String objstr)` "objstr" is a string representing a database object.
`static java.lang.String` `quote(java.lang.String in, char quoteChar)` Surrounds the input string with quoteChar and doubles every quoteChar inside the string.
`static java.lang.String` `quote(java.lang.String content, java.lang.String quoteMark)` surround content with quoteMark and double every quoteMark inside content
`static java.lang.String[]` `splitDotStr(java.lang.String input)`
`static java.lang.String` `toHexString(byte[] bytes)`
`static java.lang.String` `unquote(java.lang.String quoted)` Removes the surrounding quotation mark (' or ") and restores 2 successive quotation marks to 1.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### NO_QUOTES

    public static final int NO_QUOTES

See Also:
  Constant Field Values

### MATCHING_SINGLE_QUOTES

    public static final int MATCHING_SINGLE_QUOTES

See Also:
  Constant Field Values

### MATCHING_DOUBLE_QUOTES

    public static final int MATCHING_DOUBLE_QUOTES

See Also:
  Constant Field Values

### NO_MATCHING_QUOTES

    public static final int NO_MATCHING_QUOTES

See Also:
  Constant Field Values

### ID_PATTERN

    public static final java.util.regex.Pattern ID_PATTERN

### STRING_PATTERN

    public static final java.util.regex.Pattern STRING_PATTERN

### MAX_NAME_LENGTH_FOR_MESSAGE_DIALOGS

    public static int MAX_NAME_LENGTH_FOR_MESSAGE_DIALOGS

Constructor Detail

### SQLUtil

    public SQLUtil()

Method Detail

### parseDatabaseObject

    public static java.lang.String[] parseDatabaseObject(java.lang.String objstr)

  "objstr" is a string representing a database object. Possibly in following formats: <ll>
  - objname
  - ownername.objname
  - databasename.ownername.objname
  - databasename..objname
  </ll> This method will try to figure it out, and return a string array. with the first element be the last segment in "objstr". In case of invalid objstr, will return null NOTE: it is allowed to have whitespace in objname/ownername/databasename, in that case, the name is quoted in "'". See SQL grammer for detail.

  Parameters:
    `objstr` - a string identifying a database object.
  Returns:
    string array

### findQuotes

    public static int findQuotes(java.lang.String content)

### quote

    public static java.lang.String quote(java.lang.String in,
                                         char quoteChar)

  Surrounds the input string with quoteChar and doubles every quoteChar inside the string.

  Parameters:
    `in` - the input string
    `quoteChar` - quotation character, usually it's ' or "
  Returns:
    quoted string

### quote

    public static java.lang.String quote(java.lang.String content,
                                         java.lang.String quoteMark)

  surround content with quoteMark and double every quoteMark inside content

  Parameters:
    `content` -
    `quoteMark` -
  Returns:

### unquote

    public static java.lang.String unquote(java.lang.String quoted)

  Removes the surrounding quotation mark (' or ") and restores 2 successive quotation marks to 1.

  Parameters:
    `quoted` - quoted string
  Returns:
    unquoted string

### describeSQL

    public static java.lang.String describeSQL(java.lang.String sql,
                                               int length)

  Describe the sql string by truncating the characters after `length-3` and appending ellipses if it's longer than `length`.

  Parameters:
    `sql` -
    `length` -
  Returns:

### toHexString

    public static final java.lang.String toHexString(byte[] bytes)

  Parameters:
    `bytes` - The array of bytes to convert to ASCII hex form.
  Returns:
    An ASCII hexadecimal numeric string representing the specified array of bytes.

### splitDotStr

    public static java.lang.String[] splitDotStr(java.lang.String input)

### getAvaiableCurrencySymbols

    public static java.lang.String[] getAvaiableCurrencySymbols()

  Returns all the currency symbols

  Returns:

### equalsIgnoreQuote

    public static boolean equalsIgnoreQuote(java.lang.String s1,
                                            java.lang.String s2,
                                            boolean caseSensitive)

  Returns whether the 2 Strings are equal by ignoring the surrounding quotes

  Parameters:
    `s1` -
    `s2` -
    `caseSensitive` - whether to consider case
  Returns:

### isBinaryType

    public static boolean isBinaryType(IDatatype datatype)

### isBinaryType

    public static boolean isBinaryType(java.lang.String datatype)

### isNumericType

    public static boolean isNumericType(java.lang.String datatype)

### convert2SQLType

    public static int convert2SQLType(java.lang.String datatype)

### isNumericType

    public static boolean isNumericType(int datatype)

### isNumericType

    public static boolean isNumericType(IDatatype datatype)

### isStringType

    public static boolean isStringType(java.lang.String datatype)

### isStringType

    public static boolean isStringType(IDatatype datatype)

### isStringType

    public static boolean isStringType(int sqlType)