Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
 /**
  * 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;
   }
 }
Ejemplo n.º 3
0
 /** @see #set(Range) */
 protected void set(char min, char max) {
   set(new Range(min, max));
 }