Alan Bateman Alan.Bateman at Sun.COM
Sat Nov 1 03:37:07 PDT 2008

Rémi Forax wrote:
> Hi alan, hi all,
> I have some questions about FileSystem.getNameMatcher() :
> First its name, i would prefer something like getNamePathMatcher(),
> after all it returns a PathMatcher.
Rémi - A late reply as I have been away for a few days.

It was named getNameMatcher as it currently only matches on file names 
and "getNamePathMatcher" seemed a mouthful (I do of course appreciate 
you taking time to find inconsistencies and naming issues). In any case, 
a number of people have pinged me about matching across directory 
boundaries (** matching). This requires a bit of spec work. When that is 
done then renaming it to getPathMatcher seems natural.

> Why getNameMatcher doesn't  reuse the  same design than setOptions()
> to specify the syntax i.e.
> interface Syntax {
>  String name();
> }
> public enum StandardSyntax {
>  glob, regex
> }
> PathMatcher getNameMatcher(Syntax syntax, String regex) {
>  ...
> }
The API is using this "extensible enum" pattern in places where we 
expect there will be platform/provider specific extensions. For pattern 
matching we haven't seen a big need beyond regular expressions and 
globbing so this is why it wasn't used here. From a consistency point of 
view, you are right (but it does require yet another interface and 
enum). I'll think about it. As it happens, Tom Hawtin also mentioned 
this one to me recently. FYI, in an earlier version there was a single 
parameter that took the form "syntax:pattern".


More information about the nio-dev mailing list