예제 #1
0
파일: Chset.java 프로젝트: ungly/opengse
 /**
  * Creates a new character set which matches a character if that character matches either the
  * {@code left} or {@code right} character sets.
  *
  * <p>left | right
  *
  * @param left The left source character set.
  * @param right The right source character set.
  */
 public static Chset union(Chset left, Chset right) {
   Chset n = left.clone();
   for (Range r : right.ranges) {
     n.set(r);
   }
   return n;
 }
예제 #2
0
파일: Chset.java 프로젝트: ungly/opengse
 /**
  * Class constructor that initializes a {@code Chset} from a string specification.
  *
  * @param spec The string specification to initialize the {@code Chset} from.
  */
 public Chset(String spec) {
   for (int i = 0; i < spec.length(); ) {
     final char s = spec.charAt(i);
     if ((i + 1) < spec.length()) {
       final char n = spec.charAt(i + 1);
       if (n == '-') {
         if ((i + 2) < spec.length()) {
           final char e = spec.charAt(i + 2);
           set(new Range(s, e));
           i += 3;
           continue;
         } else {
           set(new Range(s, s));
           set(new Range('-', '-'));
           break;
         }
       }
     }
     set(new Range(s, s));
     i += 1;
   }
 }
예제 #3
0
파일: Chset.java 프로젝트: ungly/opengse
 /** @see #set(Range) */
 protected void set(char min, char max) {
   set(new Range(min, max));
 }