public class VirtualTable extends Object implements Serializable
The sql query can contain named parameters. Each parameter has a name, a default value and a way to validate its contents to prevent sql injection.
As well as passing validation, parameters are also passed through a function to escape double quotes, single quotes and strip backslashes to guard against the cases where quotes are desired in the parameters or backslashes have been allowed by an overly lax regular expression.
Escaping is enabled by default and can be controlled by a constructor argument or via the setEscapeSql() method.
Modifier and Type | Field and Description |
---|---|
static String |
WHERE_CLAUSE_PLACE_HOLDER |
static int |
WHERE_CLAUSE_PLACE_HOLDER_LENGTH |
Constructor and Description |
---|
VirtualTable(String name,
String sql)
Builds a new virtual table stating its name and the query to be executed to work on it
|
VirtualTable(String name,
String sql,
boolean escapeSql)
Builds a new virtual table stating its name, the query to be executed to work on it and a
flag to indicate if SQL special characters should be escaped.
|
VirtualTable(String name,
VirtualTable other)
Clone a virtual table under a different name
|
VirtualTable(VirtualTable other)
Clone a virtual table
|
Modifier and Type | Method and Description |
---|---|
void |
addGeometryMetadatata(String geometry,
Class<? extends Geometry> binding,
int nativeSrid)
Adds geometry metadata to the virtual table.
|
void |
addGeometryMetadatata(String geometry,
Class<? extends Geometry> binding,
int nativeSrid,
int dimension)
Adds geometry metadata to the virtual table.
|
void |
addParameter(VirtualTableParameter param)
Adds a parameter to the virtual table
|
boolean |
equals(Object obj) |
String |
expandParameters(Hints hints) |
int |
getDimension(String geometryName)
Returns the geometry dimension, or 2 if not known
|
Set<String> |
getGeometries()
Returns the name of the geometry colums declared in this virtual table
|
Class<? extends Geometry> |
getGeometryType(String geometryName)
Returns the geometry's specific type, or null if not known
|
String |
getName()
The virtual table name
|
int |
getNativeSrid(String geometryName)
Returns the geometry native srid, or -1 if not known
|
VirtualTableParameter |
getParameter(String name)
Returns the requested parameter, or null if it could not be found
|
Collection<String> |
getParameterNames()
The current parameter names
|
List<String> |
getPrimaryKeyColumns()
Returns the virtual table primary key columns.
|
String |
getSql()
The virtual table sql (raw, without parameter expansion)
|
int |
hashCode() |
boolean |
isEscapeSql() |
void |
removeParameter(String paramName)
Removes a parameter from the virtual table
|
void |
setEscapeSql(boolean escapeSql) |
static Hints |
setKeepWhereClausePlaceHolderHint(Hints hints,
boolean keepWhereClausePlaceHolder)
Will add an entry to query hints specifying if the the where clause place holder should be
keep or not.
|
static Hints |
setKeepWhereClausePlaceHolderHint(Query query)
If the provided query has a filter of a where clause place holder exists it will be
preserved.
|
void |
setPrimaryKeyColumns(List<String> primaryKeyColumns)
Sets the virtual table primary key
|
String |
toString() |
public static String WHERE_CLAUSE_PLACE_HOLDER
public static int WHERE_CLAUSE_PLACE_HOLDER_LENGTH
public VirtualTable(String name, String sql)
name
- sql
- public VirtualTable(String name, String sql, boolean escapeSql)
name
- sql
- escapeSql
- public VirtualTable(String name, VirtualTable other)
name
- other
- public VirtualTable(VirtualTable other)
name
- other
- public static Hints setKeepWhereClausePlaceHolderHint(Query query)
query
- the query to testpublic static Hints setKeepWhereClausePlaceHolderHint(Hints hints, boolean keepWhereClausePlaceHolder)
hints
- query hints to update, if NULL a new hints map will be createdkeepWhereClausePlaceHolder
- TRUE if the where clause place holder should be keeppublic List<String> getPrimaryKeyColumns()
public void setPrimaryKeyColumns(List<String> primaryKeyColumns)
primaryKeyColumns
- public String getName()
public String getSql()
public String expandParameters(Hints hints) throws SQLException
SQLException
public void addGeometryMetadatata(String geometry, Class<? extends Geometry> binding, int nativeSrid)
geometry
- binding
- nativeSrid
- public void addGeometryMetadatata(String geometry, Class<? extends Geometry> binding, int nativeSrid, int dimension)
geometry
- binding
- nativeSrid
- public void addParameter(VirtualTableParameter param)
param
- public void removeParameter(String paramName)
paramName
- public Collection<String> getParameterNames()
public VirtualTableParameter getParameter(String name)
public Class<? extends Geometry> getGeometryType(String geometryName)
geometryName
- public Set<String> getGeometries()
public int getNativeSrid(String geometryName)
geometryName
- public int getDimension(String geometryName)
geometryName
- public boolean isEscapeSql()
public void setEscapeSql(boolean escapeSql)
Copyright © 1996–2019 Geotools. All rights reserved.