コード例 #1
0
        /*
         * Move the input table to the top of the selection list.
         */
        public static void setPriority(java.util.Vector <Object> inputList, String inputTable)
        {
            String tableName;
            int    i;

            if (inputList == null)
            {
                return;
            }
            for (i = 0; i < inputList.size(); i++)
            {
                tableName = (String)inputList.elementAt(i);
                if (tableName.equals(inputTable))
                {
                    if (i > 0)
                    {
                        inputList.removeElementAt(i);
                        inputList.insertElementAt(tableName, 0);
                    }
                    break;
                }
            }
        }
コード例 #2
0
        /*
         * Validate the column specifications by checking against the tables.
         */
        public void validateColumns() //throws TinySQLException
        {
            String       columnName, columnAlias, columnContext;
            TsColumn     columnObject;
            bool         selectStar;
            TinySQLTable jtbl;
            int          i, j;

/*
 *    Check for a column named *
 */
            selectStar = false;
            for (i = 0; i < columnList.size(); i++)
            {
                columnName    = (String)columnList.elementAt(i);
                columnContext = (String)contextList.elementAt(i);
                if (columnName.equals("*"))
                {
                    if (!columnContext.equals("SELECT"))
                    {
                        throw new TinySQLException("* must be a SELECT column.");
                    }
                    selectStar = true;
                    break;
                }
            }
            if (selectStar)
            {
/*
 *       A column * has been found.  Delete the existing list of SELECT
 *       columns and replace by using an enumeration variable to cycle through
 *       the columns in the tables Hashtable.
 */
                for (i = 0; i < columnList.size(); i++)
                {
                    columnContext = (String)contextList.elementAt(i);
                    if (columnContext.equals("SELECT"))
                    {
                        columnList.removeElementAt(i);
                        contextList.removeElementAt(i);
                        columnAliasList.removeElementAt(i);
                    }
                }
                for (i = 0; i < tableList.size(); i++)
                {
                    jtbl = (TinySQLTable)tables.get((String)tableList.elementAt(i));

/*
 *          Expand to all columns.
 */
                    for (j = 0; j < jtbl.columnNameKeys.size(); j++)
                    {
                        columnName = (String)jtbl.columnNameKeys.elementAt(j);
                        columnList.addElement(jtbl.table + "->" + jtbl.tableAlias
                                              + "." + columnName);
                        columnAliasList.addElement(columnName);
                        contextList.addElement("SELECT");
                    }
                }
            }

/*
 *    Build a column object for each selected column.
 */
            if (tables == (java.util.Hashtable <Object, Object>)null)
            {
                java.lang.SystemJ.outJ.println("*****Column validation - no tables defined.");
            }
            for (i = 0; i < columnList.size(); i++)
            {
                columnName    = (String)columnList.elementAt(i);
                columnContext = (String)contextList.elementAt(i);
                columnAlias   = (String)null;
                if (i < columnAliasList.size())
                {
                    columnAlias = (String)columnAliasList.elementAt(i);
                }
                columnObject       = new TsColumn(columnName, tables, columnContext);
                columnObject.alias = UtilString.removeQuotes(columnAlias);
                columns.addElement(columnObject);
            }
        }