Class Component

  • All Implemented Interfaces:
    Serializable
    Direct Known Subclasses:
    AnyChar, CharacterSet, Literal

    public abstract class Component
    extends Object
    implements Serializable
    Abstract base class for all regular expression components. Every component has a minimum and maximum match length. The component must match at least the minimum length and at most the maximum length (inclusive).
    Author:
    Charles Rapp
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ANY_CHAR
      This component matches any character.
      static int CHARACTER_SET
      A character set component matches only those characters in the set (positive) or not in the set (negative).
      static int LITERAL
      A literal component matches exactly.
      protected int mIndex
      The component's position within the regular expression pattern.
      protected int mMaximumSize
      The component's maximum possible length.
      protected int mMinimumSize
      The component's minimum possible length.
      protected int mType
      The component's type.
      static int NO_MAX_MATCH_LIMIT
      The maximum range limit is set to this value when the the limit is infinite.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Component​(int type, int minLength, int maxLength, int index)
      Sets the component's type, minimum and maximum length.
    • Field Detail

      • NO_MAX_MATCH_LIMIT

        public static final int NO_MAX_MATCH_LIMIT
        The maximum range limit is set to this value when the the limit is infinite.
        See Also:
        Constant Field Values
      • LITERAL

        public static final int LITERAL
        A literal component matches exactly.
        See Also:
        Constant Field Values
      • CHARACTER_SET

        public static final int CHARACTER_SET
        A character set component matches only those characters in the set (positive) or not in the set (negative).
        See Also:
        Constant Field Values
      • ANY_CHAR

        public static final int ANY_CHAR
        This component matches any character.
        See Also:
        Constant Field Values
      • mType

        protected final int mType
        The component's type. Must be one of LITERAL, CHARACTER_SET or ANY_CHAR.
      • mMinimumSize

        protected final int mMinimumSize
        The component's minimum possible length.
      • mMaximumSize

        protected final int mMaximumSize
        The component's maximum possible length.
      • mIndex

        protected final int mIndex
        The component's position within the regular expression pattern. Indexing begins at zero.
    • Constructor Detail

      • Component

        protected Component​(int type,
                            int minLength,
                            int maxLength,
                            int index)
        Sets the component's type, minimum and maximum length.
        Parameters:
        type - The regular expression component type.
        minLength - The component's minimum length.
        maxLength - The component's maximum length.
        index - The component's position in the pattern.
    • Method Detail

      • type

        public final int type()
        Returns this component's type. Return value will be one of
        • LITERAL
        • CHARACTER_SET
        • ANY_CHAR
        Returns:
        this component's type.
      • minimumSize

        public final int minimumSize()
        Returns the component's minimum size. This component must match at least this many times.
        Returns:
        the component's minimum size.
      • maximumSize

        public final int maximumSize()
        Returns the component's maximum size. This component must match at most this many times (inclusive).
        Returns:
        the component's maximum size.
      • index

        public final int index()
        Returns the component's pattern index.
        Returns:
        the component's pattern index.
      • lessThan

        public abstract boolean lessThan​(char c)
        Returns true if this component is less than the character c; returns false otherwise.
        Parameters:
        c - Test against this character.
        Returns:
        true if this component is less than the character c; returns false otherwise.
      • equalTo

        public abstract boolean equalTo​(char c)
        Returns true if this component is equal to the character c; returns false otherwise.
        Parameters:
        c - Test against this character.
        Returns:
        true if this component is equal to the character c; returns false otherwise.
      • greaterThan

        public abstract boolean greaterThan​(char c)
        Returns true if this component is greater than the character c; returns false otherwise.
        Parameters:
        c - Test against this character.
        Returns:
        true if this component is greater than the character c; returns false otherwise.
      • appendSize

        protected void appendSize​(StringBuilder buffer)
        Adds the size to the output only if not {1, 1}.
        Parameters:
        buffer - Append the size to this output buffer.