Class ADQLTable

  • All Implemented Interfaces:
    ADQLObject, FromContent

    public class ADQLTable
    extends java.lang.Object
    implements ADQLObject, FromContent
    It represents any item of the clause FROM: a table name or a sub-query.
    A table reference may have an alias (MUST if it is a sub-query).
    Version:
    1.5 (09/2019)
    Author:
    Grégory Mantelet (CDS;ARI)
    • Constructor Summary

      Constructors 
      Constructor Description
      ADQLTable​(ADQLQuery query)
      Builds a reference to a sub-query.
      ADQLTable​(ADQLTable toCopy)
      Builds an ADQL table by copying the given one.
      ADQLTable​(java.lang.String table)
      Builds a reference to a table with its name (simple or full ({catalog}.{schema}.{table})).
      ADQLTable​(java.lang.String schema, java.lang.String table)
      Builds a reference to a table with its name and the name of its schema.
      ADQLTable​(java.lang.String catalog, java.lang.String schema, java.lang.String table)
      Builds a reference to a table with its name, the name of its schema and the name of its catalog.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ADQLIterator adqlIterator()
      Gets an iterator on the intern ADQL objects.
      java.lang.String getAlias()
      Gets the label of this table.
      byte getCaseSensitive()
      Gets the whole case sensitivity of this ADQL table.
      java.lang.String getCatalogName()
      Gets the name of the catalog which contains this table.
      ADQLObject getCopy()
      Gets a (deep) copy of this ADQL object.
      SearchColumnList getDBColumns()
      Gets the list of all columns (~ database metadata) available in this FROM part.
      DBTable getDBLink()
      Gets the corresponding DBTable.
      java.lang.String getFullTableName()
      Gets the full name of this table (catalogName .
      java.lang.String getName()
      Gets the name of this object in ADQL.
      TextPosition getPosition()
      Gets the position in the original ADQL query string.
      java.lang.String getSchemaName()
      Gets the name of the schema which contains this table.
      ADQLQuery getSubQuery()
      Gets the sub-query used as table.
      java.lang.String getTableName()
      Gets the name of the table.
      java.util.List<ADQLTable> getTables()
      Gets all ADQLTable instances contained in this FROM part (itself included, if it is an ADQLTable).
      java.util.List<ADQLTable> getTablesByAlias​(java.lang.String alias, boolean caseSensitive)
      Gets all the table whose the alias is equals to the given one.
      boolean hasAlias()
      Tells whether this table has an alias or not.
      boolean isCaseSensitive()
      Indicates whether all fields (catalog, schema and table) are case sensitive.
      boolean isCaseSensitive​(IdentifierField field)
      Indicates whether the specified field (catalog, schema or table) is case sensitive or not.
      boolean isSubQuery()
      Tells whether this table reference is a sub-query or a table name/alias.
      protected java.lang.String normalizeName​(java.lang.String name, IdentifierField field)
      Lets normalizing any catalog/schema/table name or alias.
      void refreshDBLink()
      (Re-)Builds a default description of this ADQL table ONLY IF it is a sub-query AND there is an alias.
      void setAlias​(java.lang.String alias)
      Sets the label of this table.
      void setCaseSensitive​(boolean sensitive)
      Sets the case sensitivity of all fields (catalog, schema and table).
      void setCaseSensitive​(byte sensitivity)
      Sets the whole case sensitivity of this ADQL table.
      void setCaseSensitive​(IdentifierField field, boolean sensitive)
      Sets the case sensitivity of the specified field (catalog, schema or table).
      void setCatalogName​(java.lang.String catalog)
      Sets the name of the catalog which contains this table.
      void setDBLink​(DBTable dbLink)
      Sets the DBTable corresponding to this ADQLTable.
      void setPosition​(TextPosition pos)
      Sets the position at which this ADQLTable has been found in the original ADQL query string.
      void setSchemaName​(java.lang.String schema)
      Sets the name of the schema which contains this table.
      void setSubQuery​(ADQLQuery query)
      Sets the sub-query to use as table.
      void setTable​(java.lang.String tableRef)
      Updates the whole Table according to the given table reference ({catalog}.{schema}.{table}).
      void setTableName​(java.lang.String newTableName)
      Sets the name of the table.
      java.lang.String toADQL()
      Gets the ADQL expression of this object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ADQLTable

        public ADQLTable​(java.lang.String table)
        Builds a reference to a table with its name (simple or full ({catalog}.{schema}.{table})).
        Parameters:
        table - Name of the table (simple or full ({catalog}.{schema}.{table})).
      • ADQLTable

        public ADQLTable​(java.lang.String schema,
                         java.lang.String table)
        Builds a reference to a table with its name and the name of its schema.
        Parameters:
        schema - Name of its schema.
        table - Name of the table.
      • ADQLTable

        public ADQLTable​(java.lang.String catalog,
                         java.lang.String schema,
                         java.lang.String table)
        Builds a reference to a table with its name, the name of its schema and the name of its catalog.
        Parameters:
        catalog - Name of its catalog.
        schema - Name of its schema.
        table - Name of the table.
      • ADQLTable

        public ADQLTable​(ADQLTable toCopy)
                  throws java.lang.Exception
        Builds an ADQL table by copying the given one.
        Parameters:
        toCopy - The ADQLTable to copy.
        Throws:
        java.lang.Exception - If there is an error during the copy.
    • Method Detail

      • normalizeName

        protected java.lang.String normalizeName​(java.lang.String name,
                                                 IdentifierField field)

        Lets normalizing any catalog/schema/table name or alias.

        If the name is surrounded by double-quotes, they are removed and the corresponding field will be declared as case sensitive.

        Parameters:
        name - Name to normalize.
        field - The name part to normalize and to get (if normalized, the case sensitivity of the given field will be set).
        Returns:
        The normalized name.
      • getCatalogName

        public final java.lang.String getCatalogName()
        Gets the name of the catalog which contains this table.
        Returns:
        Catalog name.
      • setCatalogName

        public final void setCatalogName​(java.lang.String catalog)
        Sets the name of the catalog which contains this table.
        Parameters:
        catalog - The new name of its catalog.
      • getSchemaName

        public final java.lang.String getSchemaName()
        Gets the name of the schema which contains this table.
        Returns:
        Schema name.
      • setSchemaName

        public final void setSchemaName​(java.lang.String schema)
        Sets the name of the schema which contains this table.
        Parameters:
        schema - The new name of its schema.
      • getTableName

        public final java.lang.String getTableName()
        Gets the name of the table.
        Returns:
        Table name.
      • getFullTableName

        public final java.lang.String getFullTableName()
        Gets the full name of this table (catalogName . schemaName . tableName) by respecting the case sensitivity of each field (if case sensitive double-quotes will surround the concerned fields name).
        Returns:
        Its full name.
      • setTableName

        public void setTableName​(java.lang.String newTableName)
        Sets the name of the table.
        Parameters:
        newTableName - The new name of the table.
      • setTable

        public final void setTable​(java.lang.String tableRef)
        Updates the whole Table according to the given table reference ({catalog}.{schema}.{table}).
        Parameters:
        tableRef - The complete table reference ({catalog}.{schema}.{table}).
      • getSubQuery

        public final ADQLQuery getSubQuery()
        Gets the sub-query used as table.
        Returns:
        Sub-query.
      • setSubQuery

        public final void setSubQuery​(ADQLQuery query)
        Sets the sub-query to use as table.
        Parameters:
        query - Sub-query (MUST NOT BE NULL).
        See Also:
        refreshDBLink()
      • isSubQuery

        public final boolean isSubQuery()
        Tells whether this table reference is a sub-query or a table name/alias.
        Returns:
        true if this table is a sub-query, false else.
      • getAlias

        public final java.lang.String getAlias()
        Gets the label of this table.
        Returns:
        Table label.
      • hasAlias

        public final boolean hasAlias()
        Tells whether this table has an alias or not.
        Returns:
        true if this table has an alias, false otherwise.
      • setAlias

        public void setAlias​(java.lang.String alias)
        Sets the label of this table.
        Parameters:
        alias - Label to put on this table.
      • isCaseSensitive

        public final boolean isCaseSensitive​(IdentifierField field)
        Indicates whether the specified field (catalog, schema or table) is case sensitive or not.
        Parameters:
        field - A field (catalog, schema or table).
        Returns:
        true if the specified field is case sensitive, false otherwise.
        See Also:
        IdentifierField, IdentifierField.isCaseSensitive(byte)
      • setCaseSensitive

        public final void setCaseSensitive​(IdentifierField field,
                                           boolean sensitive)
        Sets the case sensitivity of the specified field (catalog, schema or table).
        Parameters:
        field - The field for which the case sensitivity must be updated.
        sensitive - true if the specified field must be case sensitive, false otherwise.
        See Also:
        IdentifierField, IdentifierField.setCaseSensitive(byte, boolean)
      • isCaseSensitive

        public final boolean isCaseSensitive()
        Indicates whether all fields (catalog, schema and table) are case sensitive.
        Returns:
        true if all fields are case sensitive, false otherwise.
        See Also:
        IdentifierField.isFullCaseSensitive(byte)
      • setCaseSensitive

        public final void setCaseSensitive​(boolean sensitive)
        Sets the case sensitivity of all fields (catalog, schema and table).
        Parameters:
        sensitive - true if all fields must be case sensitive, false otherwise.
        See Also:
        IdentifierField.getFullCaseSensitive(boolean)
      • getCaseSensitive

        public final byte getCaseSensitive()
        Gets the whole case sensitivity of this ADQL table.
        Returns:
        Its new case sensitivity (one bit per fields).
        See Also:
        IdentifierField
      • setCaseSensitive

        public final void setCaseSensitive​(byte sensitivity)
        Sets the whole case sensitivity of this ADQL table.
        Parameters:
        sensitivity - Its new case sensitivity (one bit per fields).
        See Also:
        IdentifierField
      • setDBLink

        public final void setDBLink​(DBTable dbLink)
        Sets the DBTable corresponding to this ADQLTable.
        Parameters:
        dbLink - Its corresponding DBTable.
      • getDBColumns

        public SearchColumnList getDBColumns()
        Description copied from interface: FromContent

        Gets the list of all columns (~ database metadata) available in this FROM part.

        Note: In the most cases, this list is generated on the fly !

        Specified by:
        getDBColumns in interface FromContent
        Returns:
        All the available DBColumns.
      • getTablesByAlias

        public java.util.List<ADQLTable> getTablesByAlias​(java.lang.String alias,
                                                          boolean caseSensitive)
        Description copied from interface: FromContent

        Gets all the table whose the alias is equals to the given one.

        Note: Theoretically, only one table may be returned. But, since this object may be generated without the parser, it is possible that several ADQLTable objects exits with the same alias (particularly if there are JOIN).

        Specified by:
        getTablesByAlias in interface FromContent
        Parameters:
        alias - Alias of the table(s) to get.
        caseSensitive - true if the research must be made with case-sensitivity, false otherwise.
        Returns:
        The list of all tables found.
      • getCopy

        public ADQLObject getCopy()
                           throws java.lang.Exception
        Description copied from interface: ADQLObject
        Gets a (deep) copy of this ADQL object.
        Specified by:
        getCopy in interface ADQLObject
        Returns:
        The copy of this ADQL object.
        Throws:
        java.lang.Exception - If there is any error during the copy.
      • getName

        public java.lang.String getName()
        Description copied from interface: ADQLObject
        Gets the name of this object in ADQL.
        Specified by:
        getName in interface ADQLObject
        Returns:
        The name of this ADQL object.
      • toADQL

        public java.lang.String toADQL()
        Description copied from interface: ADQLObject
        Gets the ADQL expression of this object.
        Specified by:
        toADQL in interface ADQLObject
        Returns:
        The corresponding ADQL expression.