Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.3.0)

E17493-04


oracle.javatools.db.sql
Class SQLFragmentUtils

java.lang.Object
  extended by oracle.javatools.db.sql.SQLFragmentUtils


public final class SQLFragmentUtils
extends java.lang.Object

Utilities for dealing with SQLFragments.


Method Summary
static java.util.List<SelectObject> expandStarColumns(SQLQuery query)
          Gets an expanded list of SelectObjects for the given query that has any wildcard * columns expanded to the underlying table columns.
static SelectObject[] getSelectObjects(SQLQuery query)
          Gets the SelectObjects for this query.
static Relation getTable(FromObject from)
           
static java.lang.String getTableName(FromObjectUsage usage)
          Gets the table name used by the given FromObjectUsage (could be an alias rather than an actual table's name).
static boolean hasPKCols(java.util.Collection<java.lang.String> colNames, FromObject from)
          Tests whether the list of columns contains a PK column for the table referenced by the given given FromObject
static java.util.Collection<java.lang.String> listColumnNames(SQLFragment expression)
          Lists the columns available from the given SQLFragment.
static java.util.Collection<Column> listColumns(SQLFragment expression)
          Lists the columns available from the given SQLFragment.
static java.util.Collection<ColumnUsage> listColumnUsages(SQLFragment expression)
          Lists the columns available from the given SQLFragment.
static java.util.Collection<java.lang.String> listCommonColumns(FromObject left, FromObject right)
          Lists the names of columns common to both FromObjects.
static java.util.Collection<java.lang.String> listCommonColumns(JoinObject join)
          List the names of columns common to both the left and right side of the given join.
static java.util.Set<java.lang.String> listFromObjectNames(SQLQuery query)
          Lists the names of the FromObjects that are defined in the given query (does not include subqueries, just the namespace available in the current query).
static void replaceStarColumns(SQLQuery query)
          Alters the given SQLQuery so that any asterisk columns are expanded into multiple select objects.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Method Detail

getSelectObjects

public static SelectObject[] getSelectObjects(SQLQuery query)
Gets the SelectObjects for this query. If the query contains a set operator (or operators) the SelectObjects of the first "real" query are returned so that the list is meaningful.

It is only expected that this is useful for logic that determines the "columns" to match a given query.

Parameters:
query - the query to get a list of SelectObjects for
Returns:
the SelectObjects of the query, or the SelectObjects of the first part of a union (or similar) query.

replaceStarColumns

public static void replaceStarColumns(SQLQuery query)
Alters the given SQLQuery so that any asterisk columns are expanded into multiple select objects. For example "SELECT * FROM TABLE1" is changed to become "SELECT COL1, COL2... FROM TABLE1" where COL1, COL2... are the columns available on TABLE1.
Parameters:
query - the query to expand.

expandStarColumns

public static java.util.List<SelectObject> expandStarColumns(SQLQuery query)
Gets an expanded list of SelectObjects for the given query that has any wildcard * columns expanded to the underlying table columns.

getTable

public static Relation getTable(FromObject from)

getTableName

public static java.lang.String getTableName(FromObjectUsage usage)
Gets the table name used by the given FromObjectUsage (could be an alias rather than an actual table's name).
Parameters:
usage - the FromObjectUsage to get the table name/alias for
Returns:
the table's name/alias or null if none could be determined

listFromObjectNames

public static java.util.Set<java.lang.String> listFromObjectNames(SQLQuery query)
Lists the names of the FromObjects that are defined in the given query (does not include subqueries, just the namespace available in the current query).

listCommonColumns

public static java.util.Collection<java.lang.String> listCommonColumns(JoinObject join)
List the names of columns common to both the left and right side of the given join.

listCommonColumns

public static java.util.Collection<java.lang.String> listCommonColumns(FromObject left,
                                                                       FromObject right)
Lists the names of columns common to both FromObjects.

listColumns

public static java.util.Collection<Column> listColumns(SQLFragment expression)
Lists the columns available from the given SQLFragment. The fragment must be a FromObject, JoinObject or RelationUsage.
Parameters:
expression - the expression to query
Returns:
valid Columns that could be associated with the given expression

listColumnUsages

public static java.util.Collection<ColumnUsage> listColumnUsages(SQLFragment expression)
Lists the columns available from the given SQLFragment. The fragment must be a FromObject, JoinObject or RelationUsage.
Parameters:
expression - the expression to query
Returns:
valid ColumnUsages that could be associated with the given expression

listColumnNames

public static java.util.Collection<java.lang.String> listColumnNames(SQLFragment expression)
Lists the columns available from the given SQLFragment. The fragment must be a FromObject, JoinObject or RelationUsage.
Parameters:
expression - the expression to query
Returns:
valid Column names that could be associated with the given expression

hasPKCols

public static boolean hasPKCols(java.util.Collection<java.lang.String> colNames,
                                FromObject from)
Tests whether the list of columns contains a PK column for the table referenced by the given given FromObject
Parameters:
colNames - the name of the columns from the used table
from - the FromObject (from which the table is found)
Returns:
true if the colNames contains a PK column

Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.3.0)

E17493-04


Copyright © 1997, 2012, Oracle. All rights reserved.