You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@empire-db.apache.org by Francis De Brabandere <fr...@gmail.com> on 2009/02/24 22:34:22 UTC

DBCommand.select()

DBCommand has this:

    /**
     * Adds a list of column expression to the select clause
     *
     * @param columns the column expressions to add
     */
    public void select(Collection<DBColumnExpr> columns)
    {
        for (DBColumnExpr expr : columns)
            select(expr);
    }

    /**
     * Adds a list of column expression to the select clause
     *
     * @param columns the column expressions to add
     */
    public void select(List<DBColumn> columns)
    {
        for (int i = 0; i < columns.size(); i++)
            select(columns.get(i));
    }

Why the second select method if the first one is able to handle both?

-- 
http://www.somatik.be
Microsoft gives you windows, Linux gives you the whole house.

Re: DBCommand.select()

Posted by Francis De Brabandere <fr...@gmail.com>.
just rewrote the functions

public void select(Collection<? extends DBColumnExpr> columns)

same cleanups for the group by clause

On Wed, Feb 25, 2009 at 9:57 AM, Rainer Döbele <do...@esteam.de> wrote:
> Hi Franics,
>
> correct. This is old code that was originally writte for Java 1.2. Some methods have been altered for Java 5, others haven't.
>
> For the second case:
> List<DBColumn> cannot be automatically casted into a Collection<DBColumnExpr>. So although the implementation is the same it is necessary to have both function signatures.
> Although I am not sure whether we could replace List<DBColumn> with Collection<DBColumn>.
>
> If you want you can rewrite the variable args function - or do you prefer me to do it?
>
> Regards
> Rainer
>
>
> Francis De Brabandere
>> Re: DBCommand.select()
>>
>> and an other one:
>>
>> Can't all the following methods and more be covered as public void
>> select(DBColumnExpr...expr) ?
>>
>>     /**
>>      * Adds a DBColumnExpr object to the Vector: 'select'.
>>      *
>>      * @param expr the DBColumnExpr object
>>      */
>>     public void select(DBColumnExpr expr)
>>     { // Select this column
>>         if (select == null)
>>             select = new ArrayList<DBColumnExpr>();
>>         if (expr != null && select.contains(expr) == false)
>>             select.add(expr);
>>     }
>>
>>     /**
>>      * This helper function adds two DBColumnExpr objects
>>      * to the Vector: 'select'
>>      *
>>      * @param expr1 the first DBColumnExpr object
>>      * @param expr2 the second DBColumnExpr object
>>      */
>>     public void select(DBColumnExpr expr1, DBColumnExpr expr2)
>>     {
>>         select(expr1);
>>         select(expr2);
>>     }
>>
>>     /**
>>      * This helper function adds three DBColumnExpr objects to the
>> Vector: 'select'.
>>      */
>>     public void select(DBColumnExpr expr1, DBColumnExpr expr2,
>> DBColumnExpr expr3)
>>     {
>>         select(expr1);
>>         select(expr2);
>>         select(expr3);
>>     }
>>
>>     /**
>>      * This helper function adds four DBColumnExpr objects to the
>> Vector: 'select'.
>>      */
>>     public void select(DBColumnExpr expr1, DBColumnExpr expr2,
>> DBColumnExpr expr3, DBColumnExpr expr4)
>>     {
>>         select(expr1);
>>         select(expr2);
>>         select(expr3);
>>         select(expr4);
>>     }
>>
>>     /**
>>      * This helper function adds five DBColumnExpr objects
>>      * to the Vector: 'select'.
>>      */
>>     public void select(DBColumnExpr expr1, DBColumnExpr expr2,
>> DBColumnExpr expr3, DBColumnExpr expr4, DBColumnExpr expr5)
>>     {
>>         select(expr1);
>>         select(expr2);
>>         select(expr3);
>>         select(expr4);
>>         select(expr5);
>>     }
>>
>>     /**
>>      * This helper function adds an array of DBColumnExpr
>>      * objects to list of select-columns.
>>      */
>>     public void select(DBColumnExpr[] exprList)
>>     {
>>         for (int i=0; i<exprList.length; i++)
>>         {
>>             select(exprList[i]);
>>         }
>>     }
>>
>> On Tue, Feb 24, 2009 at 10:34 PM, Francis De Brabandere
>> <fr...@gmail.com> wrote:
>> > DBCommand has this:
>> >
>> >    /**
>> >     * Adds a list of column expression to the select clause
>> >     *
>> >     * @param columns the column expressions to add
>> >     */
>> >    public void select(Collection<DBColumnExpr> columns)
>> >    {
>> >        for (DBColumnExpr expr : columns)
>> >            select(expr);
>> >    }
>> >
>> >    /**
>> >     * Adds a list of column expression to the select clause
>> >     *
>> >     * @param columns the column expressions to add
>> >     */
>> >    public void select(List<DBColumn> columns)
>> >    {
>> >        for (int i = 0; i < columns.size(); i++)
>> >            select(columns.get(i));
>> >    }
>> >
>> > Why the second select method if the first one is able to handle both?
>> >
>> > --
>> > http://www.somatik.be
>> > Microsoft gives you windows, Linux gives you the whole house.
>> >
>>
>>
>>
>> --
>> http://www.somatik.be
>> Microsoft gives you windows, Linux gives you the whole house.
>



-- 
http://www.somatik.be
Microsoft gives you windows, Linux gives you the whole house.

AW: DBCommand.select()

Posted by Rainer Döbele <do...@esteam.de>.
Hi Franics,

correct. This is old code that was originally writte for Java 1.2. Some methods have been altered for Java 5, others haven't.

For the second case:
List<DBColumn> cannot be automatically casted into a Collection<DBColumnExpr>. So although the implementation is the same it is necessary to have both function signatures.
Although I am not sure whether we could replace List<DBColumn> with Collection<DBColumn>.

If you want you can rewrite the variable args function - or do you prefer me to do it?

Regards
Rainer


Francis De Brabandere
> Re: DBCommand.select()
> 
> and an other one:
> 
> Can't all the following methods and more be covered as public void
> select(DBColumnExpr...expr) ?
> 
>     /**
>      * Adds a DBColumnExpr object to the Vector: 'select'.
>      *
>      * @param expr the DBColumnExpr object
>      */
>     public void select(DBColumnExpr expr)
>     { // Select this column
>         if (select == null)
>             select = new ArrayList<DBColumnExpr>();
>         if (expr != null && select.contains(expr) == false)
>             select.add(expr);
>     }
> 
>     /**
>      * This helper function adds two DBColumnExpr objects
>      * to the Vector: 'select'
>      *
>      * @param expr1 the first DBColumnExpr object
>      * @param expr2 the second DBColumnExpr object
>      */
>     public void select(DBColumnExpr expr1, DBColumnExpr expr2)
>     {
>         select(expr1);
>         select(expr2);
>     }
> 
>     /**
>      * This helper function adds three DBColumnExpr objects to the
> Vector: 'select'.
>      */
>     public void select(DBColumnExpr expr1, DBColumnExpr expr2,
> DBColumnExpr expr3)
>     {
>         select(expr1);
>         select(expr2);
>         select(expr3);
>     }
> 
>     /**
>      * This helper function adds four DBColumnExpr objects to the
> Vector: 'select'.
>      */
>     public void select(DBColumnExpr expr1, DBColumnExpr expr2,
> DBColumnExpr expr3, DBColumnExpr expr4)
>     {
>         select(expr1);
>         select(expr2);
>         select(expr3);
>         select(expr4);
>     }
> 
>     /**
>      * This helper function adds five DBColumnExpr objects
>      * to the Vector: 'select'.
>      */
>     public void select(DBColumnExpr expr1, DBColumnExpr expr2,
> DBColumnExpr expr3, DBColumnExpr expr4, DBColumnExpr expr5)
>     {
>         select(expr1);
>         select(expr2);
>         select(expr3);
>         select(expr4);
>         select(expr5);
>     }
> 
>     /**
>      * This helper function adds an array of DBColumnExpr
>      * objects to list of select-columns.
>      */
>     public void select(DBColumnExpr[] exprList)
>     {
>         for (int i=0; i<exprList.length; i++)
>         {
>             select(exprList[i]);
>         }
>     }
> 
> On Tue, Feb 24, 2009 at 10:34 PM, Francis De Brabandere
> <fr...@gmail.com> wrote:
> > DBCommand has this:
> >
> >    /**
> >     * Adds a list of column expression to the select clause
> >     *
> >     * @param columns the column expressions to add
> >     */
> >    public void select(Collection<DBColumnExpr> columns)
> >    {
> >        for (DBColumnExpr expr : columns)
> >            select(expr);
> >    }
> >
> >    /**
> >     * Adds a list of column expression to the select clause
> >     *
> >     * @param columns the column expressions to add
> >     */
> >    public void select(List<DBColumn> columns)
> >    {
> >        for (int i = 0; i < columns.size(); i++)
> >            select(columns.get(i));
> >    }
> >
> > Why the second select method if the first one is able to handle both?
> >
> > --
> > http://www.somatik.be
> > Microsoft gives you windows, Linux gives you the whole house.
> >
> 
> 
> 
> --
> http://www.somatik.be
> Microsoft gives you windows, Linux gives you the whole house.

Re: DBCommand.select()

Posted by Francis De Brabandere <fr...@gmail.com>.
and an other one:

Can't all the following methods and more be covered as public void
select(DBColumnExpr...expr) ?

    /**
     * Adds a DBColumnExpr object to the Vector: 'select'.
     *
     * @param expr the DBColumnExpr object
     */
    public void select(DBColumnExpr expr)
    { // Select this column
        if (select == null)
            select = new ArrayList<DBColumnExpr>();
        if (expr != null && select.contains(expr) == false)
            select.add(expr);
    }

    /**
     * This helper function adds two DBColumnExpr objects
     * to the Vector: 'select'
     *
     * @param expr1 the first DBColumnExpr object
     * @param expr2 the second DBColumnExpr object
     */
    public void select(DBColumnExpr expr1, DBColumnExpr expr2)
    {
        select(expr1);
        select(expr2);
    }

    /**
     * This helper function adds three DBColumnExpr objects to the
Vector: 'select'.
     */
    public void select(DBColumnExpr expr1, DBColumnExpr expr2,
DBColumnExpr expr3)
    {
        select(expr1);
        select(expr2);
        select(expr3);
    }

    /**
     * This helper function adds four DBColumnExpr objects to the
Vector: 'select'.
     */
    public void select(DBColumnExpr expr1, DBColumnExpr expr2,
DBColumnExpr expr3, DBColumnExpr expr4)
    {
        select(expr1);
        select(expr2);
        select(expr3);
        select(expr4);
    }

    /**
     * This helper function adds five DBColumnExpr objects
     * to the Vector: 'select'.
     */
    public void select(DBColumnExpr expr1, DBColumnExpr expr2,
DBColumnExpr expr3, DBColumnExpr expr4, DBColumnExpr expr5)
    {
        select(expr1);
        select(expr2);
        select(expr3);
        select(expr4);
        select(expr5);
    }

    /**
     * This helper function adds an array of DBColumnExpr
     * objects to list of select-columns.
     */
    public void select(DBColumnExpr[] exprList)
    {
        for (int i=0; i<exprList.length; i++)
        {
            select(exprList[i]);
        }
    }

On Tue, Feb 24, 2009 at 10:34 PM, Francis De Brabandere
<fr...@gmail.com> wrote:
> DBCommand has this:
>
>    /**
>     * Adds a list of column expression to the select clause
>     *
>     * @param columns the column expressions to add
>     */
>    public void select(Collection<DBColumnExpr> columns)
>    {
>        for (DBColumnExpr expr : columns)
>            select(expr);
>    }
>
>    /**
>     * Adds a list of column expression to the select clause
>     *
>     * @param columns the column expressions to add
>     */
>    public void select(List<DBColumn> columns)
>    {
>        for (int i = 0; i < columns.size(); i++)
>            select(columns.get(i));
>    }
>
> Why the second select method if the first one is able to handle both?
>
> --
> http://www.somatik.be
> Microsoft gives you windows, Linux gives you the whole house.
>



-- 
http://www.somatik.be
Microsoft gives you windows, Linux gives you the whole house.