code: protected JCRPathMatcher parsePathMatcher(LocationFactory locFactory, String path) throws RepositoryException
     {
  
        JCRPath knownPath = null;
        boolean forDescendants = false;
        boolean forAncestors = false;
  
        if (path.equals("*") || path.equals(".*"))
        {
           // any
           forDescendants = true;
           forAncestors = true;
        }
        else if (path.endsWith("*") && path.startsWith("*"))
        {
           forDescendants = true;
           forAncestors = true;
           knownPath = parsePath(path.substring(1, path.length() - 1), locFactory);
        }
        else if (path.endsWith("*"))
        {
           forDescendants = true;
           knownPath = parsePath(path.substring(0, path.length() - 1), locFactory);
        }
        else if (path.startsWith("*"))
        {
           forAncestors = true;
           knownPath = parsePath(path.substring(1), locFactory);
        }
        else
        {
           knownPath = parsePath(path, locFactory);
        }
  
        return new JCRPathMatcher(knownPath == null ? null : knownPath.getInternalPath(), forDescendants, forAncestors);
     }
docs: Parses JCR path matcher from string.
  
  @param path
  @return
  @throws RepositoryException