getting known keys from an AttributeView

Alan Bateman Alan.Bateman at Sun.COM
Wed Jan 27 02:19:18 PST 2010


Joel Uckelman wrote:
> I've noticed that there seems to be no way to implement Path.readAttributes()
> without hardcoding all of the known attribute keys. For example, if you
> receive "foo:*" as an argument, then the docs require that you return a
> Map containing all of the FooAttributeView keys and their values. I see no
> programmatic way to find out what keys FooAttributeView supports, so the
> only thing I can do is build the map by hand, pair by pair. This is rather
> inconvenient, and generates a lot of boilerplate code. Have I missed
> something?
>
> It would be helpful if AttributeView had a keys() method which returned a
> String[] of the keys it supports via Path.getAttribute().
>
>   
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.


More information about the nio-dev mailing list