Class Util
java.lang.Object
com.github.curiousoddman.rgxgen.util.Util
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcompactOverlappingRangesAndSymbols(List<SymbolRange> originalSymbolRanges, CharList originalSymbols, List<SymbolRange> compactedRanges, CharList compactedSymbols) static BigIntegerCount number of variation of words in case insensitive manner.static OptionalIntindexOfNextCaseSensitiveCharacter(CharSequence text, int startIndex) Finds next case sensitive character.static voidinvertSymbolsAndRanges(List<SymbolRange> symbolRanges, CharList symbols, SymbolRange allCharactersRange, List<SymbolRange> invertedRanges, CharList invertedCharacters) In terms of sets = invertedRanges and invertedCharacters = allCharacterRange - symbols and symbolRanges i.e.static booleanisRightCanContinueLeft(SymbolRange left, SymbolRange right) static booleanisRightWithinLeft(SymbolRange left, SymbolRange right) makeVariations(List<String> originalTexts, char characterToReplace, char... allowedReplacements) Method creates variation by replacing characterToReplace with all allowedReplacements (one at a time)static StringrandomlyChangeCase(Random rnd, String input) Randomly change case for the letters in a stringstatic StringrepeatChar(char c, int times) Repeats text multiple times
-
Constructor Details
-
Util
public Util()
-
-
Method Details
-
repeatChar
Repeats text multiple times- Parameters:
c- character to repeattimes- number of times. Values less or equal to zero will result in empty string- Returns:
- text repeated multiple times
-
randomlyChangeCase
Randomly change case for the letters in a string- Parameters:
rnd- random to be usedinput- input string to randomize- Returns:
- string with random characters changed case.
-
countCaseInsensitiveVariations
Count number of variation of words in case insensitive manner. For example for word "a" - there are 2 variation ("a" and "A"). For word "1a" - there are also 2 variations ("1a" and "1A") For word "AB" - there are 4 variations: ("ab", "aB", "Ab", "BB")- Parameters:
value- word to calculate variations- Returns:
- number of variations.
-
indexOfNextCaseSensitiveCharacter
Finds next case sensitive character. Case sensitive character is either lower-case or upper-case character.- Parameters:
text- text to be analyzedstartIndex- start search from index.- Returns:
- index of next case sensitive character or
emptyif no such character present
-
makeVariations
public static Set<String> makeVariations(List<String> originalTexts, char characterToReplace, char... allowedReplacements) Method creates variation by replacing characterToReplace with all allowedReplacements (one at a time)- Parameters:
originalTexts- texts from which variation are to be madecharacterToReplace- make variations by replacing this character in originalTextallowedReplacements- replace characterToReplace with each of these characters- Returns:
- all unique variations
-
invertSymbolsAndRanges
public static void invertSymbolsAndRanges(List<SymbolRange> symbolRanges, CharList symbols, SymbolRange allCharactersRange, List<SymbolRange> invertedRanges, CharList invertedCharacters) In terms of sets = invertedRanges and invertedCharacters = allCharacterRange - symbols and symbolRanges i.e. in invertedRanges and invertedCharacters are all characters that are not in symbols and symbolRanges- Parameters:
symbolRanges-symbols-allCharactersRange-invertedRanges-invertedCharacters-
-
compactOverlappingRangesAndSymbols
public static void compactOverlappingRangesAndSymbols(List<SymbolRange> originalSymbolRanges, CharList originalSymbols, List<SymbolRange> compactedRanges, CharList compactedSymbols) -
isRightCanContinueLeft
-
isRightWithinLeft
-