Class SQLUtil
- java.lang.Object
-
- com.vividsolutions.jump.datastore.SQLUtil
-
public class SQLUtil extends Object
Utililty class containing methods to manipulate SQL Strings
-
-
Constructor Summary
Constructors Constructor Description SQLUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringcompose(String schemaName, String tableName)Compose a concatenated quoted schema name and table name.static StringescapeSingleQuote(String identifier)Escape single quotes in the given identifier.static AttributeTypegetAttributeType(int sqlType, String dataTypeName)Returns OpenJUMP attributeType from sql type and datatype name.static byte[]getByteArrayFromGeometry(org.locationtech.jts.geom.Geometry geom, int srid, int dimension)Converts the geometry into a byte array in EWKB formatstatic Stringnormalize(String name)Normalize an identifier name (use only lower case)static Stringquote(String s)Returns s if s is already quoted (with double-quotes), and a quoted version of s otherwise.static String[]splitTableName(String fullName)Returns a pair of strings containing unquoted schema and table names from a full table name.static Stringunquote(String s)Returns s without initial and final double quotes if any.
-
-
-
Method Detail
-
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 nametableName- 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 arraysrid- the srid of the geometrydimension- 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 datatypedataTypeName- native datatype name
-
-