Class TopAtom
- java.lang.Object
-
- it.unive.lisa.util.datastructures.regex.RegularExpression
-
- it.unive.lisa.util.datastructures.regex.Atom
-
- it.unive.lisa.util.datastructures.regex.TopAtom
-
- All Implemented Interfaces:
TransitionSymbol<RegularExpression>,java.lang.Comparable<RegularExpression>
public final class TopAtom extends Atom
ARegularExpressionrepresenting a sequence of unknown characters of arbitrary length.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class it.unive.lisa.util.datastructures.regex.RegularExpression
RegularExpression.PartialSubstring
-
-
Field Summary
Fields Modifier and Type Field Description static TopAtomINSTANCEThe singleton instance.static java.lang.StringSTRINGThe string used to represent this regular expression.-
Fields inherited from interface it.unive.lisa.util.datastructures.automaton.TransitionSymbol
UNKNOWN_SYMBOL
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intcompareToAux(RegularExpression other)AuxiliaryRegularExpression.compareTo(RegularExpression)that can safely assume thatotheris an object of the same class asthis.booleancontains(java.lang.String s)Yieldstrueif and only if this regular expression always contains the given string.booleanendsWith(java.lang.String s)Yieldstrueif and only if this regular expression always ends with the given string.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.booleanis(java.lang.String str)Yieldstrueif and only if this regular expression corresponds to the given string.booleanisEmpty()Yieldstrueif and only if this regular expression corresponds to the empty string or to no strings at all.intmaxLength()Yields the maximum length of this symbol.booleanmayContain(java.lang.String s)Yieldstrueif and only if this regular expression may contain the given string.booleanmayEndWith(java.lang.String s)Yieldstrueif and only if this regular expression may end with the given string.booleanmayStartWith(java.lang.String s)Yieldstrueif and only if this regular expression may start with the given string.intminLength()Yields the minimum length of this symbol.RegularExpressionreverse()Yields a new symbol that corresponds to this one, but read back-to-front.booleanstartsWith(java.lang.String s)Yieldstrueif 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>>
AtoAutomaton(AutomataFactory<A,T> factory)Transforms this regular expression into its equivalent automaton.protected RegularExpressiontopAsEmptyString()Yields a new regular expression where allTopAtomare assumed to have length zero.protected RegularExpressiontopAsSingleChar()Yields a new regular expression where allTopAtomare assumed to have length one.-
Methods inherited from class it.unive.lisa.util.datastructures.regex.Atom
equals, getString, hashCode, readsWhiteSpaceString, repeat, simplify, toString, trimLeft, trimRight, unrollStarToFixedLength
-
-
-
-
Field Detail
-
STRING
public static final java.lang.String STRING
The string used to represent this regular expression.- See Also:
- Constant Field Values
-
INSTANCE
public static final TopAtom INSTANCE
The singleton instance.
-
-
Method Detail
-
toAutomaton
public <A extends Automaton<A,T>,T extends TransitionSymbol<T>> A toAutomaton(AutomataFactory<A,T> factory)
Description copied from class:RegularExpressionTransforms this regular expression into its equivalent automaton.- Overrides:
toAutomatonin classAtom- Type Parameters:
A- the concrete type ofAutomatonthat this method yieldsT- the concrete type ofTransitionSymbols that instances ofAhave 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:RegularExpressionReturns 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.- Overrides:
substringAuxin classAtom- Parameters:
charsToSkip- the number of characters to skip before starting to collect the substringmissingChars- the number of missing characters to complete the substring- Returns:
- the set of partial substrings
-
isEmpty
public boolean isEmpty()
Description copied from class:RegularExpressionYieldstrueif and only if this regular expression corresponds to the empty string or to no strings at all.
-
is
public boolean is(java.lang.String str)
Description copied from class:RegularExpressionYieldstrueif and only if this regular expression corresponds to the given string.
-
maxLength
public int maxLength()
Description copied from interface:TransitionSymbolYields the maximum length of this symbol.- Specified by:
maxLengthin interfaceTransitionSymbol<RegularExpression>- Overrides:
maxLengthin classAtom- Returns:
- the maximum length
-
minLength
public int minLength()
Description copied from interface:TransitionSymbolYields the minimum length of this symbol.- Specified by:
minLengthin interfaceTransitionSymbol<RegularExpression>- Overrides:
minLengthin classAtom- Returns:
- the minimum length
-
mayContain
public boolean mayContain(java.lang.String s)
Description copied from class:RegularExpressionYieldstrueif and only if this regular expression may contain the given string.- Overrides:
mayContainin classAtom- Parameters:
s- the string- Returns:
trueif that condition holds
-
contains
public boolean contains(java.lang.String s)
Description copied from class:RegularExpressionYieldstrueif and only if this regular expression always contains the given string.
-
mayStartWith
public boolean mayStartWith(java.lang.String s)
Description copied from class:RegularExpressionYieldstrueif and only if this regular expression may start with the given string.- Overrides:
mayStartWithin classAtom- Parameters:
s- the string- Returns:
trueif that condition holds
-
startsWith
public boolean startsWith(java.lang.String s)
Description copied from class:RegularExpressionYieldstrueif and only if this regular expression always starts with the given string.- Overrides:
startsWithin classAtom- Parameters:
s- the string- Returns:
trueif that condition holds
-
mayEndWith
public boolean mayEndWith(java.lang.String s)
Description copied from class:RegularExpressionYieldstrueif and only if this regular expression may end with the given string.- Overrides:
mayEndWithin classAtom- Parameters:
s- the string- Returns:
trueif that condition holds
-
endsWith
public boolean endsWith(java.lang.String s)
Description copied from class:RegularExpressionYieldstrueif and only if this regular expression always ends with the given string.
-
topAsSingleChar
protected RegularExpression topAsSingleChar()
Description copied from class:RegularExpressionYields a new regular expression where allTopAtomare assumed to have length one.- Overrides:
topAsSingleCharin classAtom- Returns:
- the regular expression with shrinked top regular expressions
-
topAsEmptyString
protected RegularExpression topAsEmptyString()
Description copied from class:RegularExpressionYields a new regular expression where allTopAtomare assumed to have length zero.- Overrides:
topAsEmptyStringin classAtom- Returns:
- the regular expression with empty top regular expressions
-
reverse
public RegularExpression reverse()
Description copied from interface:TransitionSymbolYields a new symbol that corresponds to this one, but read back-to-front.- Specified by:
reversein interfaceTransitionSymbol<RegularExpression>- Overrides:
reversein classAtom- Returns:
- the reversed symbol
-
explode
public RegularExpression[] explode()
Description copied from class:RegularExpressionYields 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.
-
compareToAux
protected int compareToAux(RegularExpression other)
Description copied from class:RegularExpressionAuxiliaryRegularExpression.compareTo(RegularExpression)that can safely assume thatotheris an object of the same class asthis.- Overrides:
compareToAuxin classAtom- Parameters:
other- the other regular expression- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object
-
-