Class XpathFilterElement

    • Constructor Detail

      • XpathFilterElement

        public XpathFilterElement​(String files,
                                  String checks,
                                  String message,
                                  String moduleId,
                                  String query)
        Creates a XpathElement instance.
        Parameters:
        files - regular expression for names of filtered files
        checks - regular expression for filtered check classes
        message - regular expression for messages.
        moduleId - the module id
        query - the xpath query
        Throws:
        IllegalArgumentException - if the xpath query is not expected.
      • XpathFilterElement

        public XpathFilterElement​(Pattern files,
                                  Pattern checks,
                                  Pattern message,
                                  String moduleId,
                                  String query)
        Creates a XpathElement instance.
        Parameters:
        files - regular expression for names of filtered files
        checks - regular expression for filtered check classes
        message - regular expression for messages.
        moduleId - the module id
        query - the xpath query
        Throws:
        IllegalArgumentException - if the xpath query is not correct.
    • Method Detail

      • accept

        public boolean accept​(TreeWalkerAuditEvent event)
        Description copied from interface: TreeWalkerFilter
        Determines whether or not a filtered TreeWalkerAuditEvent is accepted.
        Specified by:
        accept in interface TreeWalkerFilter
        Parameters:
        event - the TreeWalkerAuditEvent to filter.
        Returns:
        true if the event is accepted.
      • getItems

        private List<net.sf.saxon.om.Item> getItems​(TreeWalkerAuditEvent event)
        Returns list of nodes matching xpath expression given event.
        Parameters:
        event - TreeWalkerAuditEvent object
        Returns:
        list of nodes matching xpath expression given event
        Throws:
        IllegalStateException - if the xpath query could not be evaluated.
      • getPatternSafely

        private static String getPatternSafely​(Pattern pattern)
        Util method to get pattern String value from Pattern object safely, return null if pattern object is null.
        Parameters:
        pattern - pattern object
        Returns:
        value of pattern or null