public static FileSelector create(String path)
    {
        // path is a sequence of glob patterns separated 
        // by slashes. E.g. "[a-z]*/*/../foo/*.java".
        FileSelector first = null;
        FileSelector last = null;
        boolean any_wildcards = false;
        for (StringTokenizer path_scanner =
                 new StringTokenizer(path, "/");
             path_scanner.hasMoreTokens();)
        {
            String path_element = path_scanner.nextToken();
            FileSelector selector;
            if (path_element.equals("."))
                selector = new DotSelector();
            else if (path_element.equals(".."))
                selector = new DotDotSelector();
            else
            {
                PatternSelector pattern_selector =
                    new PatternSelector(path_element);
                if (first == null && path.startsWith("/"))
                    pattern_selector.markRoot();
                any_wildcards = 
                    any_wildcards || 
                    pattern_selector.hasWildcards();
                selector = pattern_selector;
            }
            if (first == null)
                first = selector;
            else
                last._next = selector;
            last = selector;
        }
        if (first == null)
        {
            PatternSelector pattern_selector =
                new PatternSelector("/");
            pattern_selector.markRoot();
            first = pattern_selector;
        }
        // If path has no wildcards in it, then the user may be
        // trying to identify a file so that it can be created,
        // e.g. "cp existing_file new_place". So for paths with
        // no wildcards, return a File object for that path.
        if (!any_wildcards)
            first.requestedPath(path);
        return first;
    }