Class SimpleAutomaton
- java.lang.Object
-
- it.unive.lisa.util.datastructures.automaton.Automaton<SimpleAutomaton,StringSymbol>
-
- it.unive.lisa.analysis.string.fsa.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.
-
-
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 givenstates
andtransitions
.
-
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 ofthis
automaton repeated k-times, with k belonging tointv
.SimpleAutomaton
replace(SimpleAutomaton toReplace, SimpleAutomaton str)
Yields a new automaton where all occurrences of strings recognized bytoReplace
are replaced with the automatonstr
, assuming thattoReplace
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 fromthis
.SimpleAutomaton
trimLeft()
Yields a new automaton where leading whitespaces have been removed fromthis
.SimpleAutomaton
trimRight()
Yields a new automaton where trailing whitespaces have been removed fromthis
.SimpleAutomaton
unknownString()
boolean
validateString(java.lang.String str)
Computes all the automaton transitions to validate a given stringstr
.-
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
-
-
-
-
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 givenstates
andtransitions
.- Parameters:
states
- the set of states of the new automatontransitions
- 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)
-
unknownString
public SimpleAutomaton unknownString()
-
emptyLanguage
public SimpleAutomaton emptyLanguage()
-
emptyString
public SimpleAutomaton emptyString()
-
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)
-
epsilon
public StringSymbol epsilon()
- Specified by:
epsilon
in classit.unive.lisa.util.datastructures.automaton.Automaton<SimpleAutomaton,StringSymbol>
-
concat
public StringSymbol concat(StringSymbol first, StringSymbol second)
- Specified by:
concat
in classit.unive.lisa.util.datastructures.automaton.Automaton<SimpleAutomaton,StringSymbol>
-
symbolToRegex
public it.unive.lisa.util.datastructures.regex.RegularExpression symbolToRegex(StringSymbol symbol)
- Specified by:
symbolToRegex
in classit.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 stringstr
.- 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 bytoReplace
are replaced with the automatonstr
, assuming thattoReplace
is finite (i.e., no loops nor top-transitions). The resulting automaton is then collapsed.
- Parameters:
toReplace
- the automaton recognizing the strings to replacestr
- the automaton that must be used as replacement- Returns:
- the replaced automaton
- Throws:
it.unive.lisa.util.datastructures.automaton.CyclicAutomatonException
- iftoReplace
contains loops
-
trimLeft
public SimpleAutomaton trimLeft()
Yields a new automaton where leading whitespaces have been removed fromthis
.- 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 fromthis
.- 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 fromthis
.- 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 ofthis
automaton repeated k-times, with k belonging tointv
.- Parameters:
i
- the interval- Returns:
- a new automaton instance recognizing each string of
this
automaton repeated k-times, with k belonging tointv
- Throws:
it.unive.lisa.util.numeric.MathNumberConversionException
- ifintv
is iterated but is not finite
-
-