org.h2gis.utilities
Class TableLocation

java.lang.Object
  extended by org.h2gis.utilities.TableLocation

public class TableLocation
extends Object

Just a class used to split Catalog Schema and Table. Theses components are a unique table identifier.

Author:
Nicolas Fortin

Constructor Summary
TableLocation(ResultSet rs)
           
TableLocation(String table)
           
TableLocation(String schema, String table)
           
TableLocation(String catalog, String schema, String table)
           
 
Method Summary
static String capsIdentifier(String identifier, Boolean isH2Database)
          Change case of parameters to make it more user-friendly.
 boolean equals(Object o)
           
 String getCatalog()
           
 String getCatalog(String defaultValue)
           
 String getSchema()
           
 String getSchema(String defaultValue)
           
 String getTable()
           
 int hashCode()
           
static TableLocation parse(String concatenatedTableLocation)
          Convert catalog.schema.table, schema.table or table into a TableLocation instance.
static TableLocation parse(String concatenatedTableLocation, Boolean isH2Database)
          Convert catalog.schema.table, schema.table or table into a TableLocation instance.
static String quoteIdentifier(String identifier)
          Always Quote string for both H2 and Postgre compatibility
static String quoteIdentifier(String identifier, boolean isH2DataBase)
          Quote identifier only if necessary.
 void setDefaultSchema(String defaultSchema)
           
 String toString()
           
 String toString(boolean isH2)
          String representation of Table location, for insertion in SQL statement.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TableLocation

public TableLocation(ResultSet rs)
              throws SQLException
Parameters:
rs - result set obtained through DatabaseMetaData.getTables(String, String, String, String[])
Throws:
SQLException

TableLocation

public TableLocation(String catalog,
                     String schema,
                     String table)
Parameters:
catalog - Catalog name without quotes
schema - Schema name without quotes
table - Table name without quotes

TableLocation

public TableLocation(String schema,
                     String table)
Parameters:
schema - Schema name without quotes
table - Table name without quotes

TableLocation

public TableLocation(String table)
Parameters:
table - Table name without quotes
Method Detail

quoteIdentifier

public static String quoteIdentifier(String identifier)
Always Quote string for both H2 and Postgre compatibility

Parameters:
identifier - Catalog,Schema,Table or Field name
Returns:
Quoted Identifier

quoteIdentifier

public static String quoteIdentifier(String identifier,
                                     boolean isH2DataBase)
Quote identifier only if necessary. Require database knowledge.

Parameters:
identifier - Catalog,Schema,Table or Field name
isH2DataBase - True if the quote is for H2, false if for POSTGRE
Returns:
Quoted Identifier

toString

public String toString()
Overrides:
toString in class Object

toString

public String toString(boolean isH2)
String representation of Table location, for insertion in SQL statement. This function try to do not quote unnecessary components; require database type.

Parameters:
isH2 - True if H2, false if
Returns:
String representation of Table location

getCatalog

public String getCatalog()
Returns:
Table catalog name (database)

getCatalog

public String getCatalog(String defaultValue)
Parameters:
defaultValue - Return this value if this attribute is not defined.
Returns:
Table catalog name (database)

parse

public static TableLocation parse(String concatenatedTableLocation)
Convert catalog.schema.table, schema.table or table into a TableLocation instance. Non-specified schema or catalogs are converted to the empty string.

Parameters:
concatenatedTableLocation - Table location [[Catalog.]Schema.]Table
Returns:
Java beans for table location

parse

public static TableLocation parse(String concatenatedTableLocation,
                                  Boolean isH2Database)
Convert catalog.schema.table, schema.table or table into a TableLocation instance. Non-specified schema or catalogs are converted to the empty string.

Parameters:
concatenatedTableLocation - Table location [[Catalog.]Schema.]Table
isH2Database - True if H2, False if PostGreSQL, null if unknown
Returns:
Java beans for table location

capsIdentifier

public static String capsIdentifier(String identifier,
                                    Boolean isH2Database)
Change case of parameters to make it more user-friendly.

Parameters:
identifier - Table, Catalog, Schema, or column name
isH2Database - True if H2, False if PostGreSQL, null if unknown
Returns:
Upper or lower case version of identifier

getSchema

public String getSchema()
Returns:
Table schema name

getSchema

public String getSchema(String defaultValue)
Parameters:
defaultValue - Return this value if this attribute is not defined.
Returns:
Table schema name

getTable

public String getTable()
Returns:
Table name

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

setDefaultSchema

public void setDefaultSchema(String defaultSchema)
Parameters:
defaultSchema - Default connection schema, used for table location equality test.


Copyright © 2015 IRSTV CNRS-FR-2488. All Rights Reserved.