commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (NET-491) FTPClient - confusing parameters to setFileStructure/setFileType/setTransferMode
Date Sat, 08 Dec 2012 01:41:21 GMT

    [ https://issues.apache.org/jira/browse/NET-491?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13526967#comment-13526967
] 

Sebb commented on NET-491:
--------------------------

One possibility might be to have a table of bit flags, with one flag for each parameter type
(some values may apply to multiple parameters).

It might also be possible to get round the problem of the double nature of its second parameter
by overloading the ftpClient.setFileType() method, for example:

setFileType(FileTypeEnum, FormatEnum)
setFileType(FileTypeEnum, int) - in this case the enum must be LOCAL_FILE_TYPE.

The methods with int parameters could then be deprecated.

It may be worth doing both - i.e. checking the parameter values and adding enum support.
                
> FTPClient - confusing parameters to setFileStructure/setFileType/setTransferMode
> --------------------------------------------------------------------------------
>
>                 Key: NET-491
>                 URL: https://issues.apache.org/jira/browse/NET-491
>             Project: Commons Net
>          Issue Type: Improvement
>            Reporter: Sebb
>
> The methods setFileStructure/setFileType/setTransferMode all have int parameters which
are defined in the FTP class.
> However, not all the integers are valid for all the parameters, for example:
> ftpClient.setFileType(FTP.BINARY_FILE_TYPE, FTP.BINARY_FILE_TYPE)
> is not valid - the second parameter should be one of the _FORMAT - or a byte size if
the first parameter is FTP.LOCAL_FILE_TYPE.
> The parameters are used to look up an entry in the private _modes string, so garbage
values should be detected there.
> The example above shows that not all errors are currently detected.
> It might be possible to implement some basic additional checks to help catch errors.
> Using enums looks to be impossible, as the example shows.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message