]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.utils/src/org/simantics/utils/strings/ValidatorUtils.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.utils / src / org / simantics / utils / strings / ValidatorUtils.java
1 package org.simantics.utils.strings;
2
3 import java.util.Collection;
4 import java.util.Collections;
5 import java.util.regex.Pattern;
6
7 public class ValidatorUtils {
8
9         public static Pattern alphaNumericPattern(int length) {
10
11                 String pattern = "^(_|\\p{Alnum}){1," + length + "}+$";
12                 return Pattern.compile(pattern);
13                 
14         }
15         
16         public static Collection<StringInputProblem> errorProblem(final String text) {
17                 return Collections.<StringInputProblem>singletonList(new StringInputProblem() {
18                         
19                         @Override
20                         public Severity getSeverity() {
21                                 return Severity.Error;
22                         }
23                         
24                         @Override
25                         public int getEnd() {
26                                 return 0;
27                         }
28                         
29                         @Override
30                         public String getDescription() {
31                                 return text;
32                         }
33                         
34                         @Override
35                         public int getBegin() {
36                                 return 0;
37                         }
38                         
39                 });
40         }
41         
42 }