|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.mifmif.common.regex.Generex
public class Generex
A Java utility class that help generating string values that match a given regular expression.It generate all values that are matched by the Regex, a random value, or you can generate only a specific string based on it's lexicographical order .
| Field Summary | |
|---|---|
private dk.brics.automaton.Automaton |
automaton
|
private boolean |
isTransactionNodeBuilt
|
private int |
matchedStringCounter
|
private List<String> |
matchedStrings
|
private Map<String,String> |
predefinedCharacterClasses
|
private int |
preparedTransactionNode
|
private dk.brics.automaton.RegExp |
regExp
|
private Node |
rootNode
|
| Constructor Summary | |
|---|---|
Generex(dk.brics.automaton.Automaton automaton)
|
|
Generex(String regex)
|
|
| Method Summary | |
|---|---|
private void |
buildRootNode()
Prepare the rootNode and it's child nodes so that we can get matchedString by index |
private String |
buildStringFromNode(Node node,
int indexOrder)
|
private void |
generate(String strMatch,
dk.brics.automaton.State state,
int limit)
|
List<String> |
getAllMatchedStrings()
Generate all Strings that matches the given Regex. |
String |
getFirstMatch()
|
String |
getMatchedString(int indexOrder)
|
List<String> |
getMatchedStrings(int limit)
Generate subList with a size of limit of Strings that
matches the given Regex. the Strings are ordered in lexicographical
order. |
Iterator |
iterator()
|
long |
matchedStringsSize()
|
private String |
prepareRandom(String strMatch,
dk.brics.automaton.State state,
int minLength,
int maxLength)
|
private List<Node> |
prepareTransactionNodes(dk.brics.automaton.State state)
Build list of nodes that present possible transactions from the state. |
String |
random()
Generate and return a random String that match the pattern used in this Generex. |
String |
random(int minLength)
Generate and return a random String that match the pattern used in this Generex, and the string has a length >= minLength |
String |
random(int minLength,
int maxLength)
Generate and return a random String that match the pattern used in this Generex, and the string has a length >= minLength and <=
maxLength |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private Map<String,String> predefinedCharacterClasses
private dk.brics.automaton.RegExp regExp
private dk.brics.automaton.Automaton automaton
private List<String> matchedStrings
private Node rootNode
private boolean isTransactionNodeBuilt
private int matchedStringCounter
private int preparedTransactionNode
| Constructor Detail |
|---|
public Generex(String regex)
public Generex(dk.brics.automaton.Automaton automaton)
| Method Detail |
|---|
public String getMatchedString(int indexOrder)
indexOrder - ( 1<= indexOrder <=n)
indexOrder between 1 and n where
n is the number of matched String.StackOverflowError
private String buildStringFromNode(Node node,
int indexOrder)
public String getFirstMatch()
public long matchedStringsSize()
private void buildRootNode()
private void generate(String strMatch,
dk.brics.automaton.State state,
int limit)
private List<Node> prepareTransactionNodes(dk.brics.automaton.State state)
state.
state -
public List<String> getAllMatchedStrings()
public List<String> getMatchedStrings(int limit)
limit of Strings that
matches the given Regex. the Strings are ordered in lexicographical
order.
limit -
public String random()
public String random(int minLength)
minLength
minLength -
public String random(int minLength,
int maxLength)
minLength and <=
maxLength
minLength - maxLength -
private String prepareRandom(String strMatch,
dk.brics.automaton.State state,
int minLength,
int maxLength)
public Iterator iterator()
iterator in interface Iterable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||