[ 
https://issues.apache.org/jira/browse/VFS-245?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12935855#action_12935855
 ] 

Ralph Goers commented on VFS-245:
---------------------------------

I've experimented with various options for this.

I looked at removing the FileType attribute. Unfortunately, resolveName in 
DefaultFileSystemManager relies on it to determine whether the FileName is a 
File vs a Folder so removing it would break that.

I looked at making the FileType immutable and removing the setType method. This 
is doable but requires that AbstractFileObject change the setType method to 
create a new FileName when the type is changed instead of modifying the 
FileName. As a consequence this just moves the immutability problem since 
FileObjects are cached by their FileName.

While the assessment above is correct, I disagree with the outcome. appendURI 
is provided to allow FileName implementations to include information such as 
the userid and password into the path. Furthermore, the only thing the FileType 
is used for is to determine whether to append a '/' to the path.  Given this it 
makes more sense to me to modify equals(), hashcode, and compareTo to use a 
method that generates a URI that contains the results from appendURI but does 
not try to append the '/' to the path. This will result in these three methods 
returning constant values regardless of what the FileType might be.

> FileName interface says that it is immutable, however 
> AbstractFileName.setType(FileType type) flouts this rule
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: VFS-245
>                 URL: https://issues.apache.org/jira/browse/VFS-245
>             Project: Commons VFS
>          Issue Type: Bug
>            Reporter: Sebb
>         Attachments: AbstractFileName.java.patch
>
>
> FileName interface says that it is immutable, however 
> AbstractFileName.setType(FileType type) flouts this rule.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to