Trouble understanding the meaning of the API

Marcel Ammerlaan marcel-snoracle-nio at dyskolus.com
Fri Feb 5 02:27:22 PST 2010


Alan Bateman wrote:
> Marcel Ammerlaan wrote:
>> An even stronger requirement on toString() would be that 
>> FileSystem.getPath("/bin/ls") equals 
>> FileSystem.getPath(FileSystem.getPath("/bin/ls").toString())
>> to make sure the the human-readable equivalent of the path can 
>> actually be related to the technical path that's used by the filesystem.
> It's not possible to provide this guarantee. The getPath method might 
> remove redundant separators (for example) so 
> getPath("////////bin/////ls").toString() returns "/bin/ls". The 
> toString method has a statement to explain that it might differ. There 
> are other more complications reasons that arise when the file system 
> representation isn't Unicode.
>
Thanks for the answers so far. On the equality: if was refering to Path 
equality, not String equality.
So the requirement on toString() would be:
Path p1 = FileSystem.getPath("/bin/ls");
Path p2 = FileSystem.getPath(p1.toString());
p1.equals(p2) == true

Should filesystem providers at least adhere to this requirement?

Regards,

Marcel Ammerlaan.




More information about the nio-discuss mailing list