Class GlobbingPathFilter

  • All Implemented Interfaces:
    EventFilter

    public class GlobbingPathFilter
    extends Object
    implements EventFilter
    This Filter implementation supports filtering on paths using simple glob patterns. Such a pattern is a string denoting a path. Each element of the pattern is matched against the corresponding element of a path. Elements of the pattern are matched literally except for the special elements * and ** where the former matches an arbitrary path element and the latter matches any number of path elements (including none).

    Note: an empty path pattern matches no path.

    Note: path patterns only match against the corresponding elements of the path and do not distinguish between absolute and relative paths.

    Note: there is no way to escape * and **.

    Examples:

        q matches q only
        * matches character matches zero or more characters of a name component without crossing path boundaries (ie without crossing /)
        ** matches every path
        a/b/c matches a/b/c only
        a/*/c matches a/x/c for every element x
        a/*.html/c matches a/x.html/c for every character sequence x (that doesn't include /)
        a/*.*/c matches a/x.y/c for every character sequence x and y (that don't include /)
        **/y/z match every path ending in y/z
        r/s/t/** matches r/s/t and all its descendants
     
    • Constructor Detail

      • GlobbingPathFilter

        public GlobbingPathFilter​(@NotNull
                                  @NotNull String pattern,
                                  Map<String,​Pattern> patternMap)
      • GlobbingPathFilter

        public GlobbingPathFilter​(@NotNull
                                  @NotNull String pattern)
        for testing only - use variant which passes the patternMap for productive code
    • Method Detail

      • includeAdd

        public boolean includeAdd​(PropertyState after)
        Description copied from interface: EventFilter
        Include an added property
        Specified by:
        includeAdd in interface EventFilter
        Parameters:
        after - added property
        Returns:
        true if the property should be included
      • includeChange

        public boolean includeChange​(PropertyState before,
                                     PropertyState after)
        Description copied from interface: EventFilter
        Include a changed property
        Specified by:
        includeChange in interface EventFilter
        Parameters:
        before - property before the change
        after - property after the change
        Returns:
        true if the property should be included
      • includeDelete

        public boolean includeDelete​(PropertyState before)
        Description copied from interface: EventFilter
        Include a deleted property
        Specified by:
        includeDelete in interface EventFilter
        Parameters:
        before - deleted property
        Returns:
        true if the property should be included
      • includeAdd

        public boolean includeAdd​(String name,
                                  NodeState after)
        Description copied from interface: EventFilter
        Include an added node
        Specified by:
        includeAdd in interface EventFilter
        Parameters:
        name - name of the node
        after - added node
        Returns:
        true if the node should be included
      • includeDelete

        public boolean includeDelete​(String name,
                                     NodeState before)
        Description copied from interface: EventFilter
        Include a deleted node
        Specified by:
        includeDelete in interface EventFilter
        Parameters:
        name - name of the node
        before - deleted node
        Returns:
        true if the node should be included
      • includeMove

        public boolean includeMove​(String sourcePath,
                                   String name,
                                   NodeState moved)
        Description copied from interface: EventFilter
        Include a moved node
        Specified by:
        includeMove in interface EventFilter
        Parameters:
        sourcePath - source path of the move operation
        name - name of the moved node
        moved - the moved node
        Returns:
        true if the node should be included
      • includeReorder

        public boolean includeReorder​(String destName,
                                      String name,
                                      NodeState reordered)
        Description copied from interface: EventFilter
        Include a reordered node
        Specified by:
        includeReorder in interface EventFilter
        Parameters:
        destName - name of the orderBefore() destination node
        name - name of the reordered node
        reordered - the reordered node
        Returns:
        true if the node should be included
      • create

        public EventFilter create​(String name,
                                  NodeState before,
                                  NodeState after)
        Description copied from interface: EventFilter
        Factory for creating a filter instance for the given child node
        Specified by:
        create in interface EventFilter
        Parameters:
        name - name of the child node
        before - before state of the child node
        after - after state of the child node
        Returns:
        filter instance for filtering the child node or null to exclude the sub tree rooted at this child node.