Class Capture


  • public class Capture
    extends Object
    Represents the named capture of a Query. Captures are used to extract information from syntax trees when a query match occurs. Each instance can be uniquely identified by the Query it belongs to, along with its ordinal position within the same query.
    Since:
    1.7.0
    Author:
    Ozren Dabić
    See Also:
    Pattern, Query
    • Method Detail

      • disable

        public void disable()
        Disable this capture, preventing it from returning in matches. This will eliminate any resource usage from the Query associated with recording the capture.

        This can not be undone.

      • getQuantifier

        public Quantifier getQuantifier​(@NotNull
                                        @NotNull Pattern pattern)
        Get the capture quantifier for a given query Pattern.
        Parameters:
        pattern - the query pattern
        Returns:
        the quantifier
        Throws:
        NullPointerException - if pattern is null
        IllegalArgumentException - if the pattern is not present in the query
        Since:
        1.12.0
      • getQuantifiers

        public List<Quantifier> getQuantifiers()
        Get the capture quantifiers for all Query patterns. The order of the quantifiers in the returned list corresponds to the Pattern order in the query.
        Returns:
        the quantifiers
        Since:
        1.12.0
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object