Class RegularExpressionParser<E>

  • Type Parameters:
    E - the type of the sequence elements
    All Implemented Interfaces:
    com.google.common.base.Function<java.lang.String,​RegularExpression<E>>, java.util.function.Function<java.lang.String,​RegularExpression<E>>

    public abstract class RegularExpressionParser<E>
    extends java.lang.Object
    implements com.google.common.base.Function<java.lang.String,​RegularExpression<E>>
    A regular expression parser turns strings into RegularExpression objects.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      RegularExpression<E> apply​(java.lang.String string)  
      abstract Expression.BaseExpression<E> factory​(java.lang.String token)
      The factory method creates an expression from the supplied token string.
      private static int indexOfClose​(java.lang.String string, int start, char open, char close)  
      RegularExpression<E> parse​(java.lang.String string)  
      java.lang.String readToken​(java.lang.String remaining)
      Read a token from the remaining text and return it.
      java.util.List<Expression<E>> tokenize​(java.lang.String string)
      Convert a list of tokens (<...>) to a list of expressions.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface com.google.common.base.Function

        equals
      • Methods inherited from interface java.util.function.Function

        andThen, compose
    • Constructor Detail

      • RegularExpressionParser

        public RegularExpressionParser()
    • Method Detail

      • factory

        public abstract Expression.BaseExpression<E> factory​(java.lang.String token)
        The factory method creates an expression from the supplied token string.
        Parameters:
        token - a string representation of a token
        Returns:
        an evaluatable representation of a token
      • apply

        public RegularExpression<E> apply​(java.lang.String string)
        Specified by:
        apply in interface com.google.common.base.Function<java.lang.String,​RegularExpression<E>>
        Specified by:
        apply in interface java.util.function.Function<java.lang.String,​RegularExpression<E>>
      • readToken

        public java.lang.String readToken​(java.lang.String remaining)
        Read a token from the remaining text and return it. This is a default implementation that is overridable. In the default implementation, the starting and ending token characters are not escapable. If this implemenation is overridden, A token MUST ALWAYS start with '<' or '[' and end with '>' or ']'.
        Parameters:
        remaining -
        Returns:
      • tokenize

        public java.util.List<Expression<E>> tokenize​(java.lang.String string)
        Convert a list of tokens (<...>) to a list of expressions.
        Parameters:
        tokens -
        factory - Factory class to create a BaseExpression from the text between angled brackets.
        Returns:
      • indexOfClose

        private static int indexOfClose​(java.lang.String string,
                                        int start,
                                        char open,
                                        char close)