Package com.databricks.jdbc.common.util

## Class StringUtil

- java.lang.Object
- - com.databricks.jdbc.common.util.StringUtil

    public class StringUtil
    extends Object

### Constructor Summary

Constructors
`StringUtil()`

### Method Summary

All Methods Static Methods Concrete Methods
`static boolean` `checkPrefixMatch​(String prefix, String fileName, boolean caseSensitive)` Function to check if the given prefix exists in the fileName
`static String` `convertJdbcEscapeSequences​(String sql)`
`static String` `escapeStringLiteral​(String str)` Escape sql string literal which is enclosed in a single quote, it replaces single quote with doubled single quotes.
`static String` `getBaseNameFromPath​(String path)` Function to return the base name from the path
`static String` `getFolderNameFromPath​(String path)` Function to return the folder name from the path
`static String` `getVolumePath​(String catalog, String schema, String volume)` Building the volume path using the provided catalog, schema and volume
`static Set<Integer>` `parseIntegerSet​(String input)` Parses a comma-separated string of integers into a Set.
`static String` `removeRedundantEscapeClause​(String sql)` Removes empty ESCAPE clauses from SQL statements to work around Databricks SQL parser limitations.
`static List<String>` `split​(String value)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### StringUtil

    public StringUtil()

### Method Detail

#### convertJdbcEscapeSequences

    public static String convertJdbcEscapeSequences​(String sql)

#### escapeStringLiteral

    public static String escapeStringLiteral​(String str)

Escape sql string literal which is enclosed in a single quote, it replaces single quote with doubled single quotes.

Please always use prepareStatement to bind variables if possible, only use it when prepareStatement is not applicable, e.g. some DDL statement

#### checkPrefixMatch

    public static boolean checkPrefixMatch​(String prefix,
                                           String fileName,
                                           boolean caseSensitive)

Function to check if the given prefix exists in the fileName

#### split

    public static List<String> split​(String value)

#### getFolderNameFromPath

    public static String getFolderNameFromPath​(String path)

Function to return the folder name from the path

#### getBaseNameFromPath

    public static String getBaseNameFromPath​(String path)

Function to return the base name from the path

#### getVolumePath

    public static String getVolumePath​(String catalog,
                                       String schema,
                                       String volume)

Building the volume path using the provided catalog, schema and volume

#### removeRedundantEscapeClause

    public static String removeRedundantEscapeClause​(String sql)

Removes empty ESCAPE clauses from SQL statements to work around Databricks SQL parser limitations.

All other ESCAPE clauses, including custom escape characters (e.g., `ESCAPE '#'`), are preserved unchanged.

Parameters:
  `sql` - The SQL statement to process
Returns:
  SQL with empty ESCAPE clauses removed, or null if input is null

#### parseIntegerSet

    public static Set<Integer> parseIntegerSet​(String input)

Parses a comma-separated string of integers into a Set.

Parameters:
  `input` - comma-separated string of integers (e.g., "500, 503, 504")
Returns:
  Set of parsed integers, or empty set if input is null/empty or all values are invalid
Throws:
  `NumberFormatException` - if any value cannot be parsed as an integer (after validation)