You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Andrea Francia <an...@andreafrancia.it> on 2008/10/09 19:43:41 UTC

[Design Question] Why FtpFile#listFiles() returns an array instead of a java.util.List?

FtpFile interface has this method:

   /**
    * List file objects. If not a directory or does not exist, null will be
    * returned. Files must be returned in alphabetical order.
    */
   FtpFile[] listFiles();

Why not:

   List<FtpFile> listFiles();

Using a java.util.List has those benefits:
 - you can create a unmodifiable view of your list without copying the 
original list
 - ftp implementor can implements some lazy loading

-- 
Andrea Francia
http://andreafrancia.blogspot.com/2008/07/colinux-linux-dentro-windows.html


Re: [Design Question] Why FtpFile#listFiles() returns an array instead of a java.util.List?

Posted by Andrea Francia <an...@andreafrancia.it>.
Niklas Gustavsson wrote:
> On Thu, Oct 9, 2008 at 7:43 PM, Andrea Francia <an...@andreafrancia.it> wrote:
>   
>> FtpFile interface has this method:
>>
>>  /**
>>   * List file objects. If not a directory or does not exist, null will be
>>   * returned. Files must be returned in alphabetical order.
>>   */
>>  FtpFile[] listFiles();
>>
>> Why not:
>>
>>  List<FtpFile> listFiles();
>>     
>
> This is a remain from before Java 1.5. I would be happy to make this change.
>   
Also the User#getAuthorities has similar problems.


-- 
Andrea Francia
http://andreafrancia.blogspot.com/2008/07/colinux-linux-dentro-windows.html


Re: [Design Question] Why FtpFile#listFiles() returns an array instead of a java.util.List?

Posted by Andrea Francia <an...@andreafrancia.it>.
Emmanuel Lecharny wrote:
> Andrea Francia wrote:
>> Niklas Gustavsson wrote:
>>> On Thu, Oct 9, 2008 at 7:43 PM, Andrea Francia 
>>> <an...@andreafrancia.it> wrote:
>>>  
>>>> FtpFile interface has this method:
>>>>
>>>>  /**
>>>>   * List file objects. If not a directory or does not exist, null 
>>>> will be
>>>>   * returned. Files must be returned in alphabetical order.
>>>>   */
>>>>  FtpFile[] listFiles();
>>>>
>>>> Why not:
>>>>
>>>>  List<FtpFile> listFiles();
>>>>     
>>>
>>> This is a remain from before Java 1.5. I would be happy to make this 
>>> change.
>>>   
>>
>> What about ?
>>
>> Set<FtpFile> listFiles();
>>
>> The same file could not be contained more than one time.
> And it will also have the other advantage to makes Andrea's wish to 
> have this method returning an undordered list accomplished ;)
Ops, is not for that .... you can return SortedSet.... :)
>
>


-- 
Andrea Francia
http://andreafrancia.blogspot.com/2008/07/colinux-linux-dentro-windows.html


Re: [Design Question] Why FtpFile#listFiles() returns an array instead of a java.util.List?

Posted by Emmanuel Lecharny <el...@gmail.com>.
Andrea Francia wrote:
> Niklas Gustavsson wrote:
>> On Thu, Oct 9, 2008 at 7:43 PM, Andrea Francia 
>> <an...@andreafrancia.it> wrote:
>>  
>>> FtpFile interface has this method:
>>>
>>>  /**
>>>   * List file objects. If not a directory or does not exist, null 
>>> will be
>>>   * returned. Files must be returned in alphabetical order.
>>>   */
>>>  FtpFile[] listFiles();
>>>
>>> Why not:
>>>
>>>  List<FtpFile> listFiles();
>>>     
>>
>> This is a remain from before Java 1.5. I would be happy to make this 
>> change.
>>   
>
> What about ?
>
> Set<FtpFile> listFiles();
>
> The same file could not be contained more than one time.
And it will also have the other advantage to makes Andrea's wish to have 
this method returning an undordered list accomplished ;)


-- 
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org



Re: [Design Question] Why FtpFile#listFiles() returns an array instead of a java.util.List?

Posted by Niklas Gustavsson <ni...@protocol7.com>.
On 10/9/08, Andrea Francia <an...@andreafrancia.it> wrote:
> What about ?
>
> Set<FtpFile> listFiles();
>
> The same file could not be contained more than one time.

That should be a SortedSet then.

/niklas

Re: [Design Question] Why FtpFile#listFiles() returns an array instead of a java.util.List?

Posted by Andrea Francia <an...@andreafrancia.it>.
Niklas Gustavsson wrote:
> On Thu, Oct 9, 2008 at 7:43 PM, Andrea Francia <an...@andreafrancia.it> wrote:
>   
>> FtpFile interface has this method:
>>
>>  /**
>>   * List file objects. If not a directory or does not exist, null will be
>>   * returned. Files must be returned in alphabetical order.
>>   */
>>  FtpFile[] listFiles();
>>
>> Why not:
>>
>>  List<FtpFile> listFiles();
>>     
>
> This is a remain from before Java 1.5. I would be happy to make this change.
>   

What about ?

 Set<FtpFile> listFiles();

The same file could not be contained more than one time.

-- 
Andrea Francia
http://andreafrancia.blogspot.com/2008/07/colinux-linux-dentro-windows.html


Re: [Design Question] Why FtpFile#listFiles() returns an array instead of a java.util.List?

Posted by Niklas Gustavsson <ni...@protocol7.com>.
On Thu, Oct 9, 2008 at 7:43 PM, Andrea Francia <an...@andreafrancia.it> wrote:
> FtpFile interface has this method:
>
>  /**
>   * List file objects. If not a directory or does not exist, null will be
>   * returned. Files must be returned in alphabetical order.
>   */
>  FtpFile[] listFiles();
>
> Why not:
>
>  List<FtpFile> listFiles();

This is a remain from before Java 1.5. I would be happy to make this change.

/niklas