Class LayerMatch

  • All Implemented Interfaces:
    nzilbb.util.CloneableBean

    public class LayerMatch
    extends Object
    implements nzilbb.util.CloneableBean
    One cell in a search matrix, containing a pattern to match on one layer.

    General principles, which are not enforced by these classes, are:

    • If pattern is set, then min and max should be null, and vice-versa
    • Only one LayerMatch in a Matrix has target == true.
    • Constructor Detail

      • LayerMatch

        public LayerMatch()
    • Method Detail

      • getId

        @ClonedProperty
        public String getId()
        Getter for id: The Layer ID to match.
        Returns:
        The Layer ID to match.
      • setId

        public LayerMatch setId​(String newId)
        Setter for id: The Layer ID to match.
        Parameters:
        newId - The Layer ID to match.
      • getPattern

        @ClonedProperty
        public String getPattern()
        Getter for pattern: The regular expression to match the label against.
        Returns:
        The regular expression to match the label against.
      • setPattern

        public LayerMatch setPattern​(String newPattern)
        Setter for pattern: The regular expression to match the label against.
        Parameters:
        newPattern - The regular expression to match the label against. An empty string results in null being assigned.
      • getNot

        @ClonedProperty
        public Boolean getNot()
        Getter for not: Whether the #pattern is being negated (i.e. selecting tokens that don't match) or not.
        Returns:
        Whether the #pattern is being negated (i.e. selecting tokens that don't match) or not.
      • setNot

        public LayerMatch setNot​(Boolean newNot)
        Setter for not: Whether the #pattern is being negated (i.e. selecting tokens that don't match) or not.
        Parameters:
        newNot - Whether the #pattern is being negated (i.e. selecting tokens that don't match) or not.
      • getMin

        @ClonedProperty
        public Double getMin()
        Getter for min: The minimum value for the label.
        Returns:
        The minimum value for the label.
      • setMin

        public LayerMatch setMin​(Double newMin)
        Setter for min: The minimum value for the label.
        Parameters:
        newMin - The minimum value for the label.
      • setMinString

        public LayerMatch setMinString​(String newMin)
        Setter for min.
        Parameters:
        newMin - A string representing the minimum value for the label. An empty string results in null being assigned.
      • getMax

        @ClonedProperty
        public Double getMax()
        Getter for max: The maximum value for the label.
        Returns:
        The maximum value for the label.
      • setMax

        public LayerMatch setMax​(Double newMax)
        Setter for max: The maximum value for the label.
        Parameters:
        newMax - The maximum value for the label.
      • setMaxString

        public LayerMatch setMaxString​(String newMax)
        Setter for max.
        Parameters:
        newMax - A string representing the maximum value for the label.
      • getTarget

        @ClonedProperty
        public Boolean getTarget()
        Getter for target: Whether this matrix cell is the target of the search.
        Returns:
        Whether this matrix cell is the target of the search.
      • setTarget

        public LayerMatch setTarget​(Boolean newTarget)
        Setter for target: Whether this matrix cell is the target of the search.
        Parameters:
        newTarget - Whether this matrix cell is the target of the search.
      • getAnchorStart

        @ClonedProperty
        public Boolean getAnchorStart()
        Getter for anchorStart: Whether this condition is anchored to the start of the word token.
        Returns:
        Whether this condition is anchored to the start of the word token.
      • setAnchorStart

        public LayerMatch setAnchorStart​(Boolean newAnchorStart)
        Setter for anchorStart: Whether this condition is anchored to the start of the word token.
        Parameters:
        newAnchorStart - Whether this condition is anchored to the start of the word token.
      • getAnchorEnd

        @ClonedProperty
        public Boolean getAnchorEnd()
        Getter for anchorEnd: Whether this condition is anchored to the end of the word token.
        Returns:
        Whether this condition is anchored to the end of the word token.
      • setAnchorEnd

        public LayerMatch setAnchorEnd​(Boolean newAnchorEnd)
        Setter for anchorEnd: Whether this condition is anchored to the end of the word token.
        Parameters:
        newAnchorEnd - Whether this condition is anchored to the end of the word token.
      • setNullBooleans

        public LayerMatch setNullBooleans()
        Ensures that Boolean attributes (target, not, anchorStart, anchorEnd) have non-null values. Any with null values are assumed to be false.
      • ensurePatternAnchored

        public LayerMatch ensurePatternAnchored()
        Ensures that the pattern includes anchoring to the beginning (^) and end ($) of input.

        After this method is called, pattern will instead be ^(pattern)$

      • toString

        public String toString()
        Returns the JSON serialization of this layer.
        Overrides:
        toString in class Object
        Returns:
        The JSON serialization of this layer.
      • HasCondition

        public static boolean HasCondition​(LayerMatch layer)
        Determines whether the given LayerMatch actually specifies a pattern, min, or max.
        Parameters:
        layer - The layer match to check.
        Returns:
        true if the given LayerMatch specifies a pattern, min, or max, false otherwise.
      • IsTarget

        public static boolean IsTarget​(LayerMatch layer)
        Determines whether the given LayerMatch actually specifies a pattern, min, or max.
        Parameters:
        layer - The layer match to check.
        Returns:
        true if the given LayerMatch specifies a pattern, min, or max, false otherwise.