View Javadoc
1   package org.csveed.bean.conversion;
2   
3   import java.util.regex.Pattern;
4   
5   public class PatternConverter extends AbstractConverter<Pattern> {
6   
7       private final int flags;
8   
9       public PatternConverter() {
10          this(0);
11      }
12  
13      public PatternConverter(int flags) {
14          super(Pattern.class);
15          this.flags = flags;
16      }
17  
18      @Override
19      public Pattern fromString(String text) throws Exception {
20          return text != null ? Pattern.compile(text, this.flags) : null;
21      }
22  
23      @Override
24      public String toString(Pattern value) throws Exception {
25          return value != null ? value.pattern() : "";
26      }
27  }