Class 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 Detail

      • TableLocation

        public TableLocation​(String catalog,
                             String schema,
                             String table,
                             DBTypes dbTypes)
        Parameters:
        catalog - Catalog name without quotes
        schema - Schema name without quotes
        table - Table name without quotes
        dbTypes - The database type e.g : H2GIS, POSTGIS...
      • 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 schema,
                             String table,
                             DBTypes dbTypes)
        Parameters:
        schema - Schema name without quotes
        table - Table name without quotes
        dbTypes - The database type e.g : H2GIS, POSTGIS...
      • TableLocation

        public TableLocation​(String table,
                             DBTypes dbTypes)
        Parameters:
        table - Table name without quotes
        dbTypes - The database type e.g : H2GIS, POSTGIS...
      • 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
      • format

        public static String format​(String identifier,
                                    DBTypes dbTypes)
        Format the identifier is necessary. Require database knowledge.
        Parameters:
        identifier - Catalog,Schema,Table or Field name.
        dbTypes - Type of the database.
        Returns:
        Quoted identifier.
      • quoteIdentifier

        public static String quoteIdentifier​(String identifier,
                                             DBTypes dbTypes)
        Quote identifier only if necessary. Require database knowledge.
        Parameters:
        identifier - Catalog,Schema,Table or Field name.
        dbTypes - Type of the database.
        Returns:
        Quoted identifier.
      • toString

        public String toString​(DBTypes dbTypes)
        String representation of Table location, for insertion in SQL statement. This function try to do not quote unnecessary components; require database type.
        Parameters:
        dbTypes - Database type.
        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
      • split

        public static String[] split​(String tableName)
        Convert catalog.schema.table, schema.table or table into a String array instance. Non-specified schema or catalogs are converted to the empty string.
        Parameters:
        tableName - in the form [[Catalog.]Schema.]Table
        Returns:
        a String array with [0] = Catalog [1] = Schema [2] = Table
      • parse

        public static TableLocation parse​(String concatenatedTableLocation,
                                          DBTypes dbTypes)
        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
        dbTypes - Database type.
        Returns:
        Java beans for table location
      • capsIdentifier

        public static String capsIdentifier​(String identifier,
                                            DBTypes dbTypes)
        Change case of parameters to make it more user-friendly.
        Parameters:
        identifier - Table, Catalog, Schema, or column name
        dbTypes - Database type.
        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
      • 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.
      • getDbTypes

        public DBTypes getDbTypes()
        Return the dbtype used by tablelocation. Default is H2
        Returns: