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
ARegularExpression
representing 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 TopAtom
INSTANCE
The singleton instance.static java.lang.String
STRING
The 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 int
compareToAux(RegularExpression other)
AuxiliaryRegularExpression.compareTo(RegularExpression)
that can safely assume thatother
is an object of the same class asthis
.boolean
contains(java.lang.String s)
Yieldstrue
if and only if this regular expression always contains the given string.boolean
endsWith(java.lang.String s)
Yieldstrue
if 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.boolean
is(java.lang.String str)
Yieldstrue
if and only if this regular expression corresponds to the given string.boolean
isEmpty()
Yieldstrue
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)
Yieldstrue
if and only if this regular expression may contain the given string.boolean
mayEndWith(java.lang.String s)
Yieldstrue
if and only if this regular expression may end with the given string.boolean
mayStartWith(java.lang.String s)
Yieldstrue
if and only if this regular expression may start with the given string.int
minLength()
Yields the minimum length of this symbol.RegularExpression
reverse()
Yields a new symbol that corresponds to this one, but read back-to-front.boolean
startsWith(java.lang.String s)
Yieldstrue
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>>
AtoAutomaton(AutomataFactory<A,T> factory)
Transforms this regular expression into its equivalent automaton.protected RegularExpression
topAsEmptyString()
Yields a new regular expression where allTopAtom
are assumed to have length zero.protected RegularExpression
topAsSingleChar()
Yields a new regular expression where allTopAtom
are 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:RegularExpression
Transforms this regular expression into its equivalent automaton.- Overrides:
toAutomaton
in classAtom
- Type Parameters:
A
- the concrete type ofAutomaton
that this method yieldsT
- the concrete type ofTransitionSymbol
s that instances ofA
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.- Overrides:
substringAux
in 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:RegularExpression
Yieldstrue
if 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:RegularExpression
Yieldstrue
if and only if this regular expression corresponds to the given string.
-
maxLength
public int maxLength()
Description copied from interface:TransitionSymbol
Yields the maximum length of this symbol.- Specified by:
maxLength
in interfaceTransitionSymbol<RegularExpression>
- Overrides:
maxLength
in classAtom
- Returns:
- the maximum length
-
minLength
public int minLength()
Description copied from interface:TransitionSymbol
Yields the minimum length of this symbol.- Specified by:
minLength
in interfaceTransitionSymbol<RegularExpression>
- Overrides:
minLength
in classAtom
- Returns:
- the minimum length
-
mayContain
public boolean mayContain(java.lang.String s)
Description copied from class:RegularExpression
Yieldstrue
if and only if this regular expression may contain the given string.- Overrides:
mayContain
in classAtom
- Parameters:
s
- the string- Returns:
true
if that condition holds
-
contains
public boolean contains(java.lang.String s)
Description copied from class:RegularExpression
Yieldstrue
if and only if this regular expression always contains the given string.
-
mayStartWith
public boolean mayStartWith(java.lang.String s)
Description copied from class:RegularExpression
Yieldstrue
if and only if this regular expression may start with the given string.- Overrides:
mayStartWith
in classAtom
- Parameters:
s
- the string- Returns:
true
if that condition holds
-
startsWith
public boolean startsWith(java.lang.String s)
Description copied from class:RegularExpression
Yieldstrue
if and only if this regular expression always starts with the given string.- Overrides:
startsWith
in classAtom
- Parameters:
s
- the string- Returns:
true
if that condition holds
-
mayEndWith
public boolean mayEndWith(java.lang.String s)
Description copied from class:RegularExpression
Yieldstrue
if and only if this regular expression may end with the given string.- Overrides:
mayEndWith
in classAtom
- Parameters:
s
- the string- Returns:
true
if that condition holds
-
endsWith
public boolean endsWith(java.lang.String s)
Description copied from class:RegularExpression
Yieldstrue
if and only if this regular expression always ends with the given string.
-
topAsSingleChar
protected RegularExpression topAsSingleChar()
Description copied from class:RegularExpression
Yields a new regular expression where allTopAtom
are assumed to have length one.- Overrides:
topAsSingleChar
in classAtom
- Returns:
- the regular expression with shrinked top regular expressions
-
topAsEmptyString
protected RegularExpression topAsEmptyString()
Description copied from class:RegularExpression
Yields a new regular expression where allTopAtom
are assumed to have length zero.- Overrides:
topAsEmptyString
in classAtom
- Returns:
- the regular expression with empty top regular expressions
-
reverse
public RegularExpression reverse()
Description copied from interface:TransitionSymbol
Yields a new symbol that corresponds to this one, but read back-to-front.- Specified by:
reverse
in interfaceTransitionSymbol<RegularExpression>
- Overrides:
reverse
in classAtom
- 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.
-
compareToAux
protected int compareToAux(RegularExpression other)
Description copied from class:RegularExpression
AuxiliaryRegularExpression.compareTo(RegularExpression)
that can safely assume thatother
is an object of the same class asthis
.- Overrides:
compareToAux
in 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
-
-