Package adql.query.from

## Class ADQLJoin

- java.lang.Object
- - adql.query.from.ADQLJoin

- All Implemented Interfaces:
    `ADQLObject`, `FromContent`
  Direct Known Subclasses:
    `CrossJoin`, `InnerJoin`, `OuterJoin`

      public abstract class ADQLJoin
      extends java.lang.Object
      implements ADQLObject, FromContent

  Defines a join between two "tables".
  Version:
    1.4 (09/2017)
  Author:
    Grégory Mantelet (CDS;ARI)

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected ClauseConstraints` | `condition` | The join condition.
    `protected java.util.ArrayList<ADQLColumn>` | `lstColumns` | List of columns on which the join must be done.
    `protected boolean` | `natural` | Natural join (use of table keys) ?

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ADQLJoin​(ADQLJoin toCopy)` | Builds an ADQL join by copying the given one.
    `ADQLJoin​(FromContent left, FromContent right)` | Builds an `ADQLJoin` with at least two `FromContent` objects: the left and the right part of the join (usually two tables: T1 JOIN T2).

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static void` | `addAllExcept​(SearchColumnList itemsToAdd, SearchColumnList target, java.util.Map<java.lang.String,​DBCommonColumn> exception)` |
    `ADQLIterator` | `adqlIterator()` | Gets an iterator on the intern ADQL objects.
    `static DBColumn` | `findAtMostOneColumn​(java.lang.String columnName, byte caseSensitive, SearchColumnList list, boolean leftList)` |
    `static DBColumn` | `findExactlyOneColumn​(java.lang.String columnName, byte caseSensitive, SearchColumnList list, boolean leftList)` |
    `abstract 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.
    `ClauseConstraints` | `getJoinCondition()` | Gets the condition of this join (that's to say: the condition which follows the keyword ON).
    `java.util.Iterator<ADQLColumn>` | `getJoinedColumns()` | Gets the list of all columns on which the join is done (that's to say: the list of columns given with the keyword USING).
    `abstract java.lang.String` | `getJoinType()` | Gets the type of this join.
    `FromContent` | `getLeftTable()` | Gets the left "table" of this join.
    `java.lang.String` | `getName()` | Gets the name of this object in ADQL.
    `TextPosition` | `getPosition()` | Gets the position of this object/token in the ADQL query.
    `FromContent` | `getRightTable()` | Gets the right "table" of this join.
    `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` | `hasJoinedColumns()` | Tells whether this join has a list of columns to join.
    `static boolean` | `isCommonColumn​(DBColumn col)` | Tells whether the given column is a common column (that's to say, a unification of several columns of the same name).
    `boolean` | `isNatural()` | Indicates whether this join is natural or not.
    `void` | `setJoinCondition​(ClauseConstraints cond)` | Sets the condition of this join (that's to say: the condition which follows the keyword ON).
    `void` | `setJoinedColumns​(java.util.Collection<ADQLColumn> columns)` | Sets the list of all columns on which the join is done (that's to say: the list of columns given with the keyword USING).
    `void` | `setLeftTable​(FromContent table)` | Sets the left "table" of this join.
    `void` | `setNatural​(boolean natural)` | Lets indicate that this join is natural (it must use the table keys).
    `void` | `setPosition​(TextPosition position)` | Set the position of this `FromContent` in the given ADQL query string.
    `void` | `setRightTable​(FromContent table)` | Sets the right "table" of this join.
    `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`

- - ### Field Detail

    - #### natural

          protected boolean natural

      Natural join (use of table keys) ?

    - #### condition

          protected ClauseConstraints condition

      The join condition.

    - #### lstColumns

          protected java.util.ArrayList<ADQLColumn> lstColumns

      List of columns on which the join must be done.

  - ### Constructor Detail

    - #### ADQLJoin

          public ADQLJoin​(FromContent left,
                          FromContent right)

      Builds an `ADQLJoin` with at least two `FromContent` objects: the left and the right part of the join (usually two tables: T1 JOIN T2).
      Parameters:
        `left` - Left "table" of the join.
        `right` - Right "table" of the join.

    - #### ADQLJoin

          public ADQLJoin​(ADQLJoin toCopy)
                   throws java.lang.Exception

      Builds an ADQL join by copying the given one.
      Parameters:
        `toCopy` - The ADQLJoin to copy.
      Throws:
        `java.lang.Exception` - If there is an error during the copy.

  - ### Method Detail

    - #### isNatural

          public final boolean isNatural()

      Indicates whether this join is natural or not.
      Returns:
        true means this join is natural, false else.

    - #### setNatural

          public void setNatural​(boolean natural)

      Lets indicate that this join is natural (it must use the table keys).
      Parameters:
        `natural` - true means this join must be natural, false else.

    - #### getLeftTable

          public final FromContent getLeftTable()

      Gets the left "table" of this join.
      Returns:
        The left part of the join.

    - #### setLeftTable

          public void setLeftTable​(FromContent table)

      Sets the left "table" of this join.
      Parameters:
        `table` - The left part of the join.

    - #### getRightTable

          public final FromContent getRightTable()

      Gets the right "table" of this join.
      Returns:
        The right part of the join.

    - #### setRightTable

          public void setRightTable​(FromContent table)

      Sets the right "table" of this join.
      Parameters:
        `table` - The right part of the join.

    - #### getJoinCondition

          public final ClauseConstraints getJoinCondition()

      Gets the condition of this join (that's to say: the condition which follows the keyword ON).
      Returns:
        The join condition.

    - #### setJoinCondition

          public void setJoinCondition​(ClauseConstraints cond)

      Sets the condition of this join (that's to say: the condition which follows the keyword ON).
      Parameters:
        `cond` - The join condition (condition following ON).

    - #### getPosition

          public final TextPosition getPosition()

      Description copied from interface: `ADQLObject`

      Gets the position of this object/token in the ADQL query.

      By default, no position should be set.

      Specified by:
        `getPosition` in interface `ADQLObject`
      Returns:
        Position of this ADQL item in the ADQL query, or NULL if not written originally in the query (for example, if added afterwards.

    - #### setPosition

          public final void setPosition​(TextPosition position)

      Description copied from interface: `FromContent`
      Set the position of this `FromContent` in the given ADQL query string.
      Specified by:
        `setPosition` in interface `FromContent`
      Parameters:
        `position` - New position of this `FromContent`.

    - #### getJoinedColumns

          public final java.util.Iterator<ADQLColumn> getJoinedColumns()

      Gets the list of all columns on which the join is done (that's to say: the list of columns given with the keyword USING).
      Returns:
        The joined columns (columns listed in USING(...)).

    - #### hasJoinedColumns

          public final boolean hasJoinedColumns()

      Tells whether this join has a list of columns to join.
      Returns:
        true if some columns must be explicitly joined, false otherwise.

    - #### setJoinedColumns

          public void setJoinedColumns​(java.util.Collection<ADQLColumn> columns)

      Sets the list of all columns on which the join is done (that's to say: the list of columns given with the keyword USING).
      Parameters:
        `columns` - The joined columns.

    - #### 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.

    - #### adqlIterator

          public ADQLIterator adqlIterator()

      Description copied from interface: `ADQLObject`

      Gets an iterator on the intern ADQL objects.

      Note:The returned iterator is particularly used by a `ISearchHandler` extension to browse a whole ADQL tree.

      Specified by:
        `adqlIterator` in interface `ADQLObject`
      Returns:
        An ADQL objects iterator.
      See Also:
        `ADQLIterator`, `ISearchHandler`

    - #### 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.

    - #### getDBColumns

          public SearchColumnList getDBColumns()
                                        throws UnresolvedJoinException

      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 `DBColumn`s.
      Throws:
        `UnresolvedJoinException` - If a join is not possible.

    - #### addAllExcept

          public static final void addAllExcept​(SearchColumnList itemsToAdd,
                                                SearchColumnList target,
                                                java.util.Map<java.lang.String,​DBCommonColumn> exception)

    - #### findExactlyOneColumn

          public static final DBColumn findExactlyOneColumn​(java.lang.String columnName,
                                                            byte caseSensitive,
                                                            SearchColumnList list,
                                                            boolean leftList)
                                                     throws UnresolvedJoinException

      Throws:
        `UnresolvedJoinException`

    - #### findAtMostOneColumn

          public static final DBColumn findAtMostOneColumn​(java.lang.String columnName,
                                                           byte caseSensitive,
                                                           SearchColumnList list,
                                                           boolean leftList)
                                                    throws UnresolvedJoinException

      Throws:
        `UnresolvedJoinException`

    - #### isCommonColumn

          public static final boolean isCommonColumn​(DBColumn col)

      Tells whether the given column is a common column (that's to say, a unification of several columns of the same name).
      Parameters:
        `col` - A DBColumn.
      Returns:
        true if the given column is a common column, false otherwise (particularly if col = null).

    - #### getTables

          public java.util.List<ADQLTable> getTables()

      Description copied from interface: `FromContent`
      Gets all `ADQLTable` instances contained in this FROM part (itself included, if it is an `ADQLTable`).
      Specified by:
        `getTables` in interface `FromContent`
      Returns:
        The list of all `ADQLTable`s found.

    - #### 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.

    - #### getJoinType

          public abstract java.lang.String getJoinType()

      Gets the type of this join.
      Returns:
        Its join type (i.e. CROSS JOIN, LEFT JOIN, LEFT OUTER JOIN, ...).

    - #### getCopy

          public abstract 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.