Class SimpleAutomaton

  • All Implemented Interfaces:
    it.unive.lisa.util.datastructures.automaton.AutomataFactory<SimpleAutomaton,​StringSymbol>

    public final class SimpleAutomaton
    extends it.unive.lisa.util.datastructures.automaton.Automaton<SimpleAutomaton,​StringSymbol>
    A class that describes an generic automaton(dfa, nfa, epsilon nfa) using a standard alphabet of single characters.
    • Field Summary

      • Fields inherited from class it.unive.lisa.util.datastructures.automaton.Automaton

        deterministic, minimized, states, transitions
    • Constructor Summary

      Constructors 
      Constructor Description
      SimpleAutomaton​(java.lang.String s)
      Builds a new automaton that accepts a given string.
      SimpleAutomaton​(java.util.SortedSet<it.unive.lisa.util.datastructures.automaton.State> states, java.util.SortedSet<it.unive.lisa.util.datastructures.automaton.Transition<StringSymbol>> transitions)
      Builds a new automaton with given states and transitions.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      StringSymbol concat​(StringSymbol first, StringSymbol second)  
      SimpleAutomaton emptyLanguage()  
      SimpleAutomaton emptyString()  
      StringSymbol epsilon()  
      SimpleAutomaton from​(java.util.SortedSet<it.unive.lisa.util.datastructures.automaton.State> states, java.util.SortedSet<it.unive.lisa.util.datastructures.automaton.Transition<StringSymbol>> transitions)  
      SimpleAutomaton repeat​(Interval i)
      Yields a new automaton instance recognizing each string of this automaton repeated k-times, with k belonging to intv.
      SimpleAutomaton replace​(SimpleAutomaton toReplace, SimpleAutomaton str)
      Yields a new automaton where all occurrences of strings recognized by toReplace are replaced with the automaton str, assuming that toReplace is finite (i.e., no loops nor top-transitions).
      SimpleAutomaton singleString​(java.lang.String string)  
      it.unive.lisa.util.datastructures.regex.RegularExpression symbolToRegex​(StringSymbol symbol)  
      SimpleAutomaton trim()
      Yields a new automaton where leading and trailing whitespaces have been removed from this.
      SimpleAutomaton trimLeft()
      Yields a new automaton where leading whitespaces have been removed from this.
      SimpleAutomaton trimRight()
      Yields a new automaton where trailing whitespaces have been removed from this.
      SimpleAutomaton unknownString()  
      boolean validateString​(java.lang.String str)
      Computes all the automaton transitions to validate a given string str.
      • Methods inherited from class it.unive.lisa.util.datastructures.automaton.Automaton

        acceptsEmptyLanguage, addState, addTransition, addTransition, areMutuallyReachable, commonAlphabet, complement, concat, copy, determinize, epsilonClosure, epsilonClosure, equals, extractLongestString, factors, factorsChangingInitialState, getAllPaths, getAllTransitionsConnecting, getAlphabet, getFinalStates, getIngoingTransitionsFrom, getInitialState, getInitialStates, getLanguage, getNextStates, getNextSymbols, getOutgoingTransitionsFrom, getReadableSymbolsFromState, getReadableSymbolsFromStates, getStateFromPair, getStates, getTransitions, hasCycle, hashCode, hasOnlyOnePath, intersection, isContained, isDeterministic, isEqualTo, lenghtOfLongestString, makeAcyclic, maximumPath, minimize, minimumPath, nextStatesNFA, prefix, prettyPrint, recognizesExactlyOneString, removeStates, removeTransitions, removeUnreachableStates, reverse, star, suffix, toRegex, toSingleInitalState, toString, totalize, union, widening
      • Methods inherited from class java.lang.Object

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

      • SimpleAutomaton

        public SimpleAutomaton​(java.util.SortedSet<it.unive.lisa.util.datastructures.automaton.State> states,
                               java.util.SortedSet<it.unive.lisa.util.datastructures.automaton.Transition<StringSymbol>> transitions)
        Builds a new automaton with given states and transitions.
        Parameters:
        states - the set of states of the new automaton
        transitions - the set of the transitions of the new automaton
      • SimpleAutomaton

        public SimpleAutomaton​(java.lang.String s)
        Builds a new automaton that accepts a given string.
        Parameters:
        s - the only string accepted by the automaton.
    • Method Detail

      • singleString

        public SimpleAutomaton singleString​(java.lang.String string)
      • from

        public SimpleAutomaton from​(java.util.SortedSet<it.unive.lisa.util.datastructures.automaton.State> states,
                                    java.util.SortedSet<it.unive.lisa.util.datastructures.automaton.Transition<StringSymbol>> transitions)
      • symbolToRegex

        public it.unive.lisa.util.datastructures.regex.RegularExpression symbolToRegex​(StringSymbol symbol)
        Specified by:
        symbolToRegex in class it.unive.lisa.util.datastructures.automaton.Automaton<SimpleAutomaton,​StringSymbol>
      • validateString

        public boolean validateString​(java.lang.String str)
        Computes all the automaton transitions to validate a given string str.
        Parameters:
        str - String that has to be checked.
        Returns:
        a boolean value that indicates either if str has been accepted or not.
      • replace

        public SimpleAutomaton replace​(SimpleAutomaton toReplace,
                                       SimpleAutomaton str)
                                throws it.unive.lisa.util.datastructures.automaton.CyclicAutomatonException
        Yields a new automaton where all occurrences of strings recognized by toReplace are replaced with the automaton str, assuming that toReplace is finite (i.e., no loops nor top-transitions). The resulting automaton is then collapsed.

        Parameters:
        toReplace - the automaton recognizing the strings to replace
        str - the automaton that must be used as replacement
        Returns:
        the replaced automaton
        Throws:
        it.unive.lisa.util.datastructures.automaton.CyclicAutomatonException - if toReplace contains loops
      • trimLeft

        public SimpleAutomaton trimLeft()
        Yields a new automaton where leading whitespaces have been removed from this.
        Returns:
        a new automaton where leading whitespaces have been removed from this
      • trimRight

        public SimpleAutomaton trimRight()
        Yields a new automaton where trailing whitespaces have been removed from this.
        Returns:
        a new automaton where trailing whitespaces have been removed from this
      • trim

        public SimpleAutomaton trim()
        Yields a new automaton where leading and trailing whitespaces have been removed from this.
        Returns:
        a new automaton where leading trailing whitespaces have been removed from this
      • repeat

        public SimpleAutomaton repeat​(Interval i)
                               throws it.unive.lisa.util.numeric.MathNumberConversionException
        Yields a new automaton instance recognizing each string of this automaton repeated k-times, with k belonging to intv.
        Parameters:
        i - the interval
        Returns:
        a new automaton instance recognizing each string of this automaton repeated k-times, with k belonging to intv
        Throws:
        it.unive.lisa.util.numeric.MathNumberConversionException - if intv is iterated but is not finite