Implementing new Solution refs #13207
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/social-networking/social-util-library@176784 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
73b98fb122
commit
2cf0d20a63
|
@ -7,7 +7,13 @@ import java.util.regex.Pattern;
|
|||
|
||||
public class GCubeStringTokenizer {
|
||||
|
||||
/**
|
||||
* The default delimiter regex is any whitespaces '\s'
|
||||
*/
|
||||
public static final String DEFAULT_DELIMITER_REGEX = "\\s";
|
||||
|
||||
private final String originalString;
|
||||
private final String delimiterRegex;
|
||||
|
||||
private Pattern pattern;
|
||||
private Matcher matcher;
|
||||
|
@ -15,8 +21,13 @@ public class GCubeStringTokenizer {
|
|||
private List<Token> tokens;
|
||||
|
||||
public GCubeStringTokenizer(String string) {
|
||||
this(string, DEFAULT_DELIMITER_REGEX);
|
||||
}
|
||||
|
||||
public GCubeStringTokenizer(String string, String delimiterRegex) {
|
||||
this.originalString = string;
|
||||
this.pattern = Pattern.compile("\\s");
|
||||
this.delimiterRegex = delimiterRegex;
|
||||
this.pattern = Pattern.compile(delimiterRegex);
|
||||
this.matcher = pattern.matcher(originalString);
|
||||
}
|
||||
|
||||
|
@ -49,4 +60,12 @@ public class GCubeStringTokenizer {
|
|||
return tokens;
|
||||
}
|
||||
|
||||
public String getOriginalString() {
|
||||
return originalString;
|
||||
}
|
||||
|
||||
public String getDelimiterRegex() {
|
||||
return delimiterRegex;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue