Class Atom

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Atom EPSILON
      A unique constant for the epsilon (empty) string.
    • Constructor Summary

      Constructors 
      Constructor Description
      Atom​(java.lang.String s)
      Builds the atom.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected int compareToAux​(RegularExpression other)
      Auxiliary RegularExpression.compareTo(RegularExpression) that can safely assume that other is an object of the same class as this.
      boolean contains​(java.lang.String s)
      Yields true if and only if this regular expression always contains the given string.
      boolean endsWith​(java.lang.String s)
      Yields true if and only if this regular expression always ends with the given string.
      boolean equals​(java.lang.Object obj)  
      RegularExpression[] explode()
      Yields a new regular expression that is the exploded version of this one, that is, where all atoms have been broken down to the composition of the characters that compose their inner strings.
      java.lang.String getString()
      Yields the inner string of this atom.
      int hashCode()  
      boolean is​(java.lang.String str)
      Yields true if and only if this regular expression corresponds to the given string.
      boolean isEmpty()
      Yields true if and only if this regular expression corresponds to the empty string or to no strings at all.
      int maxLength()
      Yields the maximum length of this symbol.
      boolean mayContain​(java.lang.String s)
      Yields true if and only if this regular expression may contain the given string.
      boolean mayEndWith​(java.lang.String s)
      Yields true if and only if this regular expression may end with the given string.
      boolean mayStartWith​(java.lang.String s)
      Yields true if and only if this regular expression may start with the given string.
      int minLength()
      Yields the minimum length of this symbol.
      protected boolean readsWhiteSpaceString()
      Checks whether this regular expression recognize a string made just of whitespaces.
      RegularExpression repeat​(long n)
      Yields a new regular expression corresponding to the n-repetition of this.
      RegularExpression reverse()
      Yields a new symbol that corresponds to this one, but read back-to-front.
      RegularExpression simplify()
      Yields a simplified version of this regular expression.
      boolean startsWith​(java.lang.String s)
      Yields true if and only if this regular expression always starts with the given string.
      protected java.util.Set<RegularExpression.PartialSubstring> substringAux​(int charsToSkip, int missingChars)
      Returns the set of all possible substrings of this regular expression, starting at the given index (inclusive) and ending at the given index (exclusive).
      <A extends Automaton<A,​T>,​T extends TransitionSymbol<T>>
      A
      toAutomaton​(AutomataFactory<A,​T> factory)
      Transforms this regular expression into its equivalent automaton.
      protected RegularExpression topAsEmptyString()
      Yields a new regular expression where all TopAtom are assumed to have length zero.
      protected RegularExpression topAsSingleChar()
      Yields a new regular expression where all TopAtom are assumed to have length one.
      java.lang.String toString()  
      RegularExpression trimLeft()
      Yields a new regular expression where leading whitespaces have been removed from this.
      RegularExpression trimRight()
      Yields a new regular expression where trailing whitespaces have been removed from this.
      protected RegularExpression unrollStarToFixedLength​(int length)
      Yields a new regular expression where all Star have been unrolled to a sequence of their inner regular expression of length length.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • EPSILON

        public static final Atom EPSILON
        A unique constant for the epsilon (empty) string.
    • Constructor Detail

      • Atom

        public Atom​(java.lang.String s)
        Builds the atom.
        Parameters:
        s - the string to be represented by this atom
    • Method Detail

      • getString

        public java.lang.String getString()
        Yields the inner string of this atom. Note that this method will return an empty string if this is EPSILON, or TopAtom.STRING if this is an instance of TopAtom.
        Returns:
        the underlying string
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • simplify

        public RegularExpression simplify()
        Description copied from class: RegularExpression
        Yields a simplified version of this regular expression. Simplification happens through heuristics.
        Specified by:
        simplify in class RegularExpression
        Returns:
        a simplified regular expression equivalent to this
      • toAutomaton

        public <A extends Automaton<A,​T>,​T extends TransitionSymbol<T>> A toAutomaton​(AutomataFactory<A,​T> factory)
        Description copied from class: RegularExpression
        Transforms this regular expression into its equivalent automaton.
        Specified by:
        toAutomaton in class RegularExpression
        Type Parameters:
        A - the concrete type of Automaton that this method yields
        T - the concrete type of TransitionSymbols that instances of A have on their transitions
        Parameters:
        factory - the factory that can be used to create the automaton
        Returns:
        the automaton
      • substringAux

        protected java.util.Set<RegularExpression.PartialSubstring> substringAux​(int charsToSkip,
                                                                                 int missingChars)
        Description copied from class: RegularExpression
        Returns the set of all possible substrings of this regular expression, starting at the given index (inclusive) and ending at the given index (exclusive). Each substring is decorated with the number of characters that are still missing to reach the beginning of the substring, and the number of characters that still need to be added to the string to reach the desired length.
        Specified by:
        substringAux in class RegularExpression
        Parameters:
        charsToSkip - the number of characters to skip before starting to collect the substring
        missingChars - the number of missing characters to complete the substring
        Returns:
        the set of partial substrings
      • isEmpty

        public boolean isEmpty()
        Description copied from class: RegularExpression
        Yields true if and only if this regular expression corresponds to the empty string or to no strings at all.
        Specified by:
        isEmpty in class RegularExpression
        Returns:
        true if that condition holds
      • is

        public boolean is​(java.lang.String str)
        Description copied from class: RegularExpression
        Yields true if and only if this regular expression corresponds to the given string.
        Specified by:
        is in class RegularExpression
        Parameters:
        str - the string
        Returns:
        true if that condition holds
      • maxLength

        public int maxLength()
        Description copied from interface: TransitionSymbol
        Yields the maximum length of this symbol.
        Returns:
        the maximum length
      • minLength

        public int minLength()
        Description copied from interface: TransitionSymbol
        Yields the minimum length of this symbol.
        Returns:
        the minimum length
      • mayContain

        public boolean mayContain​(java.lang.String s)
        Description copied from class: RegularExpression
        Yields true if and only if this regular expression may contain the given string.
        Specified by:
        mayContain in class RegularExpression
        Parameters:
        s - the string
        Returns:
        true if that condition holds
      • contains

        public boolean contains​(java.lang.String s)
        Description copied from class: RegularExpression
        Yields true if and only if this regular expression always contains the given string.
        Specified by:
        contains in class RegularExpression
        Parameters:
        s - the string
        Returns:
        true if that condition holds
      • mayStartWith

        public boolean mayStartWith​(java.lang.String s)
        Description copied from class: RegularExpression
        Yields true if and only if this regular expression may start with the given string.
        Specified by:
        mayStartWith in class RegularExpression
        Parameters:
        s - the string
        Returns:
        true if that condition holds
      • startsWith

        public boolean startsWith​(java.lang.String s)
        Description copied from class: RegularExpression
        Yields true if and only if this regular expression always starts with the given string.
        Specified by:
        startsWith in class RegularExpression
        Parameters:
        s - the string
        Returns:
        true if that condition holds
      • mayEndWith

        public boolean mayEndWith​(java.lang.String s)
        Description copied from class: RegularExpression
        Yields true if and only if this regular expression may end with the given string.
        Specified by:
        mayEndWith in class RegularExpression
        Parameters:
        s - the string
        Returns:
        true if that condition holds
      • endsWith

        public boolean endsWith​(java.lang.String s)
        Description copied from class: RegularExpression
        Yields true if and only if this regular expression always ends with the given string.
        Specified by:
        endsWith in class RegularExpression
        Parameters:
        s - the string
        Returns:
        true if that condition holds
      • unrollStarToFixedLength

        protected RegularExpression unrollStarToFixedLength​(int length)
        Description copied from class: RegularExpression
        Yields a new regular expression where all Star have been unrolled to a sequence of their inner regular expression of length length.
        Specified by:
        unrollStarToFixedLength in class RegularExpression
        Parameters:
        length - the length
        Returns:
        the regular expression with unrolled stars
      • reverse

        public RegularExpression reverse()
        Description copied from interface: TransitionSymbol
        Yields a new symbol that corresponds to this one, but read back-to-front.
        Returns:
        the reversed symbol
      • explode

        public RegularExpression[] explode()
        Description copied from class: RegularExpression
        Yields a new regular expression that is the exploded version of this one, that is, where all atoms have been broken down to the composition of the characters that compose their inner strings.
        Specified by:
        explode in class RegularExpression
        Returns:
        the exploded regular expression
      • repeat

        public RegularExpression repeat​(long n)
        Description copied from class: RegularExpression
        Yields a new regular expression corresponding to the n-repetition of this.
        Specified by:
        repeat in class RegularExpression
        Parameters:
        n - number of repetitions
        Returns:
        a new regular expression corresponding to the n-repetition of this
      • trimLeft

        public RegularExpression trimLeft()
        Description copied from class: RegularExpression
        Yields a new regular expression where leading whitespaces have been removed from this.
        Specified by:
        trimLeft in class RegularExpression
        Returns:
        a new regular expression where leading whitespaces have been removed from this
      • trimRight

        public RegularExpression trimRight()
        Description copied from class: RegularExpression
        Yields a new regular expression where trailing whitespaces have been removed from this.
        Specified by:
        trimRight in class RegularExpression
        Returns:
        a new regular expression where trailing whitespaces have been removed from this
      • readsWhiteSpaceString

        protected boolean readsWhiteSpaceString()
        Description copied from class: RegularExpression
        Checks whether this regular expression recognize a string made just of whitespaces.
        Specified by:
        readsWhiteSpaceString in class RegularExpression
        Returns:
        true if this regular expression recognize a string made just of whitespaces, false otherwise.