Class SQLUtil

java.lang.Object
com.vividsolutions.jump.datastore.SQLUtil

public class SQLUtil extends Object
Utililty class containing methods to manipulate SQL Strings
  • Constructor Details

    • SQLUtil

      public SQLUtil()
  • Method Details

    • splitTableName

      public static String[] splitTableName(String fullName)
      Returns a pair of strings containing unquoted schema and table names from a full table name. If the fullName contains only one part (table name), the returned array contains a null element at index 0
      Examples :
      • myschema.mytable -> [myschema, mytable]
      • "MySchema"."MyTable" -> [MySchema, MyTable]
      • MyTable -> [null, MyTable]
      • 2_table -> [null, 2_table]
    • quote

      public static String quote(String s)
      Returns s if s is already quoted (with double-quotes), and a quoted version of s otherwise. Returns null if s is null.
    • unquote

      public static String unquote(String s)
      Returns s without initial and final double quotes if any. Returns null if s is null.
    • escapeSingleQuote

      public static String escapeSingleQuote(String identifier)
      Escape single quotes in the given identifier. Replace all single quotes ("'") by double single quotes ("''")
      Parameters:
      identifier - string identifier to escape
      Returns:
      the identifier with single quotes escaped, or identifier if no string found
    • compose

      public static String compose(String schemaName, String tableName)
      Compose a concatenated quoted schema name and table name.
      Parameters:
      schemaName - unquoted schema name
      tableName - unquoted table name
    • normalize

      public static String normalize(String name)
      Normalize an identifier name (use only lower case)
      Parameters:
      name - the identifier to normalize
      Returns:
      the name writen in lowercase
    • getByteArrayFromGeometry

      public static byte[] getByteArrayFromGeometry(org.locationtech.jts.geom.Geometry geom, int srid, int dimension)
      Converts the geometry into a byte array in EWKB format
      Parameters:
      geom - the geometry to convert to a byte array
      srid - the srid of the geometry
      dimension - geometry dimension (2 or 3)
      Returns:
      a byte array containing a EWKB representation of the geometry
    • getAttributeType

      public static AttributeType getAttributeType(int sqlType, String dataTypeName)
      Returns OpenJUMP attributeType from sql type and datatype name. dataTypeName is nullable. If dataTypeName = "geometry", binary field will be interpreted into AttributeType.GEOMETRY
      Parameters:
      sqlType - jdbc sql datatype
      dataTypeName - native datatype name