getting known keys from an AttributeView

Joel Uckelman uckelman at nomic.net
Wed Jan 27 03:20:03 PST 2010


Thus spake Alan Bateman:
>
> Right, if a provider supports FooAttributeView then it must have 
> semantic knowledge of all attributes that the view defines (the 
> exception being UserDeifnedFileAttributeView where the values are 
> opaque). For dynamic access, where the user chooses to identity the 
> attributes by name, then it does mean that the provider have some way to 
> map the names to specific attributes (mundane, but not hard). I'm 
> curious how the suggested keys method improves things. It just avoids 
> helps the provider map "*" to the list of attributes names but the 
> provider must still have semantic knowledge of each of the attributes, 
> and know each of their names.
> 
> -Alan.

If you have a way to get the attrib names programatically, then
Path.readAttributes() only needs contain code for parsing the attribute
string, and can be basically the same across all Path implementations.
Without it, you end up having to list out all of the possible attributes,
which means that you're now maintaining this list in multiple places.
(For example, the names from BasicFileAttributeView will be repeated in
every readAttributes() implementation.) This is error-prone.
 
-- 
J.


More information about the nio-dev mailing list